Collision
-
- Posts: 40
- Joined: Mon Oct 31, 2005 1:19 pm
- Location: Netherlands
Collision
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
- Noelie Alite
-
- Posts: 395
- Joined: Fri Apr 08, 2005 8:46 pm
-
- Posts: 40
- Joined: Mon Oct 31, 2005 1:19 pm
- Location: Netherlands
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
- Noelie Alite
-
- Posts: 142
- Joined: Sat Dec 11, 2004 8:13 am
- Contact:
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
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
-
- Posts: 40
- Joined: Mon Oct 31, 2005 1:19 pm
- Location: Netherlands
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:
or like this:
cause both give conversion errors.
Code: Select all
triangle3d<f32> triangles[2];
aabbox3d<f32> box = ships[i].shipnode->getTransformedBoundingBox();
s32 trianglecount;
levelts->getTriangles(&triangles, 1, trianglecount, box, 0);
Code: Select all
triangle3d<f32> *triangles[2];
aabbox3d<f32> box = ships[i].shipnode->getTransformedBoundingBox();
s32 trianglecount;
levelts->getTriangles(triangles, 1, trianglecount, box, 0);
"The shortest distance between two points is always under construction."
- Noelie Alite
- Noelie Alite
-
- Posts: 40
- Joined: Mon Oct 31, 2005 1:19 pm
- Location: Netherlands
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
- Noelie Alite
Hm, it seems this is not working after all. I used the following code:
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]
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();
}
-
- Posts: 370
- Joined: Mon Aug 29, 2005 10:54 pm
- Location: http://web.utk.edu/~pfox1
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...
This is why I went to Newton...
fix to IntersectsWithLine bug
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.
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.
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.
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.
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
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=12621