Archived

This topic is now archived and is closed to further replies.

Bounding Box Vertices

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

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[i].position.x;		
			if (pObjects[objectcount].pVertices[i].position.y < vMin.y) vMin.y = pObjects[objectcount].pVertices[i].position.y;		
			if (pObjects[objectcount].pVertices[i].position.z < vMin.z) vMin.z = pObjects[objectcount].pVertices[i].position.z;		
			if (pObjects[objectcount].pVertices[i].position.x > vMax.x) vMax.x = pObjects[objectcount].pVertices[i].position.x;		
			if (pObjects[objectcount].pVertices[i].position.y > vMax.y) vMax.y = pObjects[objectcount].pVertices[i].position.y;		
			if (pObjects[objectcount].pVertices[i].position.z > vMax.z) vMax.z = pObjects[objectcount].pVertices[i].position.z;
		}
 
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:
		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);
 
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites