Oh Boy - that's a loaded Question. You have to understand FVF Direct X formats (I'm still learning), you set up a memory block with e DirectX "Mesh Header" and then depending on the FVF format - (determines what data is stored per vertex, like XYZ, NormalsXYZ, UVs? UV's for two textures? 3? up to 8 I think) and then you plow all the data into the memblock, and then create object from memblock.
Pseudo Explaination I saw in another post I saved cuz it was more helpful than a code snippet - as I understood the process - I was able to write it myself!
Quote: "
My knowledge of how to do this is a bit limited, but I'll share with you what I know. This is how you make an FVF 338 memblock mesh. I'm sorry if this is a bit pedestrian, but I don't want to make any assumptions about what anyone who reads this knows.
1. Decide how many tiles you want your mesh to be. When I tried making a mesh larger than 100 x 100, I got some sort of memory error message. I don't know if my system doesn't have enough memory or if there is some limitation, or what. I just use multiple meshes if I need more than 100 x 100 tiles.
2. Determine the number of tiles by multiplying the number of tiles in the X dimension by the number of tiles in the Z dimension.
3. Determine the number of polys by multiplying the number of tiles by 2.
4. Determine the number of vertices by multiplying the number of polys by 3.
5. Determine the memblock size by multiplying the number of vertices by 36 and then adding 12 for header information.
6. Make a memblock of the size determined in step 5.
7. Write the header info as shown:
write memblock dword MemBlockNumber, 0, 338
write memblock dword MemBlockNumber, 4, 36
write memblock dword MemBlockNumber, 8, Number of Vertices
338 is the Flexible Vertex Format of the mesh we're making. 36 is the number of bytes per vertex (more on that later). Number of vertices was determined in step 4.
8. Establish a memory variable for the current memblock byte (MemoryPosition) and initialize the value to 12 - the first byte after the header info.
9. Do a FOR/NEXT loop which will write the following information for each vertex:
write memblock float MemBlockNumber, MemoryPosition, X Position
write memblock float MemBlockNumber, MemoryPosition, Y Position
write memblock float MemBlockNumber, MemoryPosition, Z Position
write memblock float MemBlockNumber, MemoryPosition, X Normal
write memblock float MemBlockNumber, MemoryPosition, Y Normal
write memblock float MemBlockNumber, MemoryPosition, Z Normal
write memblock dword MemBlockNumber, MemoryPosition, Grid Color
write memblock float MemBlockNumber, MemoryPosition, U Coordinate
write memblock float MemBlockNumber, MemoryPosition, V Coordinate
IMPORTANT NOTE: Increment the MemoryPosition variable by 4 after each value is written to the memblock.
The number of iterations of the loop is from 1 to the number of vertices.
The number 36 that has been used before comes from the 9 pieces of information listed times the 4 bytes that each float or dword needs.
10. Make a mesh from the memblock
MAKE MESH FROM MEMBLOCK MeshNumber, MemBlockNumber
11. Make an object from the mesh
MAKE OBJECT FROM MESH MeshNumber, ObjectNumber
Now, like you, I don't know the data layouts for the various FVF formats. But there have been times when I needed FVF 530 meshes which hold two sets of UV data. This is what I do for that:
1. Make an FVF 338 mesh as described above.
2. Convert the mesh to FVF 530:
CONVERT OBJECT FVF ObjectNumber, 530
3. Lock the vertex data.
4. Do a FOR/NEXT loop with the following command:
SET VERTEXDATA UV VertexNumber, TextureStage, U, V
The number of iterations is, once again, the number of vertices.
5. Unlock the vertex data.
Now, getting a second set of UV coordinates may not be what you need. My point is that I got that second set of UV coordinates without knowing the structure of the data for an FVF 530 mesh.
I hope this helps you out.
"
Welded Verts:
http://www.thegamecreators.com/?m=codebase_view_code&i=4101d5e4795d262e21c510c47b80ca2e