How to make checkForCollisionEllipsoid's Ellipsoid visible?my bug?

Started by Uncle Ray, May 22, 2015, 01:16:05 PM

Previous topic - Next topic

Uncle Ray

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?

Uncle Ray

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.


Uncle Ray

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?

EgonOlsen

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.