Jump to content
  • Advertisement
Sign in to follow this  
hawflakes

Problems with drawing meshes with bounding boxes

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

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 this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Supernat02
Does 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 this post


Link to post
Share on other sites
Quote:
Original post by LogicalError
and 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.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!