Jump to content
  • Advertisement
Sign in to follow this  
user88

Plane in view space

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

EDIT: I see my last post has a lot of text, and nobody want read it to understand the problem.

So, let me tell one more time:

I have the clipping planes (defined by A, B, C, D equitation of course) that i got from view frustum of the Camera. These planes are in world coordinates system. The point that i want to clip by these planes is in world-view coordinate space. So, i transform the plane in world-view coordinates system and find the distance of this point to planes. If the distance is negative i have to clip this point because it lays on negative side of the plane. In theory it have works but in practice i get unexpected results.. For more details see original text of my post below:

Hello,

i have the camera far clip plane i want to transform it in view space.

Let the plane be:
0 -1 0 7126.461

View matrix:

1 0 0 0
0 0.000976562 -0.9999995 0
0 0.9999995 0.000976562 0
-2000 1493.017 7151.461 1


After transformation* of the plane by matrix i get a result:
0 0 1 -25.0005

I don't understand why the D component of the plane is equal to -25.
If i take transformed separately normal of the plane and point on it i get expectable results. Look what i mean:

Normal of the plane:
0 -1 0
Transformed** normal of the plane:
0 0 1

Point on the plane:
0 -7126.461 0
Transformed*** point on the plane:
-2000 1493.017 14277.92

As i aspect the transformed plane and plane that created from transformed separately normal and point should be equal. Why not?

*

public static void Transform(ref Plane plane, ref Float4x4 temp, out Plane result)
{
float x = plane.Normal.X;
float y = plane.Normal.Y;
float z = plane.Normal.Z;
float d = plane.D;
Float4x4 transformation = Float4x4.Invert( temp );
Plane r;
r.Normal.X = (((x * transformation.M11) + (y * transformation.M12)) + (z * transformation.M13)) + (d * transformation.M14);
r.Normal.Y = (((x * transformation.M21) + (y * transformation.M22)) + (z * transformation.M23)) + (d * transformation.M24);
r.Normal.Z = (((x * transformation.M31) + (y * transformation.M32)) + (z * transformation.M33)) + (d * transformation.M34);
r.D = (((x * transformation.M41) + (y * transformation.M42)) + (z * transformation.M43)) + (d * transformation.M44);

result = r;
}


**

public static Float3 TransformCoordinate( Float3 coord, Float4x4 transform )
{
Float4 vector;
vector.X = (((coord.X * transform.M11) + (coord.Y * transform.M21)) + (coord.Z * transform.M31)) + transform.M41;
vector.Y = (((coord.X * transform.M12) + (coord.Y * transform.M22)) + (coord.Z * transform.M32)) + transform.M42;
vector.Z = (((coord.X * transform.M13) + (coord.Y * transform.M23)) + (coord.Z * transform.M33)) + transform.M43;
vector.W = 1 / ((((coord.X * transform.M14) + (coord.Y * transform.M24)) + (coord.Z * transform.M34)) + transform.M44);
return new Float3( vector.X * vector.W, vector.Y * vector.W, vector.Z * vector.W );
}


***

public static Float3 TransformNormal( Float3 normal, Float4x4 transform )
{
Float3 vector;
vector.X = ((normal.X * transform.M11) + (normal.Y * transform.M21)) + (normal.Z * transform.M31);
vector.Y = ((normal.X * transform.M12) + (normal.Y * transform.M22)) + (normal.Z * transform.M32);
vector.Z = ((normal.X * transform.M13) + (normal.Y * transform.M23)) + (normal.Z * transform.M33);
return vector;
}
[/quote] Edited by user88

Share this post


Link to post
Share on other sites
Advertisement
Your's plane transform function is wrong. Try to remove inverse and transpose operations from it. Edited by KriScg

Share this post


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

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!