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?