mathematical plane rotation
mathematical plane rotation
Hi, I have to draw a plane in IrrLicht, the problem is that the plane is defined with its analytical components: a,b,c,d in the equation a*x+b*y+c*z+d=0. My question is how exactly can you do this in IrrLicht. I guess the obvious choice is to create a flat plane and rotate it, but I don't know how. Any help is appreciated.
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Yeah, I guess you have to use a hillplane mesh and do the rotation on your own. The easiest way is probably via quaternions. Use rotationFromTo of the quaternion class, get the matrix from the quaternion, and setTranslation to d. By transforming the plane with this matrix you should get the proper plane. You can also setRotation and setPosition of the meshnode you add the basic hillPlaneMesh, depends on what you want to do with the plane.
Here is what I did, but I guess I made a mistake somewhere, because the plane does not intersect some spheres which represent points which should lie on that plane. a, b and c are the coefficients in the equation a*x+b*y+c*z+d=0. In this case d=0.
Code: Select all
core::vector3df l(0,1.0f,0),p(a,b,c);
core::quaternion Qt;
core::quaternion Rot = Qt.rotationFromTo(l,p);
core::vector3df RVec = Rot.getMatrix().getRotationDegrees();
camera->setFarValue(20000.0f);
scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode(
"../media/terrain-heightmap2.bmp",
0, // parent node
-1, // node id
core::vector3df(0.f, 0.f, 0.f), // position
core::vector3df(0.f,0.f,0.f), // rotation
core::vector3df(1.0f, 1.0f, 1.0f),
video::SColor ( 255, 255, 255, 255 ), // vertexColor
5, // maxLOD
scene::ETPS_17, // patchSize
4 // smoothFactor
);
terrain->setRotation(RVec);
Last edited by yavorpap on Tue Aug 11, 2009 12:37 am, edited 1 time in total.
-
- Posts: 5
- Joined: Thu Aug 13, 2009 12:35 am
- Location: Brazil
- Contact:
missing scenemgr->addPlane ()
Sorry for the silly question. Here it goes.
I need to create a plan, too, but got puzzled by this topic. A billboard does not work 4 me, as it faces the camera all the time.
There is irr::core::plane3D, but I did not found a corresponding mesh-generator-thing in the API. For instance, there's no "addPlane" similar to addCube or addSphere. No addCylinder, but there is addArrow. So strange, since CGeometryCreator have everything ready, but is not accessible.
I thought of these alternatives:
1) model a plane in Blender and load it in Irrlicht (sounds weird, too much work for such a simple thing)
2) scenemgr->addCube, scaled as (x, y, 0.01) and texturized. But this burns fuel for nothing, as I need the texture to get printed only on one face.
3) use the code found in this topic. But.. by playing with addTerrainSceneNode I got (the correct) crazy results, I mean, irregular terrain.
4) use "addTerrainMesh", with a constant-height map. Once again, overcomplicated.
5) addHillPlaneMesh with 1x1 tile, followed by addAnimatedMeshSceneNode.
BTW, thank you so much for your work, guys. I'm moving from DarkGDK to Irrlicht, in order to implement the projects of our study group.
I need to create a plan, too, but got puzzled by this topic. A billboard does not work 4 me, as it faces the camera all the time.
There is irr::core::plane3D, but I did not found a corresponding mesh-generator-thing in the API. For instance, there's no "addPlane" similar to addCube or addSphere. No addCylinder, but there is addArrow. So strange, since CGeometryCreator have everything ready, but is not accessible.
I thought of these alternatives:
1) model a plane in Blender and load it in Irrlicht (sounds weird, too much work for such a simple thing)
2) scenemgr->addCube, scaled as (x, y, 0.01) and texturized. But this burns fuel for nothing, as I need the texture to get printed only on one face.
3) use the code found in this topic. But.. by playing with addTerrainSceneNode I got (the correct) crazy results, I mean, irregular terrain.
4) use "addTerrainMesh", with a constant-height map. Once again, overcomplicated.
5) addHillPlaneMesh with 1x1 tile, followed by addAnimatedMeshSceneNode.
BTW, thank you so much for your work, guys. I'm moving from DarkGDK to Irrlicht, in order to implement the projects of our study group.