Advertisement Jump to content
Sign in to follow this  
dyerseve

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.

If you intended to correct an error in the post then please contact us.

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]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!