I have two objects: cube and triangle:
My triangle points is changed by some function (some points moved by Y coordinates)
After points moved I need to change rotation matrix for cube.
Cube can be always parellel to triangle.
How to rotate object parallel to triangle?
How to rotate object parallel to triangle?
Last edited by Magnet on Mon Nov 27, 2006 11:57 am, edited 1 time in total.
This is impossible!
I have triangle3df.
I need to calculate vectors Rotation and Translation for node for make cube paralel to triangle.
I have triangle3df.
Code: Select all
ISceneNode node=smgr->addCubeSceneNode();
triangle3df tri = GetAssignedTriangle();
//node->setRotation(...);
//node->setTranslation(...);
Sorry! I was being a bit silly but then you didn't say that either hehe! You'll have to use the triangle's normal some how, though i'm sure you knew that already. Not quite sure how you'd go about that though i was doing something similar with one of my projects by having my character stand with their back to a wall.
Thnx for all.
I am realize this task!
Part of source code:
I am realize this task!
Part of source code:
Code: Select all
//calculate normal of triangle
vector3df normal1 = (tri.pointB-tri.pointA).crossProduct(tri.pointC-tri.pointB).normalize()*10;
driver->draw3DLine(tri.pointA, tri.pointA+normal1);
driver->draw3DLine(tri.pointB, tri.pointB+normal1);
driver->draw3DLine(tri.pointC, tri.pointC+normal1);
//calculate normal for buttom plain of cube
aabbox3d<float> bbox = cube->getBoundingBox();
cube->getAbsoluteTransformation().transformBox(bbox);
vector3df A = bbox.MinEdge;
vector3df B = bbox.MaxEdge;
vector3df C = bbox.MinEdge;
B.Y = A.Y;
C.X = B.X;
vector3df normal2 = (B-A).crossProduct(C-B).normalize()*10;
vector3df angle = normal2.crossProduct(normal1);
cube->setRotation(angle);
cube->setPosition(intersection);