Bounding Box Vertices

Started by
1 comment, last by webjeff 19 years, 11 months ago
OK, I got a bounding box by doing this:

		vMin.x = pObjects[objectcount].pVertices[0].position.x;
		vMin.y = pObjects[objectcount].pVertices[0].position.y;
		vMin.z = pObjects[objectcount].pVertices[0].position.z;
		//Back-right-top.
		vMax.x = pObjects[objectcount].pVertices[0].position.x;
		vMax.y = pObjects[objectcount].pVertices[0].position.y;
		vMax.z = pObjects[objectcount].pVertices[0].position.z;
		for (int i = 0; i < pObjects[objectcount].m_dwNumOfVertices; i++)
		{		
			if (pObjects[objectcount].pVertices.position.x < vMin.x) vMin.x = pObjects[objectcount].pVertices.position.x;		
			if (pObjects[objectcount].pVertices.position.y < vMin.y) vMin.y = pObjects[objectcount].pVertices.position.y;		
			if (pObjects[objectcount].pVertices.position.z < vMin.z) vMin.z = pObjects[objectcount].pVertices.position.z;		
			if (pObjects[objectcount].pVertices.position.x > vMax.x) vMax.x = pObjects[objectcount].pVertices.position.x;		
			if (pObjects[objectcount].pVertices.position.y > vMax.y) vMax.y = pObjects[objectcount].pVertices.position.y;		
			if (pObjects[objectcount].pVertices.position.z > vMax.z) vMax.z = pObjects[objectcount].pVertices.position.z;
		}
 </pre> 

However,  I am trying to render it with a wire box around in red color.  Duh, this is simple, eh wrong.  I am drawing a blank guys.  

I do this for rendering:
<pre>
		m_pd3dDevice->SetStreamSource( 0, buf[objectcount], sizeof(BOXVERTEX) );
		m_pd3dDevice->SetIndices(m_pIndexBuffer2,NULL);
		m_pd3dDevice->SetVertexShader( MESH_BOX_CUSTOMVERTEX );
		//m_pd3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME); 

		m_pd3dDevice->SetTexture(0, NULL);
			//Set material default values (R, G, B, A)
		D3DCOLORVALUE rgbaDiffuse1  = {1.0, 1.0, 1.0, 0.0,};
		D3DCOLORVALUE rgbaAmbient1  = {1.0, 0.0, 0.0, 0.0,};
		D3DCOLORVALUE rgbaSpecular1 = {0.0, 0.0, 0.0, 0.0,};
		D3DCOLORVALUE rgbaEmissive1 = {0.0, 0.0, 0.0, 0.0,};
	
		SetMaterial(rgbaDiffuse1, rgbaAmbient1, rgbaSpecular1, rgbaEmissive1, 0);

		m_pd3dDevice->SetMaterial(&m_matMaterial);
		m_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 8, 0, 12);
		m_pd3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
 </pre> 

When I do wireframe I get the box outline fine good, but its white, I can''t change it to red, when I dont do wireframe I get nothing on the screen… like its gone.  How do I color the vertices!!! this can''t be that hard.

Any help?  </i>  
Advertisement
What are your texture stage states ? You will probably need D3DTOP_SELECTARG1 for the operation (default is D3DTOP_MODULATE) and D3DTA_CURRENT or D3DTA_DIFFUSE for the argument (default is D3DTA_TEXTURE).
Also if lighting is turned off it will not use the material but the vertex color, which defaults to white if it isn''t set.
the outline is white because you''re constructing the box of a material with a white diffuse color.

---------------------------Hello, and Welcome to some arbitrary temporal location in the space-time continuum.

This topic is closed to new replies.

Advertisement