Package com.bulletphysics.collision.shapes

Examples of com.bulletphysics.collision.shapes.ShapeHull


            {
              ConvexShape convexShape = (ConvexShape)shape;
              if (shape.getUserPointer() == null)
              {
                // create a hull approximation
                ShapeHull hull = new ShapeHull(convexShape);

                // JAVA NOTE: not needed
                ///// cleanup memory
                //m_shapeHulls.push_back(hull);

                float margin = shape.getMargin();
                hull.buildHull(margin);
                convexShape.setUserPointer(hull);

                //printf("numTriangles = %d\n", hull->numTriangles ());
                //printf("numIndices = %d\n", hull->numIndices ());
                //printf("numVertices = %d\n", hull->numVertices ());
              }

              if (shape.getUserPointer() != null)
              {
                //glutSolidCube(1.0);
                ShapeHull hull = (ShapeHull)shape.getUserPointer();
               
                Vector3f normal = vectorsPool.get();
                Vector3f tmp1 = vectorsPool.get();
                Vector3f tmp2 = vectorsPool.get();

                if (hull.numTriangles () > 0)
                {
                  int index = 0;
                  IntArrayList idx = hull.getIndexPointer();
                  ObjectArrayList<Vector3f> vtx = hull.getVertexPointer();

                  gl.glBegin (gl.GL_TRIANGLES);

                  for (int i=0; i<hull.numTriangles (); i++)
                  {
                    int i1 = index++;
                    int i2 = index++;
                    int i3 = index++;
                    assert(i1 < hull.numIndices () &&
                      i2 < hull.numIndices () &&
                      i3 < hull.numIndices ());

                    int index1 = idx.get(i1);
                    int index2 = idx.get(i2);
                    int index3 = idx.get(i3);
                    assert(index1 < hull.numVertices () &&
                      index2 < hull.numVertices () &&
                      index3 < hull.numVertices ());

                    Vector3f v1 = vtx.getQuick(index1);
                    Vector3f v2 = vtx.getQuick(index2);
                    Vector3f v3 = vtx.getQuick(index3);
                    tmp1.sub(v3, v1);
View Full Code Here

TOP

Related Classes of com.bulletphysics.collision.shapes.ShapeHull

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.