Crystal Space
Welcome, Guest. Please login or register.
July 25, 2014, 01:35:41 am

Login with username, password and session length
Search:     Advanced search
9005 Posts in 2043 Topics by 8229 Members
Latest Member: Kula999lidia
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Game Content Creation
| | |-+  csColliderActor and collision with objects not reporting exact collision
« previous next »
Pages: [1] Print
Author Topic: csColliderActor and collision with objects not reporting exact collision  (Read 2996 times)
Panch
Jr. Member
**
Posts: 80


View Profile Email
« on: October 15, 2007, 07:10:27 pm »

I believe I saw this somewhere else but I'm not sure if there was ever a resolution. What I've noticed is that when a csColliderActor collides with another object, other than the world, it collides with the center of the object; not with the outer edges of the object.

Part 1 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I use:
Code:
// If the collider get hit mesh array has objects in it
    if(collider_hero.GetHitMeshes().GetSize()>0)
    {
csRef<iMeshWrapper> i=collider_hero.GetHitMeshes().GetIterator().Next();
    csRef <iObject> object = i->QueryObject();

To find what I've hit, so say I want to hit a large bubble (sphere), I use:
Quote
// Check for inventory items
       if(!items.Contains(object->GetName ()))
       {
         items.Delete(object->GetName ());
          engine->RemoveObject(object);
          inventory.Push(object->GetName ());
       }

While this works for smaller objects, I imagine because the objects size and center are closely oriented; it does not work for larger objects. I will get the collision I want if I walk into the object, and jump upwards until I reach the objects center.

Part 2 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I see a similar problem when I have a project collide with an enemy. I want there to be an explosion animation on the site of impact. The collision works, but the explosion is always a few marks above whatever is hit:

Quote
// Do a beam to check if we hit something
   csSectorHitBeamResult rc = lasersector->HitBeamPortals (
        laserstart, WeaponMesh->GetMovable()->GetFullPosition());
 
// If we hit a mesh...
  if (rc.mesh)
  {
     // Loop to only animate the detonation once, otherwise multiple explosions are drawn
     if (animate != 1)
     {
      // Start an explosion at the site of the collision
      StartExplosion(rc.mesh->GetMovable()->GetSectors ()->Get (0),
           rc.isect);   
    
      // Remove our weapon mesh (if desired)
      engine->RemoveObject(WeaponMesh);
      
      // Set the animation flag so that the loop is exited
      animate = 1;
     }

Not really sure what I'm asking. I guess I want be able to collide with a large object, at it's edge and be able to illicit a reaction of some sort. Should I be doing per-polygon collision detection or something other than what I am above?

Thanks!
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #1 on: October 16, 2007, 05:23:32 am »

If it is a static object (thing or genmesh) you can use the collider system (iCollideSystem and csColliderWrapper) manually to get per-polygon accurate collision detection. Maybe that helps?

Greetings,
Logged
Panch
Jr. Member
**
Posts: 80


View Profile Email
« Reply #2 on: October 16, 2007, 03:12:37 pm »

Quote
If it is a static object (thing or genmesh) you can use the collider system (iCollideSystem and csColliderWrapper) manually to get per-polygon accurate collision detection

Well some of the objects are static, I'll play around with it Smiley

Thanks!
Logged
Panch
Jr. Member
**
Posts: 80


View Profile Email
« Reply #3 on: October 16, 2007, 10:07:39 pm »

No go,

csColliderWrapper::Collide( ... )

Kept reporting that parameter would could only be of type csColliderWrapper, when there should be 2 overloads: one for iObject and another for iCollider.
Any idea why?

Thanks!

EDIT - NM, I figured it out. Thanks Smiley. However it seems only ThingMesh's are accurate. Genmeshes are more accurate than other types but are not per polygon accurate.
« Last Edit: October 21, 2007, 03:16:41 pm by Panch » Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 5.261 seconds with 16 queries.