# Problems with drawing meshes with bounding boxes

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

## Recommended Posts

I've been working on this Checkers game for a long time, and I had it at one point where it drew a full 3D checkerboard with all the pieces lined up. Then I tried to implement bounding boxes, things went haywire, and by the time I got my code fixed the pieces weren't being drawn anymore. After toying with this code for several hours and getting nowhere I'd like to request your help! Here is the most relevant code: To draw the mesh:
bool XFile::Display(float X, float Y, float Z)
{
D3DXMatrixTranslation(&Location, X, Y, Z);
pDevice->SetTransform(D3DTS_WORLD, &Location);
Mesh->DrawSubset(0);

for(int i = 0; i < Mtrls.size(); i++)
{
pDevice->SetMaterial( &Mtrls );
pDevice->SetTexture(0, Textures);
Mesh->DrawSubset(i);
}
// Render the bounding sphere with alpha blending so we can see
// through it.
pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

D3DMATERIAL9 yellow = d3d::YELLOW_MTRL;
yellow.Diffuse.a = 0.55f; // 25% opacity
pDevice->SetMaterial(&yellow);
Sphere->DrawSubset(0);

pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, false);

return true;
}

If the problem isn't apparent from here, I can post the rest (it's a good deal of code) Thanks!

##### Share on other sites
Does it work if you don't do the last DrawSubset call(the one where you draw the bounding box)?

Chris

##### Share on other sites
Quote:
 Original post by Supernat02Does it work if you don't do the last DrawSubset call(the one where you draw the bounding box)?Chris

Nope. have a feeling the first DrawSubset(0) is a mistake. Still, I removed that, and the code for drawing the bounding sphere (I'm used to saying box, sorry) and nothing is drawn at all.

##### Share on other sites
and this is the only function you changed?
are you sure it's not drawn?
maybe everything has the color black or something..

##### Share on other sites
Quote:
 Original post by LogicalErrorand this is the only function you changed?are you sure it's not drawn?maybe everything has the color black or something..

Well, I changed other stuff too, I changed a lot of things trying to get the bounding spheres to work. I salavaged this code from a hard disk crash and it's been all summer since I looked at it. That's why I'm kinda in a pickle right now. The bounding spheres are working but my meshes aren't being drawn. I suppose what I'll try next is loading a different, more reliable X file (a spaceship) rather than the ones I've been using.

1. 1
2. 2
frob
15
3. 3
4. 4
5. 5

• 20
• 11
• 13
• 14
• 78
• ### Forum Statistics

• Total Topics
632142
• Total Posts
3004393

×