Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Memblocks and Meshdata - whats the format for DBPro?

Author
Message
Daryn Alsup
16
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 11th Jul 2010 11:33 Edited at: 11th Jul 2010 11:38
Like the title says lol, I know the format for making objects in DBC but not for pro - and I know they're different from one another... but not how.

EDIT
I should have said that I have never made an object using memblocks - but I would like some help learning. No code is desired or anything just understanding. Thanks again

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 11th Jul 2010 13:46
I think the DBP help files are pretty clear on this one:

Quote: "The specified values must be integer values and the source resource must exist or the command will fail. The mesh memblock is layed out in the following format. The first DWORD is the FVF Format, which controls which components each vertex of your mesh will contain. The default FVF Format is 338. The second DWORD is the FVF Size, which is the size in bytes of a single vertex element. This size is respective of the FVF Format you specified, which has a default of 36. The third DWORD is the number of Vertices in your mesh. The remainder of the memblock contains mesh data. The mesh data is a sequential list of vertices, containing the component data arranged as specified by the FVF Format. The default FVF Format would specify the following arrangement of data within the vertex element, which is duplicated for every vertex specified in the memblock. Each grouping of three vertices makes a polygon. Given the default FVF Format of 338, the first three FLOAT values (12 bytes) of the vertex element would be the XYZ coordinates in model space. The second three FLOAT values (12 bytes) of the vertex element would be the normals coordinates in model space. The next DWORD is a diffuse colour component that specifies the colour of the vertex. The last two FLOATS are UV texture coordinates for the vertex. This adds up to 36 bytes which is the size of a single vertex. Multiply 36 by the number of vertices in the mesh and you get the overall size of the mesh data. "


Cheers!
Sven B

Daryn Alsup
16
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 11th Jul 2010 14:09
Lmao - well yes, that they are - but I am not really familiar with FVF formats, Normals and UV or UVW via the memblock commands. (I know what they do - but how do I place them correctly or I'll do you one better - how can I UNDERSTAND how to place them.) So I was really looking for - oh say and example of a simple plane with no cross sections changed into(or created from scratch and deleting the old one) a plane with four cross sections. Not really the code - but the/a method used for normals and Uv/UVW so that they're properly placed.

Also - I notice that all dbpro objects have a default value for FVF format that is - of 274, not 338 - is that my machine alone or is this just a help file mistake or something?

-Daryn.

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 11th Jul 2010 16:52
Quote: "Also - I notice that all dbpro objects have a default value for FVF format that is - of 274, not 338 - is that my machine alone or is this just a help file mistake or something?"


It's possible. If I'm not mistaking then the vertices of those objects don't have a diffuse color.

There's not much to know about those things though.
X, Y, Z is the position of the vertex in the object.
normal coordinates NX, NY, NZ have to do with lighting. It is a normalized vector (= length 1.0) that represents the direction where the light has to be for maximum light reflection. If the light is placed on the exact other side than the direction of the normal, then the vertex will be dark.
For a plain, this normal is usually perpendicular to the faces. It is also the reason why the front side of a plain is bright, while the back side is dark.
U,V are floats between 0.0 and 1.0. (0,0) represents the upper left corner of the texture image, while (1,1) represents the bottom right corner of the texture image. (0.5, 0.5) is the middle of the texture image.
Diffuse color is basically the color of the vertex.

Cheers!
Sven B

Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 12th Jul 2010 07:19 Edited at: 12th Jul 2010 07:19
Sven B is right. Vertices with an FVF of 274 don't have a diffuse color. However, 274 is now the default FVF. It was changed a while ago and the help files weren't updated to reflect it.

From my own research, the FVF tag is a collection of flags (each bit of the tag is a different flag). It seems that only the first two bytes are used, but here's my best guess at the meanings of each flag:



Using the "table" above, we can see that 274 is:

which means that each vertex contains its position in model space, its normal, and it's UV coordinates for the first texture stage.

Also, 338 is:

which is exactly the same, but includes a diffuse color, just like the help file says.

Anyway, you just need to put the data into the memblock end to end, in the order that they appear in the FVF tag. So, using 274, write three floats to the memblock for the X, Y, and Z coordinates, followed by another three floats for the X, Y, and Z components of the vertex normal, and finally, another two floats for the U and V coordinates of the first texture stage.

Does that help?

Login to post a reply

Server time is: 2024-11-24 14:25:11
Your offset time is: 2024-11-24 14:25:11