Page 1 of 1

Collision

Posted: Wed Nov 16, 2005 8:31 pm
by SanderVocke
Believe me when I say that I searched for an answer for this. How do i check collision between my level triangle selector and a scenenode's bbox/triangle selector? The collision tutorial doesnt cover this, and every forum post i found on this topic was redirected to the collision response animator. However, I don't want any collision response, i merely want to know whether my model collided with the level. Should I manually get the 3d lines from my bounding box and then use getCollisionPoint()? And if so, how do I get the lines from a bounding box? the getEdges() function is unclear to me. Thanks alot.

Posted: Wed Nov 16, 2005 9:06 pm
by dhenton9000
what about getCollisionResultPosition, it looks like you could make your own "response animator", part of ISceneCollisionManager

Posted: Wed Nov 16, 2005 9:31 pm
by SanderVocke
From what I see in the API, it looks like this function is just like a collision response animator: it determines the new position of the ellipsoid, based on collision, gravity, sliding etc. In my spacegame, I want ships to explode when hitting level geometry, not slide, gravitate or anything like that. unless I understood the API in a wrong way, I don't think that's what Im looking for.

Posted: Wed Nov 16, 2005 9:39 pm
by dracflamloc
Cant you just set the response vectors to 0?

Posted: Thu Nov 17, 2005 5:03 am
by SARIN
try a aabbox3d and then use this function to test for triangles, if i understand it right (which i doubt considering ive been gone a while) then check if the triangles are >0.
ITriangleSelector::getTriangles (triangle3df * , s32 , s32 , aabbox3d< f32 >, matrix4 *)
the triangle selector would be the lvl selector, and the box would be the box around your ship

Posted: Thu Nov 17, 2005 9:24 am
by SanderVocke
Thx, that might just be what I need. Ive got one little problem tho: how do I pass an array of triangles to the function? should it be done like this:

Code: Select all

triangle3d<f32> triangles[2];
		aabbox3d<f32> box = ships[i].shipnode->getTransformedBoundingBox();
		s32 trianglecount;
		levelts->getTriangles(&triangles, 1, trianglecount, box, 0);
or like this:

Code: Select all


triangle3d<f32> *triangles[2];
		aabbox3d<f32> box = ships[i].shipnode->getTransformedBoundingBox();
		s32 trianglecount;
		levelts->getTriangles(triangles, 1, trianglecount, box, 0);

cause both give conversion errors.

Posted: Thu Nov 17, 2005 11:37 am
by SanderVocke
nvm that, I found the correct way to do it. It seems to work fine, only I get the idea that there is an invisible border around the quake 3 standard level: my ship now explodes when trying to enter the level from outside. Ill make my own level and try again.

Posted: Thu Nov 17, 2005 5:09 pm
by Guest
Hm, it seems this is not working after all. I used the following code:

Code: Select all


vector3df max = vector3df(1.0f, 1.0f, 1.0f);
			vector3df min = vector3df(-1.0f, -1.0f, -1.0f);
			matrix4 m;
			m.setRotationDegrees(missiles[i].carrier->getRotation());
			m.transformVect(max);
			m.transformVect(min);
			min+=missiles[i].carrier->getPosition();
			max+=missiles[i].carrier->getPosition();
			aabbox3d<f32> box(min, max);
			triangle3d<f32> triangles;
			s32 trianglecount;
			levelts->getTriangles(&triangles, 1, trianglecount, box, 0);
			if(trianglecount)
			{
				missiles[i].Explode();
			}
this is for missiles, and I did the same for my ships. However, it seems that whenever the ship/missile is in the level, it explodes. I used the quake 3 level, and spawned my ship outside its borders, but as soon as I get near the level this code makes my ship explode.[/code]

Posted: Thu Nov 17, 2005 7:20 pm
by pfo
Irrlicht's collision detection code is a little flaky sometimes. I was trying to raycast boxes, using aabbox3df.intersectsWithLine, and if my line was almost parallel to any edge of the box, then no matter where I clicked I got an intersection, even though there was none. I've had similar results with bounding boxes reporting collisions when there was none; usually when any 2 lines on each box were mostly parallel to each other.

This is why I went to Newton...

fix to IntersectsWithLine bug

Posted: Fri Apr 14, 2006 1:03 am
by mdc
There appears to be a bug in 0.14, that didn't exist in earlier versions of the engine. The solution is here:

http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=12335

Hopefully the next version will incorporate this fix, so we don't have to compile from source.

Posted: Fri Apr 14, 2006 11:36 am
by sudi
What i understood from ur first posts is that u don't want a collision response animator in the sense of changing the objects position but a way to determine if an object hit something and thenget a callback from that. Am i right?
Then u should consider using a physics engine like newton that provides a material based callback system.

Posted: Fri Apr 14, 2006 12:42 pm
by JP
It seems that Quake3 levels have to be enclosed, hence there is probably an invisible box around the level causing it to be enclosed, and that may be what your ship is hitting and exploding against.

http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=12621

re

Posted: Fri May 12, 2006 5:13 pm
by gabdab
..I wonder if it might depends on octree space partitioning of the level since I had similar result with rays on ogre and bsp levels.
So the missile collides with the partitioning of the level as if it was a sort of face?

Gab-