Main Menu

Collision Ellipsoids!

Started by Mizuki Takase, August 10, 2007, 06:31:51 PM

Previous topic - Next topic

Mizuki Takase

I might have gotten mixed up with whichever is the most current JPCT, but is there a Primitives.getEllipsoid() yet? I would like a way to visually see the ellipsoid so that whenever I am calling Object3D.checkForCollisionEllipsoid(), I would know if I would need a bigger/smaller sized collision ellipsoid. Thanks a bunch~!

EgonOlsen

No, it's not in yet. It's still on the to-do-list, but thank you for reminding me. It should be easy to add.

Mizuki Takase

Thanks!! Its not really a must-add for now simply because I am way busy with everything else in life. However, every now and then, I do find myself playing with JPCT.

raft

i use a rectangular prism for such visualization purposes. you may use jkilavuz's create box helper method or alternatively this is the relavant piece of code for creating a box

    /** 3D representation of a box */
    public static class Box3D extends Object3D {
        public Box3D(Object3D object3d) {
            this(new Box(object3d));
        }
       
        public Box3D(Box box) {
            super(12);
           
            // left side
            addTriangle(
                    new SimpleVector(box.x.start, box.y.start, box.z.start),
                    new SimpleVector(box.x.start, box.y.end, box.z.end),
                    new SimpleVector(box.x.start, box.y.end, box.z.start));
           
            addTriangle(
                    new SimpleVector(box.x.start, box.y.start, box.z.start),
                    new SimpleVector(box.x.start, box.y.start, box.z.end),
                    new SimpleVector(box.x.start, box.y.end, box.z.end));
           
            // right side
            addTriangle(
                    new SimpleVector(box.x.end, box.y.start, box.z.start),
                    new SimpleVector(box.x.end, box.y.end, box.z.start),
                    new SimpleVector(box.x.end, box.y.end, box.z.end));
           
            addTriangle(
                    new SimpleVector(box.x.end, box.y.start, box.z.start),
                    new SimpleVector(box.x.end, box.y.end, box.z.end),
                    new SimpleVector(box.x.end, box.y.start, box.z.end));
           
            //top
            addTriangle(
                    new SimpleVector(box.x.start, box.y.start, box.z.start),
                    new SimpleVector(box.x.end, box.y.start, box.z.end),
                    new SimpleVector(box.x.start, box.y.start, box.z.end));
           
            addTriangle(
                    new SimpleVector(box.x.start, box.y.start, box.z.start),
                    new SimpleVector(box.x.end, box.y.start, box.z.start),
                    new SimpleVector(box.x.end, box.y.start, box.z.end));
           
            //bottom
            addTriangle(
                    new SimpleVector(box.x.start, box.y.end, box.z.start),
                    new SimpleVector(box.x.start, box.y.end, box.z.end),
                    new SimpleVector(box.x.end, box.y.end, box.z.end));
           
            addTriangle(
                    new SimpleVector(box.x.start, box.y.end, box.z.start),
                    new SimpleVector(box.x.end, box.y.end, box.z.end),
                    new SimpleVector(box.x.end, box.y.end, box.z.start));
           
            //front
            addTriangle(
                    new SimpleVector(box.x.start, box.y.start, box.z.start),
                    new SimpleVector(box.x.end, box.y.end, box.z.start),
                    new SimpleVector(box.x.end, box.y.start, box.z.start));
           
            addTriangle(
                    new SimpleVector(box.x.start, box.y.start, box.z.start),
                    new SimpleVector(box.x.start, box.y.end, box.z.start),
                    new SimpleVector(box.x.end, box.y.end, box.z.start));
           
            //back
            addTriangle(
                    new SimpleVector(box.x.start, box.y.start, box.z.end),
                    new SimpleVector(box.x.end, box.y.start, box.z.end),
                    new SimpleVector(box.x.end, box.y.end, box.z.end));
           
            addTriangle(
                    new SimpleVector(box.x.start, box.y.start, box.z.end),
                    new SimpleVector(box.x.end, box.y.end, box.z.end),
                    new SimpleVector(box.x.start, box.y.end, box.z.end));
        }
    }

EgonOlsen

I've updated the beta of 1.15 so that Primitives now offer a method to create ellipsoids. Hope this helps.