Hermandroid
Hermandroid

Reputation: 2200

Parallel plane in openGL

I'm working with OpenGL, I need to draw a plane in front of a triangle in the three dimensional space. So if one of the triangle points changes, the plane also changes

I have the 3 points, and using cross product, I can get the normal vector, so, to draw the plane, I only need to translate the triangle to the origin of the world in reference of one of the triangle points, translate a distance over the normal, rotate the normal angles in X, Y and Z, and draw the plane.

I need to know how to translate over the normal, and how to rotate the new plane, so, when one of the vertex changes, the normal changes, and the plane also changes.

As I understand, I can use the normal vector in glRotatef(angle, normal[x, y, z]), with angle =0. But the plane doesn't change when I change one of the triangle vertex.

Upvotes: 0

Views: 470

Answers (1)

NickLH
NickLH

Reputation: 2645

OpenGl is not a scene graph. It will not deal with transforming objects for you. All OpenGL does is render what you tell it to render.

If you tell it to render a vertex (which YOU changed), and do not tell it to change the way it draws the plane, then of course the plane will not change.

Look into scene graphs, and how to do matrix and vector math. A simple scene graph is relatively easy to create.

Upvotes: 2

Related Questions