Hey, Spellbound, (or anyone who can answer:))

Started by
1 comment, last by Esap1 24 years ago
Im using the same way of setting up Clipping Planes as they do in the ClipMirror Example in the DX7 SDK. Well, They have a helper function that takes 3 points to a triangle, I beleive, and creates a plane from the Triangle, and gives it to SetClipPlane(). Now, Because it Clips in 3D(right?), if I put the ClipPlanes on the sides of the portal(How exactly do I do that?), Would it look ok?. Thanks a lot for your Help. PS: Just for anyone who couldnt tell, Im trying to make a portal Engine
Advertisement
Well, how could I possibly ignore this question.

To use clipplanes to clip to the edges of the portal, you should use the camera position and the edge vertices on the portal to compute the plane.



To compute the plane do this:

VECTOR C; // Camera position
VECTOR E1; // Edge vertex 1
VECTOR E2; // Edge vertex 2

VECTOR N; // Plane normal
float d; // Planes distance from origo

N = Normalize(CrossProduct(E1-C, E2-C));
d = -DotProduct(C,N);

float Plane[4] = {N.x, N.y, N.z, d};
pD3DDev->SetClipPlane(PlaneIndex, Plane);



Remember that the plane normal should point into the visible frustum so you may need to swap the arguments to CrossProduct depending on the ordering of the vertices on you portal.

I hope you haven't forgotten my suggestion to let DirectX clip with the viewport edges instead of with clipplanes. The advantage of this is that the clipping equations are much easier, hence faster, and there are always only four clipplanes.

The are drawbacks with clipplanes; you can only have a maximum of 32 planes and they are slow. So you should try to minimize the amount of clipping performed during the rendering. My suggestion is that you only use clipplanes for the surfaces of mirrors and clipping portals (like those in Quake 3).


Edited by - Spellbound on 4/6/00 5:42:35 AM
Spellbound knows everything... he is a fountain of knowledge...

Programming::~Fredric(const Annoy_Ance)
3D Math- The type of mathematics that'll put hair on your chest!

This topic is closed to new replies.

Advertisement