mathematical plane rotation

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
yavorpap
Posts: 5
Joined: Mon Aug 10, 2009 9:56 pm

mathematical plane rotation

Post 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.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

There's a plane constructor which uses exactly these 4 values :D
yavorpap
Posts: 5
Joined: Mon Aug 10, 2009 9:56 pm

Post 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...)
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
yavorpap
Posts: 5
Joined: Mon Aug 10, 2009 9:56 pm

Post 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);
Last edited by yavorpap on Tue Aug 11, 2009 12:37 am, edited 1 time in total.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I think you should use (0,1,0) as the from parameter, because that's the default orientation of the hillplane.
yavorpap
Posts: 5
Joined: Mon Aug 10, 2009 9:56 pm

Post by yavorpap »

Thank you very much, that fixes it :) . I had forgotten that the horizontal plane is OXZ, not OXY.
yavorpap
Posts: 5
Joined: Mon Aug 10, 2009 9:56 pm

Post 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
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Hmm, the perspective is pretty hard to get. Maybe the plane is just oo small?
koscianski
Posts: 5
Joined: Thu Aug 13, 2009 12:35 am
Location: Brazil
Contact:

missing scenemgr->addPlane ()

Post 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.
Post Reply