Sign in to follow this  

Quads to a mesh...doesn't work, and a useful tip

This topic is 4843 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

Hiya. Thanks for reading this. This forum rocks. Before asking you to read my messy code I offer what may be a useful tip: The next time you have to search this site, instead of using the search link at the top, go to google search and type <search term> site:gamedev.net . Cool or what? OK. I have 500 quads (billboards) that I want to render as one big mesh. All of my functions return S_OK, and the code runs great...except that I don't see any of my billboards. TO spare you the gory details, I have: A Billboard class A Billboard::fvf which includes normals A texture A material Billboard trees[500]; I already have code that renders each billboard one at a time in a loop which works fine, so I know that everything is initializing ok, and I basically copied that code to initialize the vertex buffer for my single mesh, and am running the new code inside the same loop as the old code, so I know that the normals are set correctly, lighting is ok, etc.. So I've added: LPD3DXMESH pTreeMesh; D3DMATRIAL9 material; <create the textures> <init the material> hr=D3DXCreateMeshFVF( NUM_TREES, NUM_TREES*4, D3DXMESH_SOFTWAREPROCESSING, D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX1, g_Device, &pTreeMesh); BILLBOARDVERTEX* pTreeVB=NULL; hr=pTreeMesh->LockVertexBuffer(0, (LPVOID*)&pTreeVB); dwOffset = 0; for( iTree = 0; iTree < NUM_TREES; iTree++ ) { memcpy( &pTreeVB[dwOffset], m_pTrees[iTree].v, 4*sizeof(BILLBOARDVERTEX) ); m_pTrees[iTree].dwOffset = dwOffset; dwOffset += 4; } hr=pTreeMesh->UnlockVertexBuffer(); .............. Render(){ <set texture> <set material> for (int i=0; i<NUM_TREES; i++) pTreeMesh->DrawSubset(i); } Does anybody have any idea why this doesn't work? THANKS.

Share this post


Link to post
Share on other sites
How are you setting the billboard's geometry?
How bilboards are aligned with the camera?
Are you sure the billboards are not beeing back/front face culled?

Aren't you forgeting SetFVF and SetStreamSource calls before rendering?

Share this post


Link to post
Share on other sites
Thanks for the reply. Sorry to be so vague.

As I mentioned in my original post, I'm running this code alongside near identical code that properly renders each billboard seperately in a loop, using most of the same initialization code. Therefore, I know that the billboard geometry is init'd correctly, that the normals are all correct, that the billboards are always facing the camera, that SetFVF is correct, and that I am populating the vertex buffer correctly. This way I don't have to drag the good folks at gamedev through every minute detail of my code.

But...AHA...I may have forgotten to set SetStreamSource to the new vertex buffer. Doh! I'll have to look at this after work.

Bottom line, I'm not really sure that my method for doing this is "correct" at all, or if there is a better way to accomplish this task. Of course, MS's documentation is of little help.

THANKS AGAIN.

Share this post


Link to post
Share on other sites

This topic is 4843 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this