Jump to content
  • Advertisement
Sign in to follow this  
danromeo

Simply put...how do I combine a bunch of quads (billboards) into a single mesh?

This topic is 5055 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Just lock the vertex buffer, copy each vertex from the billboards into the buffer, then unlock it. It's just like filling 1 vertex buffer for 1 billboard, but now you fill 1 vertex buffer for more than one billboard. Everything must be in triangle lists, unless you want to use degenerate triangles, but then that gets complicated and is frankly a waste of time for the "possible" increase in speed you might get. Most cards like triangle lists now days (or so I've heard.) anyway. Any questions?

Chris

Share this post


Link to post
Share on other sites
Thanks Chris. You at least confirm that I'm barking up the right tree...however, it still doesn't work, and since you asked, I do have some questions on the DX mechanics of doing this.

Up til now all of my meshes were loaded from X files using D3DXLoadMeshFromX, or something like that, which takes as arguements the number of materials in the mesh and pointers to the materials and Texture buffers.

To combine my quads into a mesh I'm trying to use D3DXCreateMeshFVF, which doesn't take any arguements regarding materials or textures. So how do I associate the texture buffer with the mesh? I.e., to render the mesh with DrawSubset(attrib), how does the mesh know how many subsets to draw? Also, after creating the mesh, how would I load it?

Hope this makes sense. Thanks again.

Share this post


Link to post
Share on other sites
Maybe you should start to use vertex and index buffers directly instead of using the D3DX helper classes. They really aren't that complicated and give you way more control over what you are doing. Writing your own CMesh class shouldn't take that long.

Share this post


Link to post
Share on other sites
First, to load the mesh, you would lock the vertex buffer and fill it like any other vertex buffer, then unlock it.

Next, you need to fill the attribute table. It basically declares which vertices will be separate from others. The number of entries in the attribute table define the number of subsets. See the following example:


#define FVF (D3DFVF_XYZ)

ID3DXMesh *pMesh;

struct FVFStruct
{
D3DXVector3 Position;
}
FVFStruct *Data;
FVFStruct Vertices[30] {//Initialize to something}; // 10 triangles, 5 quads
D3DXATTRIBUTERANGE Attributes[5]; // 5 Attributes from 10 triangles, so 5 quads are using separate textures, render states, etc.

Attributes[0].AttribId = 0;
Attributes[0].FaceStart = 0;
Attributes[0].FaceCount = 1;
Attributes[0].VertexStart = 0;
Attributes[0].VertexCount = 3;

Attributes[1].AttribId = 1;
Attributes[1].FaceStart = 1;
Attributes[1].FaceCount = 1;
Attributes[1].VertexStart = 3;
Attributes[1].VertexCount = 3;

// repeat for all 5.

D3DXCreateMeshFVF(..., FVF, pDevice, &pMesh);
pMesh->LockVertexBuffer(D3DLOCK_NOOVERWRITE, (VOID*)&Data);
// Fill the 10 structures here, I'm skipping that part.
pMesh->UnlockVertexBuffer();
pMesh->SetAttributeTable(Attributes, 5/*Num Attributes*/);




Chris

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!