Page 1 of 1

mathematical plane rotation

Posted: Mon Aug 10, 2009 9:59 pm
by yavorpap
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.

Posted: Mon Aug 10, 2009 10:05 pm
by hybrid
There's a plane constructor which uses exactly these 4 values :D

Posted: Mon Aug 10, 2009 10:12 pm
by yavorpap
Much thanks. I only have one other question: how can I draw it on the screen - the ISceneManager class does not seem to have any function to suit this need (or I just don't know ho to do it...)

Posted: Mon Aug 10, 2009 10:34 pm
by hybrid
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.

Posted: Mon Aug 10, 2009 11:25 pm
by yavorpap
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);

Posted: Mon Aug 10, 2009 11:55 pm
by hybrid
I think you should use (0,1,0) as the from parameter, because that's the default orientation of the hillplane.

Posted: Tue Aug 11, 2009 12:06 am
by yavorpap
Thank you very much, that fixes it :) . I had forgotten that the horizontal plane is OXZ, not OXY.

Posted: Tue Aug 11, 2009 12:51 am
by yavorpap
Sorry that I'm bothering again, but there's another issue with the plane. Some of the spheres on the picture are supposed to be intersected by the plane (the big white thing) since their centres are on that plane, but they aren't. Any ideas?
Image

Posted: Tue Aug 11, 2009 7:16 am
by hybrid
Hmm, the perspective is pretty hard to get. Maybe the plane is just oo small?

missing scenemgr->addPlane ()

Posted: Sat Aug 15, 2009 5:58 pm
by koscianski
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.