gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > My 3dmax/gmax model exporter

#108195 - chrissieboy - Mon Nov 06, 2006 4:31 pm

Hi guys, im busy with building a script for 3dmax/gmax to export the models to header files, just like the maya exporter.

But i tried to analyse the ouput from the maya exporter, but it not realy make any sense to me?

I'll try to explain my problem, with this code :

Code:

FIFO_COMMAND_PACK(FIFO_BEGIN, FIFO_TEX_COORD, FIFO_COLOR, FIFO_VERTEX16),
GL_TRIANGLE,
TEXTURE_PACK(inttot16(0),inttot16(117)),
RGB15(31,31,31),
VERTEX_PACK(floattov16(0.2619139552),floattov16(0.125)), VERTEX_PACK(floattov16(-0.1084881499),0),

FIFO_COMMAND_PACK(FIFO_TEX_COORD, FIFO_COLOR, FIFO_VERTEX16, FIFO_TEX_COORD),
TEXTURE_PACK(inttot16(8),inttot16(117)),
RGB15(31,31,31),
VERTEX_PACK(floattov16(0.9004603148),floattov16(0.125)), VERTEX_PACK(floattov16(-0.200460121),0),
TEXTURE_PACK(inttot16(0),inttot16(128)),

FIFO_COMMAND_PACK(FIFO_COLOR, FIFO_VERTEX16, FIFO_TEX_COORD, FIFO_COLOR),
RGB15(31,31,31),
VERTEX_PACK(floattov16(0.2309698611),floattov16(0)), VERTEX_PACK(floattov16(-0.09567070752),0),
TEXTURE_PACK(inttot16(8),inttot16(128)),
RGB15(31,31,31),



FIFO_COMMAND_PACK(FIFO_VERTEX16, FIFO_TEX_COORD, FIFO_COLOR, FIFO_VERTEX16),
VERTEX_PACK(floattov16(0.176776737),floattov16(0)), VERTEX_PACK(floattov16(-0.1767765582),0),
TEXTURE_PACK(inttot16(0),inttot16(128)),
RGB15(31,31,31),
VERTEX_PACK(floattov16(0.2309698611),floattov16(0)), VERTEX_PACK(floattov16(-0.09567070752),0),

FIFO_COMMAND_PACK(FIFO_TEX_COORD, FIFO_COLOR, FIFO_VERTEX16, FIFO_TEX_COORD),
TEXTURE_PACK(inttot16(8),inttot16(117)),
RGB15(31,31,31),
VERTEX_PACK(floattov16(0.2004603148),floattov16(0.125)), VERTEX_PACK(floattov16(-0.200460121),0),
TEXTURE_PACK(inttot16(8),inttot16(117)),

FIFO_COMMAND_PACK(FIFO_COLOR, FIFO_VERTEX16, FIFO_TEX_COORD, FIFO_COLOR),
RGB15(31,31,31),
VERTEX_PACK(floattov16(0.2004603148),floattov16(0.125)), VERTEX_PACK(floattov16(-0.200460121),0),
TEXTURE_PACK(inttot16(16),inttot16(117)),
RGB15(31,31,31),




the first problem is in here :

Code:

FIFO_COMMAND_PACK(FIFO_COLOR, FIFO_VERTEX16, FIFO_TEX_COORD, FIFO_COLOR),
RGB15(31,31,31),
VERTEX_PACK(floattov16(0.2309698611),floattov16(0)), VERTEX_PACK(floattov16(-0.09567070752),0),
TEXTURE_PACK(inttot16(8),inttot16(128)),
RGB15(31,31,31),


it send 2 times the FIFO_COLOR with the same value RGB15(31,31,31).
when i change the color of it in the first part is works, but the second part doesn't do anything?

But i was thinking that this is just garbage to fill the chunks to make it 4 bytes??

Because later in the output i saw this :

Code:

FIFO_COMMAND_PACK(FIFO_COLOR, FIFO_VERTEX16, FIFO_TEX_COORD, FIFO_COLOR),
RGB15(31,31,31),
VERTEX_PACK(floattov16(0.2309698611),floattov16(0)), VERTEX_PACK(floattov16(-0.09567070752),0),
TEXTURE_PACK(inttot16(8),inttot16(128)),
RGB15(31,31,31),



FIFO_COMMAND_PACK(FIFO_VERTEX16, FIFO_TEX_COORD, FIFO_COLOR, FIFO_VERTEX16),
VERTEX_PACK(floattov16(0.176776737),floattov16(0)), VERTEX_PACK(floattov16(-0.1767765582),0),
TEXTURE_PACK(inttot16(0),inttot16(128)),
RGB15(31,31,31),
VERTEX_PACK(floattov16(0.2309698611),floattov16(0)), VERTEX_PACK(floattov16(-0.09567070752),0),


in the second part 2 times the FIFO_VERTEX16 was send, but in the last part of the second part there's this code :
Code:

VERTEX_PACK(floattov16(0.2309698611),floattov16(0)), VERTEX_PACK(floattov16(-0.09567070752),0),


its exactly the same as in the first part!

So i was really thinking that this is just to fill the fifo or something?

Am i right??



(sorry for my bad english, im dutch)

#108200 - Sausage Boy - Mon Nov 06, 2006 5:16 pm

Sounds like you're thinking of the display lists in chunks. Don't do that. Remove all the FIFO_COMMAND_PACK's in your brain, and think of it as a continuous stream of commands.
_________________
"no offense, but this is the gayest game ever"

#108205 - sajiimori - Mon Nov 06, 2006 6:55 pm

Right. Also, the exporter is setting the color several times, but since it's always white it could be set once at the beginning.

#108217 - chrissieboy - Mon Nov 06, 2006 8:26 pm

ok sausage boy! But i thought maybe the maya exporter fills the chunks with double data to fill 4 bytes? but that isn't the reason??

sajiimori this i why i thought the exporter fills the holes with double data??

#108218 - Sausage Boy - Mon Nov 06, 2006 8:28 pm

There are no holes, the "fill data" is just the data for the next verticles.
_________________
"no offense, but this is the gayest game ever"

#108223 - sajiimori - Mon Nov 06, 2006 9:33 pm

The extra color commands are just because the exporter doesn't optimize out color commands when they're the same as the previous one.

#108505 - ikaris - Thu Nov 09, 2006 6:15 pm

Hi chrissieboy,

I wrote the Maya exporter, and I'd be more than happy to answer any of your questions.

If you look at the source code of my exporter, you will find I added A LOT of comments... amongst them:

Code:


// To find size of the u32, calculate how many commands (i.e. VERTEX_PACK, FIFO_COMMAND_PACK, etc...)
// will be used.  This is calculated as follows:
// - Vertex positions are worth 2 (they use 2 VERTEX_PACK commands)
// - Vertex normals are worth 1 (they use one NORMAL_PACK command)
// - Vertex color are worth 1 (they use the single RGB15)
// - Texture coordinates are worth 1 (they use one TEXTURE_PACK), since we hold U and V data, divide by 2
// - The rendering style is worth 1 (such as GL_TRIANGLE)
// - The number of times FIFO_COMMAND_PACK is called, rounded up
//


If you look around that part of the file, you'll see the loop that builds the data... it might help you.

Hope this helps !