SceneObject collision
by Alex Baaklini · in Torque Game Engine · 05/06/2003 (12:20 pm) · 6 replies
Here's a problem I'm having... I have a SceneObject-derived effect that needs to have the possibility for collision. I have ways of determining bounding cylinders/spheres/boxes/etc. But the real issue is getting from that to something that Torque will process for collisions.
Looking through the code is proving quite useless.
Looking through the code is proving quite useless.
#2
05/07/2003 (8:18 am)
Could you elaborate on that? I'm assuming I'll have to write versions of the buildPolyList/castRay for my own object or something like that? That's not too complicated, but I find it hard to believe that there isn't going to be a few hundred other housekeeping tasks to get in there.
#3
As it stands, I can get projectile collision w/ the bounding box but nothing else.
05/13/2003 (8:03 am)
Ummm... there's obviously more to do, but that's all very poorly explained. I've written a castRay and a buildPolyList for my class, but only castRay ever gets called. I only tried a getPolyList like you mentioned, but that doesn't get called either (which I expected since SceneObjects don't have a getPolyList, only a build).As it stands, I can get projectile collision w/ the bounding box but nothing else.
#4
This is where the player object determines what it is bouncing off of and what to do when that happens. You need to do one of two things: either find a place in the engine where a collision function for your object can be called repeatedly like Player:updatePos() or add code to each of the objects' update functions that you wish to have your object collide against so they can take appropiate actions. It depends on whether you want your object to bounce off other things or if other things should bounce off your object or both.
As near as I can tell (only been working on this a week =) collision in TGE takes place against convex hulls. In an older thread Tim mentions that concave hulls can cause some major problems. At some point you are going to have to output a convex hull for the objects to collide against. With interiors this is done in getPolyList() which outputs the polys of a convex hull in an AbstractPolyList form. For a good reference on how to do that check out AbstractPolyList::addBox().
05/13/2003 (9:24 am)
Take a look at Player::updatePos()This is where the player object determines what it is bouncing off of and what to do when that happens. You need to do one of two things: either find a place in the engine where a collision function for your object can be called repeatedly like Player:updatePos() or add code to each of the objects' update functions that you wish to have your object collide against so they can take appropiate actions. It depends on whether you want your object to bounce off other things or if other things should bounce off your object or both.
As near as I can tell (only been working on this a week =) collision in TGE takes place against convex hulls. In an older thread Tim mentions that concave hulls can cause some major problems. At some point you are going to have to output a convex hull for the objects to collide against. With interiors this is done in getPolyList() which outputs the polys of a convex hull in an AbstractPolyList form. For a good reference on how to do that check out AbstractPolyList::addBox().
#5
So I'm really concerned with objects bouncing off of it.
Either way... there's still a chance that all this effort will be for naught.
05/13/2003 (1:49 pm)
Well, in my case, the object is effectively static... there's some animation, but the animation takes place in portions of the object that don't really matter for collision.So I'm really concerned with objects bouncing off of it.
Either way... there's still a chance that all this effort will be for naught.
#6
"castRay" is the way to go. If you go to here, I tried to explain a little, the system used for collision detection. Go down to the portion headed *** prepRenderImage *** and read that first.
Essentially, the bin container system will call objects that reside in collision bins that intersect with the original castRay call (plus ones in the overflow bin). Each object has its castRay function called. You can determine a collision with your object in object-space using any method you see fit. If a collision happens then you'll need to fill in the appropriate members of the structure that is passed to you in the castRay function (there's plenty of examples in the engine).
With regards to the method used to detect collisions; there are a number of helper classes for polygon collision detected rather than primitive volume detection but by your post, it sounds like you simply want to get it working with spheres/boxes etc.
Hope this helps a little.
- Melv.
05/13/2003 (11:34 pm)
Alex,"castRay" is the way to go. If you go to here, I tried to explain a little, the system used for collision detection. Go down to the portion headed *** prepRenderImage *** and read that first.
Essentially, the bin container system will call objects that reside in collision bins that intersect with the original castRay call (plus ones in the overflow bin). Each object has its castRay function called. You can determine a collision with your object in object-space using any method you see fit. If a collision happens then you'll need to fill in the appropriate members of the structure that is passed to you in the castRay function (there's plenty of examples in the engine).
With regards to the method used to detect collisions; there are a number of helper classes for polygon collision detected rather than primitive volume detection but by your post, it sounds like you simply want to get it working with spheres/boxes etc.
Hope this helps a little.
- Melv.
Associate Matt Fairfax
PopCap