You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers. No questions about C++ programming or topics which are answered in the tutorials!
I'm trying to find three points so I can create a plane out of them. My origin point is the position of a node (location1), and I want the plane to be aligned with direction the node is facing. So if the node is rolled sideways or facing up or down, the plane will go up and down. if the node is just evened off with no rotation, the plane will be horizontal, etc.
I tried to find the other points with something like this, but I can't get it to work right:
A plane is described by a point which is the distance from the origin and a normal. So for a horizontal plane which the node is on, you would use the nodes absolute position and the normal ( 0, 1, 0 ).
Last edited by Spintz on Sun Mar 04, 2007 2:38 pm, edited 1 time in total.
Spintz wrote:A plane is described by a point which is the distance from the origin and a normal. So for a horizontal plane which the node is on, you would use the nodes absolute position and the normal ( 0, 1, 0 ).
I'm not trying to make a horizontal plane... the plane is horizontal relatively to the node, but absolutely it will change depending on the rotation of the node.
i suppose I COULD do it by parenting 2 empty nodes to that node and make sure the relative Y for both of those are 0. then i can use the absolute positions of those two nodes as my points, but surely there's a quick matrix calculation I could use instead.
Spintz told you exactly what you needed to know, you just probably don't know enough to help yourself with that information.
He told you a plane is a point which is the distance from the origin and a normal. The point is actually a point in the plane. Just for giggles, say that the 'point' is the absolute position of the node. Now all you need to do is calculate the normal for the plane. You want the plane normal to be related to the orientation of the node. Well, the node has a rotation matrix. You can apply that rotation matrix to a vector, and that will get you a vector that is oriented relative to the node...
core::vector3df up(0, 1, 0); // this points up in world space
// transform up from world space to node space
node->getAbsoluteTransformation().rotateVect(up);
// now up points 'up' wrt node. if node is rotated so it is facing down,
// the up vector will be pointing forward in world space
Given that, you should see what you need to do to create a plane.
Glad that works for you. It's just a little slower to do that, then to simply get the rotation of the node and rotate the (0,1,0) normal vector based on that rotation and then call -