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]
calculating clip planes from matrices
Does anyone see a problem with this? I'm suspecting maybe plain matrix4*vector4 multiplication doesn't transform planes correctly.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement