Author Topic: Collision Ellipsoids!  (Read 6400 times)

Offline Mizuki Takase

  • int
  • **
  • Posts: 97
    • View Profile
Collision Ellipsoids!
« 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~!
« Last Edit: August 10, 2007, 06:33:49 pm by Mizuki Takase »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Collision Ellipsoids!
« Reply #1 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.

Offline Mizuki Takase

  • int
  • **
  • Posts: 97
    • View Profile
Re: Collision Ellipsoids!
« Reply #2 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.

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Collision Ellipsoids!
« Reply #3 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 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));
        }
    }

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Collision Ellipsoids!
« Reply #4 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.