assigning a plane

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.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

assigning a plane

Post by bitplane »

i want to set a plane3d equal to an edge of a bounding box, but planes only have a position and a normal.
are they infinite length or am I missing something?
VeneX
Posts: 228
Joined: Sun Nov 30, 2003 3:32 pm
Location: The Netherlands
Contact:

Post by VeneX »

yeah what exactly is a plane3d, I thougth it could be used for the rotation of an triangle: core::plane3d<f32> rotation = triangle.getPlane();
If I am right I might have done good by tying: bullethole->setRotation(rotation); to set the flat model on the triangle with the same rotation, but now I have an error: cant convert from plane3d to vector3df.

If I use the right function: how to solve this convertion,
and if I don't: what function should I use than?
Visit my website @ www.venex.be
Plethora project will be added to the site
AMD AthlonXP 2600+, 512MB DDR, Radeon M10 (mobile 9600) PRO 64MB, WinXP
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

apparently planes are mathematical planes, they have no length/width, just position vector and a normal.
I'd guess you go like setRotation( rotation.Normal );
VeneX
Posts: 228
Joined: Sun Nov 30, 2003 3:32 pm
Location: The Netherlands
Contact:

Post by VeneX »

strangely all the models get set to one same direction, unless the triangle faces point into another direction

Code: Select all

if (sm->getSceneCollisionManager()->getCollisionPoint(
		line, metaSelector, end, triangle))
     core::plane3d<f32> rotation = triangle.getPlane();


selectedSceneNode = sm->getSceneCollisionManager()->
	          getSceneNodeFromCameraBB(sm->getActiveCamera());

if (selectedSceneNode == doos)
{
mesh = sm->getMesh("hole.ms3d");
				bullethole = sm->addAnimatedMeshSceneNode(mesh);
				bullethole->setMaterialTexture(0, device->getVideoDriver()->getTexture("hole.jpg"));
				bullethole->setMaterialFlag(video::EMF_LIGHTING, false);
				bullethole->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
				bullethole->setPosition(Impacts[i].pos);
				//bullethole->setRotation(sm->getActiveCamera()->getRotation());
				bullethole->setRotation(rotation.Normal);}
The function to make only the 'bullethole' on the node 'doos' doesn't work that great either :?
Visit my website @ www.venex.be
Plethora project will be added to the site
AMD AthlonXP 2600+, 512MB DDR, Radeon M10 (mobile 9600) PRO 64MB, WinXP
VeneX
Posts: 228
Joined: Sun Nov 30, 2003 3:32 pm
Location: The Netherlands
Contact:

Post by VeneX »

can't figure out :? :(
but the selectednode for 'doos' doesn't work because he checks the camera when the 'bullet' hits the wall
Visit my website @ www.venex.be
Plethora project will be added to the site
AMD AthlonXP 2600+, 512MB DDR, Radeon M10 (mobile 9600) PRO 64MB, WinXP
VeneX
Posts: 228
Joined: Sun Nov 30, 2003 3:32 pm
Location: The Netherlands
Contact:

Post by VeneX »

I made it a:

Code: Select all

core::vector3df rotation;
core::vector3df out = triangle.getNormal();
		imp.rotation = out;
		out.setLength(0.03f);

		imp.when = 1;
		imp.outVector = out;
		imp.pos = end;
Impacts.push_back(imp);


//and all for the mesh, I only changed:
bullethole->setRotation(Impacts[i].rotation);
The source is like the techdemo.
The bulletholes are not anymore set the same direction, but it nearly seems to be random, I have no idea what's wrong.Image
Visit my website @ www.venex.be
Plethora project will be added to the site
AMD AthlonXP 2600+, 512MB DDR, Radeon M10 (mobile 9600) PRO 64MB, WinXP
Dances
Posts: 454
Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:

Post by Dances »

Its not random, its facing almost a complete 90 degrees from whatever face its in, try setting a rotation of 90 or so after getting the normal.
VeneX
Posts: 228
Joined: Sun Nov 30, 2003 3:32 pm
Location: The Netherlands
Contact:

Post by VeneX »

Dances wrote:Its not random, its facing almost a complete 90 degrees from whatever face its in, try setting a rotation of 90 or so after getting the normal.
I tried to edit the model some times, on one side of the cube (a.k.a. doos) the holes are facing in the right way, while the holes on the other side will point a whole other directionImagethis are 3 sides of the cube, Try for yourself, the demo is uploaded on my website http://members.lycos.nl/phpgenerals/plethora
Visit my website @ www.venex.be
Plethora project will be added to the site
AMD AthlonXP 2600+, 512MB DDR, Radeon M10 (mobile 9600) PRO 64MB, WinXP
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

okay this is just a guess, but the normal might be a position rather than a rotation. use getTargetAngle function from the AI class to convert to a rotation
VeneX
Posts: 228
Joined: Sun Nov 30, 2003 3:32 pm
Location: The Netherlands
Contact:

Post by VeneX »

getTargetAngle from the AI class?
I can only find getTarget

Code: Select all

pas = sm->addParticleSystemSceneNode(false, 0, -1, Impacts[i].pos);

			pas->setParticleSize(core::dimension2d<f32>(10.0f, 10.0f));

			scene::IParticleEmitter* em = pas->createBoxEmitter(
				core::aabbox3d<f32>(-5,-5,-5,5,5,5),
				Impacts[i].outVector, 20,40, video::SColor(0,255,255,255),video::SColor(0,255,255,255),
				1200,1600, 20);
This is the code from the techdemo and the particle smoke which is created is in the same angle as the face it's created on :) only hard to figure out what it should be :?
Visit my website @ www.venex.be
Plethora project will be added to the site
AMD AthlonXP 2600+, 512MB DDR, Radeon M10 (mobile 9600) PRO 64MB, WinXP
Dances
Posts: 454
Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:

Post by Dances »

getTarget DOES return an angle, perhaps that is what he meant.
VeneX
Posts: 228
Joined: Sun Nov 30, 2003 3:32 pm
Location: The Netherlands
Contact:

Post by VeneX »

If I do rotation = camera->getTarget(); it have nearly the same 'random' rotation :(
Visit my website @ www.venex.be
Plethora project will be added to the site
AMD AthlonXP 2600+, 512MB DDR, Radeon M10 (mobile 9600) PRO 64MB, WinXP
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

try control+scrollwheel, it zooms in on text on a web page you know :P

http://irrforge.org/index.php/AI_Class_For_Irrlicht

now use the code from getTargetAngle to find the angle between the plane's position and its normal.
VeneX
Posts: 228
Joined: Sun Nov 30, 2003 3:32 pm
Location: The Netherlands
Contact:

Post by VeneX »

I know for sure that AI class function is different than I ment. This getTargetAngle does calculates the angle between the node and the target, but I guess it only calculates from a boundingbox, I have to know how to get the rotation of a single triangle. :?:
:cry:
Visit my website @ www.venex.be
Plethora project will be added to the site
AMD AthlonXP 2600+, 512MB DDR, Radeon M10 (mobile 9600) PRO 64MB, WinXP
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

it calculates angles, thats all you need.
edit:
to completely spell it out for you, change the first 2 lines to
v = vector3df(0,0,0)
r = plane.Normal;
Post Reply