[ODE] drawing a rotated plane?
Kevin Reid
kpreid at attglobal.net
Thu May 15 14:10:02 2003
> I rotated a plane.
> My question is, how could I draw this rotated plane. I'm using the
> drawstuff libary, and if I rotate a plane the plane is physically
> rotated, but is drawn as it has the normal vector (0,0,1) (my normal
> vector is somthing like (-0.2, 0, 0.8) and I want the plane to be drawn
> with this rotation.)
Here's the code I use (vp is defined elsewhere, and is the camera
origin):
dVector4 p;
dVector3 x, y, z;
// get plane equation
dGeomPlaneGetParams(geom, p);
// fill z with plane normal
z[0] = p[0]; z[1] = p[1]; z[2] = p[2];
dNormalize3(z);
// construct basis
dPlaneSpace(z, y, x);
{
// rotate to match plane's orientation
GLdouble glm[16] = {
x[0], x[1], x[2], 0,
y[0], y[1], y[2], 0,
z[0], z[1], z[2], 0,
0, 0, 0, 1,
};
glMultMatrixd(glm);
}
/* now translate so that 0,0,0 in the final space is as near as
possible to the viewer in xy, and matches the plane equation in z */
glTranslatef(
x[0] * vp[0] + x[1] * vp[1] + x[2] * vp[2],
y[0] * vp[0] + y[1] * vp[1] + y[2] * vp[2],
p[3]
);
--
Kevin Reid