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.

Code Snippets / (Beginners : Mesh Memblock) Creating a 3D Triangle

Author
Message
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 18th Oct 2005 04:53
Well the topic says it all really.





Vues3d on Kalimee
20
Years of Service
User Offline
Joined: 12th May 2004
Location: NYON (SWITZERLAND)
Posted: 18th Oct 2005 17:27
Hi Raven!!
Really thanx for this....
Maybe now I will have mor practice with this mysterious thing that are Memblocks.
As I never be able to understand how they works, here could be the beginn..
So, I hope you don't mind if I ask some (many) questions on your code.

- What's the exact meaning of this:

I mean... what the signification of "|" in the line?

- VertexSize = 12 + 4 + 0 do this means that the object will be a triangle??

As I've seens, dword & float are both 4 byte length, so when use dword & when float?

Really sorry, but I'm completely Noob with Memblocks....

Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 18th Oct 2005 18:14
"||" mean Bitwise OR

Say you have 2 Variables, like 128 (0x80) and 10 (0x0A)
What Bitwise would do is change them at the binary level.

Bitwise OR works to these rules:

0 + 1 = 1
1 + 0 = 1
0 + 0 = 0
1 + 1 = 1

So if we change these values to binary


Basically we've just added the values together, but doing it at the binary level means that we can use this for more than just getting a final number.

If we used each of the binary values individually for an 8 bit value like we use above, you get 8 Yes / No (On / Off) flags.

So say you were creating a level format, and it was made entirely of cubes. You could have a flag for each face, to know if it was Active (if so then can render it) or in active.

The way we would find out if a flag is active is just as simple as adding them.

For example:



Just to proove it works, uncomment the AttachedToPole in Flag.
This is because Bitwise AND (&&) works identically to OR, only using 0 instead.

Bitwise or works to these rules:

0 + 1 = 0
1 + 0 = 0
0 + 0 = 0
1 + 1 = 1



Quote: "- VertexSize = 12 + 4 + 0 do this means that the object will be a triangle??"


No, this is simply the size of the Vertex Data.

FVF_XYZ_SIZE = 12
` Type Vector3 X,Y,Z As Float EndType / 3x 4Byte Float .. so 12 Bytes

FVF_DIFFUSE_SIZE = 4
` Dword 32-bit Colour is 4Byte

FVF_TEX0_SIZE = 0
` As this means No Texture Coordinate this has no size. Tex1 is the normal one which is Type Vector2 U,V As Float EndType / 2x 4Byte Float... so 8 Bytes

VertexSize = FVF_XYZ_SIZE + FVF_DIFFUSE_SIZE + FVF_TEX0_SIZE

As for the data sizes, yes all data is 4 Byte as it is all either a 32-bit Dword or 32-bit Float.

You use each in relation to what your copying at the time.

XYZ = Vertex Position, 3x Float, Order = X, Y, Z
NORMAL = Normal Position, 3x Float, Order = X, Y, Z
DIFFUSE = Colour, 4x Byte, Order = Red, Green, Blue, Alpha (Generally you use the RGB( ) command and you'll be alright)
SPECULAR = Same as above, only DIFFUSE Colours, this one highlights. I used to affectionately called it "Spectacular Colour" heh
TEX1 - 8 = Texture Coordinates, the number relates to the number of Coordinate Stages/Sets. Each Stage/Set uses this setup:
2x Float, Order = U, V
So for 8 Stages, you would have 8 individual Coordinate Sets as above.

There are a few more aspects to the format but honestly you won't needs them; given they're not really supported yet.

Hopefully that clears some things up.

Login to post a reply

Server time is: 2024-11-27 03:04:27
Your offset time is: 2024-11-27 03:04:27