Package jinngine.geometry

Examples of jinngine.geometry.ConvexHull


      vertices.add( new Vector3( -0.5, -0.50.5));
      vertices.add( new Vector30.50.5, -0.5));
      vertices.add( new Vector3( -0.50.5, -0.5));
      vertices.add( new Vector30.5, -0.5, -0.5));
      vertices.add( new Vector3( -0.5, -0.5, -0.5));
      final ConvexHull hull = new ConvexHull(vertices);
     
      toDraw.add( new DrawShape() {   
        @Override
        public Iterator<Vector3[]> getFaces() {
          return hull.getFaces();
        }
        @Override
        public Matrix4 getTransform() {
          return g.getTransform();
        }
        @Override
        public Body getReferenceBody() {
          return g.getBody();
        }
      });
    }
   
    if ( g instanceof UniformCapsule  ) {
      UniformCapsule cap = (UniformCapsule)g;
      final List<Vector3> vertices = new ArrayList<Vector3>();
      final List<Vector3> icoicosahedron = new ArrayList<Vector3>();
     
      // point on icosahedron
//      final double t = (1.0 + Math.sqrt(5.0))/ 2.0;
//      final double S = 1.0 / ( Math.sqrt(1+t*t));
//      icoicosahedron.add(new Vector3(-1,  t,  0));
//      icoicosahedron.add( new Vector3( 1,  t,  0));
//      icoicosahedron.add( new Vector3(-1, -t,  0));
//      icoicosahedron.add( new Vector3( 1, -t,  0));
//      icoicosahedron.add( new Vector3( 0, -1,  t));
//      icoicosahedron.add( new Vector3( 0,  1,  t));
//      icoicosahedron.add( new Vector3( 0, -1, -t));
//      icoicosahedron.add( new Vector3( 0,  1, -t));
//      icoicosahedron.add( new Vector3( t,  0, -1));
//      icoicosahedron.add( new Vector3( t,  0,  1));
//      icoicosahedron.add( new Vector3(-t,  0, -1));
//      icoicosahedron.add( new Vector3(-t,  0,  1));

      ConvexHull icosphere = buildIcosphere(1, 2);
     
      // scale to unit
//      for (Vector3 v: icoicosahedron)
//        v.assign(v.multiply(S) );

      // add two icos to vertices
      Iterator<Vector3> iter = icosphere.getVertices();
      while(iter.hasNext()) {
        Vector3 v = iter.next();
        vertices.add( v.multiply(cap.getRadius()).add(0,0,cap.getLength()/2));
        vertices.add( v.multiply(cap.getRadius()).add(0,0,-cap.getLength()/2));
      }
       
      final ConvexHull hull = new ConvexHull(vertices);
     
      toDraw.add( new DrawShape() {   
        @Override
        public Iterator<Vector3[]> getFaces() {
          return hull.getFaces();
        }
        @Override
        public Matrix4 getTransform() {
          return g.getTransform();
        }
View Full Code Here


    vertices.add( new Vector3(-t,  0, -1).normalize());
    vertices.add( new Vector3(-t,  01).normalize());

    int n = 0;
    while (true) {
      ConvexHull hull = new ConvexHull(vertices);

      if (n>=depth)
        return hull;

      // for each face, add a new sphere support
      // point in direction of the face normal
      Iterator<Vector3[]> iter = hull.getFaces();
      while(iter.hasNext()) {
        Vector3[] face = iter.next();
        Vector3 normal =face[1].sub(face[0]).cross(face[2].sub(face[1])).normalize();
        vertices.add(new Vector3(normal));
      }
View Full Code Here

          dims.x*-0.5, dims.y*-0.5, dims.z*-0.5};
     
      return points;
   
    if ( g instanceof ConvexHull ) {
      ConvexHull hull = (ConvexHull)g;
      int n = hull.getNumberOfVertices();
      double points[] = new double[n*3];
      int i = 0; Iterator<Vector3> iter = hull.getVertices();

      Matrix3 T = new Matrix3();
      Vector3 t = new Vector3();
      g.getLocalTransform(T, t);
 
View Full Code Here

TOP

Related Classes of jinngine.geometry.ConvexHull

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.