Sign in to follow this  

Problems with drawing meshes with bounding boxes

This topic is 4858 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[i] );
		pDevice->SetTexture(0, Textures[i]);
		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
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

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