/** * Instantiate the configured shape in Bullet. */ protected void createShape() { // ObjectArrayList<Vector3f> pointList = new ObjectArrayList<Vector3f>(); // for (int i = 0; i < points.length; i += 3) { // pointList.add(new Vector3f(points[i], points[i + 1], points[i + 2])); // } // objectId = new ConvexHullShape(pointList); // objectId.setLocalScaling(Converter.convert(getScale())); // objectId.setMargin(margin); ByteBuffer bbuf=BufferUtils.createByteBuffer(points.length * 4); // fbuf = bbuf.asFloatBuffer(); // fbuf.rewind(); // fbuf.put(points); for (int i = 0; i < points.length; i++) { float f = points[i]; bbuf.putFloat(f); } bbuf.rewind(); objectId = createShape(bbuf); Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Created Shape {0}", Long.toHexString(objectId)); setScale(scale); setMargin(margin); }
/** * Create a hull collision shape for the specified geometry. * * @param geom the geometry on which to base the shape (not null) * @param parent */ private static HullCollisionShape createSingleDynamicMeshShape(Geometry geom, Spatial parent) { Mesh mesh = geom.getMesh(); Transform trans = getTransform(geom, parent); if (mesh != null) { HullCollisionShape dynamicShape = new HullCollisionShape(mesh); dynamicShape.setScale(trans.getScale()); return dynamicShape; } else { return null; } }
/** * Create a hull collision shape for the specified geometry. * * @param geom the geometry on which to base the shape (not null) * @param parent */ private static HullCollisionShape createSingleDynamicMeshShape(Geometry geom, Spatial parent) { Mesh mesh = geom.getMesh(); Transform trans = getTransform(geom, parent); if (mesh != null) { HullCollisionShape dynamicShape = new HullCollisionShape(mesh); dynamicShape.setScale(trans.getScale()); return dynamicShape; } else { return null; } }
protected void createShape() { // ObjectArrayList<Vector3f> pointList = new ObjectArrayList<Vector3f>(); // for (int i = 0; i < points.length; i += 3) { // pointList.add(new Vector3f(points[i], points[i + 1], points[i + 2])); // } // objectId = new ConvexHullShape(pointList); // objectId.setLocalScaling(Converter.convert(getScale())); // objectId.setMargin(margin); ByteBuffer bbuf=BufferUtils.createByteBuffer(points.length * 4); // fbuf = bbuf.asFloatBuffer(); // fbuf.rewind(); // fbuf.put(points); for (int i = 0; i < points.length; i++) { float f = points[i]; bbuf.putFloat(f); } bbuf.rewind(); objectId = createShape(bbuf); Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Created Shape {0}", Long.toHexString(objectId)); setScale(scale); setMargin(margin); }
protected void createShape() { // ObjectArrayList<Vector3f> pointList = new ObjectArrayList<Vector3f>(); // for (int i = 0; i < points.length; i += 3) { // pointList.add(new Vector3f(points[i], points[i + 1], points[i + 2])); // } // objectId = new ConvexHullShape(pointList); // objectId.setLocalScaling(Converter.convert(getScale())); // objectId.setMargin(margin); ByteBuffer bbuf=BufferUtils.createByteBuffer(points.length * 4); // fbuf = bbuf.asFloatBuffer(); // fbuf.rewind(); // fbuf.put(points); for (int i = 0; i < points.length; i++) { float f = points[i]; bbuf.putFloat(f); } bbuf.rewind(); objectId = createShape(bbuf); Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Created Shape {0}", Long.toHexString(objectId)); setScale(scale); setMargin(margin); }
/** * This method creates a hull collision shape for the given mesh.<br> */ private static HullCollisionShape createSingleDynamicMeshShape(Geometry geom, Spatial parent) { Mesh mesh = geom.getMesh(); Transform trans = getTransform(geom, parent); if (mesh != null) { HullCollisionShape dynamicShape = new HullCollisionShape(mesh); dynamicShape.setScale(trans.getScale()); return dynamicShape; } else { return null; } }
/** * Create a hull collision shape for the specified geometry. * * @param geom the geometry on which to base the shape (not null) * @param parent */ private static HullCollisionShape createSingleDynamicMeshShape(Geometry geom, Spatial parent) { Mesh mesh = geom.getMesh(); Transform trans = getTransform(geom, parent); if (mesh != null) { HullCollisionShape dynamicShape = new HullCollisionShape(mesh); dynamicShape.setScale(trans.getScale()); return dynamicShape; } else { return null; } }