B3D2XML (code inside)

Blitz3D Forums/Blitz3D Programming/B3D2XML (code inside)

Difference(Posted 2003) [#1]
I have rewritten the B3D2XML program I made some time ago, using Marks dumpb3d.bb as the framework.

I'd like if it you would test and comment, then I will get to work on the XML2B3D part, and put it all in the code archive.

If somebody has some B3D files with custom tags, I'd really like to confirm that output is ok from those. The xml is supposed to look smothing like this for an unknown tag:

<MYTAG size="3456">
<![CDATA[3456byteshere]]>
</MYTAG>

[EDIT] code moved to:

http://www.blitzbasic.com/codearcs/codearcs.php?code=665


Difference(Posted 2003) [#2]
Obs: important update:

There is a small error in b3dfile.bb

Change: Function b3dReadFloat() to Function b3dReadFloat#()
( missing "#" )


Work on the xml>b3d is comming along nicely, more later.


fredborg(Posted 2003) [#3]
Hi Peter,

I will test it tonight, haven't had time the last few days...

I'm thinking we should make some sort of framework for open source 3d importers,
so that there is a base set of functions that people can build on. IE. how the file
is loaded into banks, types or whatever. And then a few functions to build brushes,
textures, meshes, and animations from these banks/types/whatever.

What do you think?

Fredborg


Difference(Posted 2003) [#4]
Conversions both ways is done.

Check out:
http://www.blitzbasic.com/codearcs/codearcs.php?code=665


jhocking(Posted 2003) [#5]
Wonderful! Now maybe someone can finally write a Maya exporter. Writing to your text format would be so easy that I'm tempted to try it myself but I am rather busy right now with other tasks.


Difference(Posted 2003) [#6]
Thanks. I have not gotten much feedback on this. Does it mean that it's ok as it is, or that it's not really of interest to too many people?

@Fredborg: I suggested this some months ago, but responce was so poor, that I gave up on making a common project and made my own functions/typelib. Btw.: there is now a new thread, on exactly this here: http://www.blitzbasic.com/bbs/posts.php?topic=20938

My first version of b3d2xml was based on this lib, but this time I desided to make a clean rewrite, that does only b3d>xml>b3d.


Tranz(Posted 2003) [#7]
Really nice, Peter!

I had a go at this and it's beautiful.

It opens up some options for me that I didn't have before, thanks...thanks alot!


jhocking(Posted 2003) [#8]
Do you have specifications on your XML file format? That would help a lot writing an exporter for specific 3D art tools. As far as I can see (ie. I may have just missed it) it is just the Blitz code, no specs/description of the file format.


Skitchy(Posted 2003) [#9]
Does it support animation? I'm downloading now...


Tranz(Posted 2003) [#10]
read below
|
|
V


Difference(Posted 2003) [#11]
The XML markup is close to a 1:1 translation of the B3D format.

Converting a couple of B3D files with the program should explain it pretty well.

As for the structure of the tags, refer to the B3D structure on the "specs and utils" page on this site.


Maybe there should/could be a DTD (Document Type Definition see http://www.ucc.ie:8080/cocoon/xmlfaq) but I'm not sure it's worth the trouble.

As for the specific markup, here is a little intro:

First tag is a <?xml version="1.0" ?>
All XML files must have such a tag.

Next is the b3d chunk, and following sub chunks.


examples:

The BB3D chunk is marked up like this:
<BB3D version="1" exporter="dumpb3dasxml version 0.1">
or simply:
<BB3D version="1">

All B3D chunks are directly translated into a tag with the same name as the chunk.

Ex: The TEXS chunk is wrapped in: <TEXS> </TEXS> tags

Then for each texture in the TEXS chunk a self closing tag is written like this:

<TEXTURE name="mypicure.jpg" flags="1" blend="2" xpos="0.0" ypos="0.0" xscale="1.0" yscale="1.0" rot="0.0"/>

The BRUS chunk is written like this:

<BRUS count="1">
<BRUSH name="Material0" red="0.8" green="0.8" blue="0.8" alpha="1.0" shininess="0.0" blend="1" fx="0" texture0="0" />
</BRUS>

had there been more than one texture in that brush, it would have had additional:
texture1="4"
texture2="2"
etc.

attributes.

For those chunks that have information assigned to them, this is written as attributes in the starting tag.

ex: <NODE name="ROOT" xpos="0.0" ypos="0.0" zpos="0.0" xscale="1.0" yscale="1.0" zscale="1.0" wrot="1.0" xrot="0.0" yrot="0.0" zrot="0.0">


A vertex is described as:

<VERTEX x="-0.002561" y="2.19739" z="-0.046953" u0="0.87949" v0="0.036783" u1="0.87949" v1="0.036783" />

u0, v0,w0 are for texture coord set 1
u1, v1,w1 are for texture coord set 2
etc.

A vertex normal would be : nx="-1" ny="0" nz="0"

etc. etc.


Please ask questions on anything that is not clear.


jhocking(Posted 2003) [#12]
Tranz, I know what XML is but that is just a generic description and does not cover the specifics of Peter's use of XML to describe a 3D model. His reply is pretty much what I was asking for, specifics of how the data is represented in the XML file. It sounds like your XML file format is pretty much the same as the B3D file format only with XML style tags bracketing data chunks.


Ricky Smith(Posted 2003) [#13]
Peter - Many Thankz for very good and useful routines !