Collision

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
SanderVocke
Posts: 40
Joined: Mon Oct 31, 2005 1:19 pm
Location: Netherlands

Collision

Post 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.
"The shortest distance between two points is always under construction."
- Noelie Alite
dhenton9000
Posts: 395
Joined: Fri Apr 08, 2005 8:46 pm

Post by dhenton9000 »

what about getCollisionResultPosition, it looks like you could make your own "response animator", part of ISceneCollisionManager
SanderVocke
Posts: 40
Joined: Mon Oct 31, 2005 1:19 pm
Location: Netherlands

Post 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.
"The shortest distance between two points is always under construction."
- Noelie Alite
dracflamloc
Posts: 142
Joined: Sat Dec 11, 2004 8:13 am
Contact:

Post by dracflamloc »

Cant you just set the response vectors to 0?
SARIN
Posts: 139
Joined: Fri Oct 29, 2004 3:53 am

Post 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
SanderVocke
Posts: 40
Joined: Mon Oct 31, 2005 1:19 pm
Location: Netherlands

Post 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.
"The shortest distance between two points is always under construction."
- Noelie Alite
SanderVocke
Posts: 40
Joined: Mon Oct 31, 2005 1:19 pm
Location: Netherlands

Post 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.
"The shortest distance between two points is always under construction."
- Noelie Alite
Guest

Post 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]
pfo
Posts: 370
Joined: Mon Aug 29, 2005 10:54 pm
Location: http://web.utk.edu/~pfox1

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

fix to IntersectsWithLine bug

Post 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.
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post 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.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post 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
Image Image Image
gabdab
Posts: 42
Joined: Fri May 12, 2006 5:11 pm

re

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