Author Topic: How to make checkForCollisionEllipsoid's Ellipsoid visible?my bug?  (Read 855 times)

Offline Uncle Ray

  • int
  • **
  • Posts: 81
    • View Profile
SimpleVector Ellipsoid=new SimpleVector(0,0,0)
SimpleVector boundingEllipsoid =new SimpleVector(0,0,0)
Object3D boundingbox;
Object3D target;
float scale=2;
ini()
{
                 target=...............;
                 target.setscale(scale);
                float[] box = target.getMesh().getBoundingBox();
      float widthX = box[1] - box[0];
      float heightY = box[3] - box[2];
      float lengthZ = box[5] - box[4];
      ellipsoid.x = widthX/2+1 ;
      ellipsoid.y = heightY/2+1 ;
      ellipsoid.z = lengthZ/2+1 ;
               boundingEllipsoid.x=ellipsoid.x*2/scale;
               boundingEllipsoid.y=ellipsoid.y*2/scale;
               boundingEllipsoid.z=ellipsoid.z*2/scale;
 boundingbox= ExtendedPrimitives.createEllipsoid(boundingEllipsoid, 20);
    world.addObject(boundingbox);
    boundingbox.addParent(target);   
    boundingbox.clearTranslation();
    boundingbox.setOrigin(target.getTransformedCenter());
   
}

update()
{
    fix_front=obj.checkForCollisionEllipsoid(front, Ellipsoid,5);
    if(front.equals(fix_front)==true)
    {
      obj.setTransparency(-1);
    }
    if(front.equals(fix_front)==false)
    {
       obj.setTransparency(0);
    }


}





MY PROBLEM:
i want Ellipsoid visible,so i create boundingbox to show the checkEllipsoid's Ellipsoid.but i my program,some times the checkcollideEllipsoid work,and some times checkcollideEllipsoid unwork.

so,i think may be my boundingbox is wrong,so how to create the right boudingbox,the same scale and the same position with checkcollideEllipsoid's Ellipsoid?

Offline Uncle Ray

  • int
  • **
  • Posts: 81
    • View Profile
Re: How to make checkForCollisionEllipsoid's Ellipsoid visible?my bug?
« Reply #1 on: May 22, 2015, 01:21:38 pm »
I just need create a Ellipsoid,which is the same width,height,lengh and position with checkforcollitionEllipsoid's Ellipsoid.

Any helps will be much appreciated.


Offline Uncle Ray

  • int
  • **
  • Posts: 81
    • View Profile
Re: How to make checkForCollisionEllipsoid's Ellipsoid visible?my bug?
« Reply #3 on: May 22, 2015, 05:08:01 pm »
problem still.ego,how do you make the collide ellipsoid viaible?
maybe my code was wrong?
i just need to see the collide ellipsoid.
any tips?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11775
    • View Profile
    • http://www.jpct.net
Re: How to make checkForCollisionEllipsoid's Ellipsoid visible?my bug?
« Reply #4 on: May 23, 2015, 10:20:34 am »
If you are adding the box as a child of the target, you don't have to set the origin in addition. Or at least not to the transformed center but to the center in object space.