Planes....

Started by
7 comments, last by steg 19 years, 6 months ago
Hi all, Ok, when loading a mesh using D3D, each tri in the mesh exists in its own plane. Now the plane equation is : Ax + Bx + Cy + D = 0 How do I represent a plane that represents a 'slice' of 3D space ? I'm confused at to what actually a plane is I think ! Kind regards, Steve

If it isn't working, take a bath, have a think and try again...

Advertisement
A plane is like a wall (without a certain "thickness") that goes on infinitely in any direction. A plane can be defined by just three points that it intersects. A helpful function for this would be D3DXPlaneFromPoints. Its first parameter is the actual plane, the second, third and fourth a the points it intersects.
For example, a frustum can be contructed from six planes: left, right, top and bottom plane, and the near and far clipping plane.
Thanks WanMaster,

I'm just confused as to where a plane would be used, I know we use them for frustum culling, but if I have say a 3d world such as ones like quake, I know they use planes to do their bsp stuff, how are these planes defined ?

If it isn't working, take a bath, have a think and try again...

I'm not sure I understand the question correctly.
Do you need to know how to construct the planes in a frustum?
Do you need to know how to use these planes to discard polygons in a scene?
Do you need to know anything that hasn't been covered by one of the above?

Hi WanMaster,

I'm just confused with planes! I can construct the frustum planes. How do you construct planes to discard polygons in a scene ( using bsp tree ) ? The space is partioned with 3d planes, how do you create these planes ?

If it isn't working, take a bath, have a think and try again...

bool inFrontOfPlane( Plane &plane, Point &point )
{
// Calculate
return (true or false);
}

This way you can discard vertices/polygons and whole objects too.
You can use D3DXPlaneDotCoord to test a point's position against a plane.
I'm not a BSP expert, but I'll tell you what I know.
A BSP is a binary tree that contains all the triangles in a scene. Every node in the tree holds a triangle (and its plane) and has two child nodes.
To build a BSP, you take a triangle, create the plane defined by the polygon (the plane that passes by every vertex of the triangle) and use this plane to partition the space in two parts. You usually split every triangle that crosses this plane, too, so that every remaining triangle can now be classified as "in front" of the plane, or "back" the plane.
Then you take another triangle and repeat the process, create a plane etc but thist time is only half of the space. You keep recursing and you will get all the space subdivided.
With a BSP you can easily reject large amounts of triangles. Say that you view frustum (the area you can see) is completely on the front side of the first triangle: you reject all the triangles on the back side, all AT ONCE because this is a tree structure and you just reject the "back-side" node of the first triangle.
Thanks all,

I take it then each polygon (triangle) has a plane. Say I have a triangle which obvioulsy has 3 vertices, we can call these a,b,c, now I want to generate a plane from this information :

N = b - a CrossProduct c - a will give me the normal for the plane

now normalize N and then find D

-n dotproduct a will give me D

Ax + By + Cz + D = 0

thus, Nx + Ny + Nz + D = 0

where x,y and z is any point that satisfies the above equation.

Don't know if I'm making any sense here at all ?!

Steve

If it isn't working, take a bath, have a think and try again...

This topic is closed to new replies.

Advertisement