www.jpct.net

General => Feedback => Topic started by: Mizuki Takase on August 10, 2007, 06:31:51 pm

Title: Collision Ellipsoids!
Post by: Mizuki Takase on August 10, 2007, 06:31:51 pm
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~!
Title: Re: Collision Ellipsoids!
Post by: EgonOlsen on August 10, 2007, 06:33:55 pm
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.
Title: Re: Collision Ellipsoids!
Post by: Mizuki Takase on August 10, 2007, 06:35:22 pm
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.
Title: Re: Collision Ellipsoids!
Post by: raft on August 13, 2007, 01:49:09 pm
i use a rectangular prism for such visualization purposes. you may use jkilavuz's  create box helper method (http://www.jkilavuz.com/doc/api/raft/kilavuz/util/jpct/Visuals.html#createBox(float,%20float,%20float,%20float,%20float,%20float)) or alternatively this is the relavant piece of code for creating a box

Code: [Select]
    /** 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));
        }
    }
Title: Re: Collision Ellipsoids!
Post by: EgonOlsen on August 13, 2007, 09:50:53 pm
I've updated the beta of 1.15 so that Primitives now offer a method to create ellipsoids. Hope this helps.