# calculating clip planes from matrices

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

## Recommended Posts

Does anyone see a problem with this? I'm suspecting maybe plain matrix4*vector4 multiplication doesn't transform planes correctly.
Vector4 p[6];
Matrix4 matWorld;
Matrix4 matView;
Matrix4 matProj;
Matrix4 z;
pDevice->GetTransform(D3DTS_WORLD,(struct D3DXMATRIX *)&matWorld);
pDevice->GetTransform(D3DTS_VIEW,(struct D3DXMATRIX *)&matView);
pDevice->GetTransform(D3DTS_PROJECTION,(struct D3DXMATRIX *)&matProj);
z=matWorld*matView*matProj;
z.Invert();
//Plane equation: ax+by+cz+d>0
p[0]=z.Transform(Vector4(0.0f,0.0f,1.0f,0.0f)); 	//Front:	z>0
p[1]=z.Transform(Vector4(0.0f,0.0f,-1.0f,1.0f)); 	//Back:		z<1
p[2]=z.Transform(Vector4(1.0f,0.0f,0.0f,1.0f)); 	//Left:		x>-1
p[3]=z.Transform(Vector4(-1.0f,0.0f,0.0f,1.0f)); 	//Right:	x<1
p[4]=z.Transform(Vector4(0.0f,-1.0f,0.0f,1.0f)); 	//Top:		y<1
p[5]=z.Transform(Vector4(0.0f,1.0f,0.0f,1.0f)); 	//Bottom:	y>-1
[/SOURCE]

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 13
• 9
• 15
• 14
• 46
• ### Forum Statistics

• Total Topics
634058
• Total Posts
3015288
×