www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: Uncle Ray on May 22, 2015, 01:16:05 pm

Title: How to make checkForCollisionEllipsoid's Ellipsoid visible?my bug?
Post by: Uncle Ray on May 22, 2015, 01:16:05 pm
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?
Title: Re: How to make checkForCollisionEllipsoid's Ellipsoid visible?my bug?
Post by: Uncle Ray 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.
Title: Re: How to make checkForCollisionEllipsoid's Ellipsoid visible?my bug?
Post by: EgonOlsen on May 22, 2015, 04:06:03 pm
Have you tried this: http://www.jpct.net/jpct-ae/doc/com/threed/jpct/util/ExtendedPrimitives.html#createEllipsoid(com.threed.jpct.SimpleVector, int, float, float) (http://www.jpct.net/jpct-ae/doc/com/threed/jpct/util/ExtendedPrimitives.html#createEllipsoid(com.threed.jpct.SimpleVector, int, float, float))?
Title: Re: How to make checkForCollisionEllipsoid's Ellipsoid visible?my bug?
Post by: Uncle Ray 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?
Title: Re: How to make checkForCollisionEllipsoid's Ellipsoid visible?my bug?
Post by: EgonOlsen 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.