return new HullCollisionShape(p);
return new HullCollisionShape(p);
/** * Create a hull collision shape from linked vertices to this bone. * * @param model the model on which to base the shape * @param boneIndices indices of relevant bones (not null, unaffected) * @param initialScale scale factors * @param initialPosition location * @param weightThreshold minimum weight for inclusion * @return a new shape */ public static HullCollisionShape makeShapeFromVerticeWeights(Spatial model, List<Integer> boneIndices, Vector3f initialScale, Vector3f initialPosition, float weightThreshold) { List<Float> points = new ArrayList<>(100); SkeletonControl skeletonCtrl = model.getControl(SkeletonControl.class); Mesh[] targetMeshes = skeletonCtrl.getTargets(); for (Mesh mesh : targetMeshes) { for (Integer index : boneIndices) { List<Float> bonePoints = getPoints(mesh, index, initialScale, initialPosition, weightThreshold); points.addAll(bonePoints); } } assert !points.isEmpty(); float[] p = new float[points.size()]; for (int i = 0; i < points.size(); i++) { p[i] = points.get(i); } return new HullCollisionShape(p); }
/** * Create a hull collision shape from linked vertices to this bone. * * @param model the model on which to base the shape * @param boneIndices indices of relevant bones (not null, unaffected) * @param initialScale scale factors * @param initialPosition location * @param weightThreshold minimum weight for inclusion * @return a new shape */ public static HullCollisionShape makeShapeFromVerticeWeights(Spatial model, List<Integer> boneIndices, Vector3f initialScale, Vector3f initialPosition, float weightThreshold) { List<Float> points = new ArrayList<>(100); SkeletonControl skeletonCtrl = model.getControl(SkeletonControl.class); Mesh[] targetMeshes = skeletonCtrl.getTargets(); for (Mesh mesh : targetMeshes) { for (Integer index : boneIndices) { List<Float> bonePoints = getPoints(mesh, index, initialScale, initialPosition, weightThreshold); points.addAll(bonePoints); } } assert !points.isEmpty(); float[] p = new float[points.size()]; for (int i = 0; i < points.size(); i++) { p[i] = points.get(i); } return new HullCollisionShape(p); }
/** * 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; } }
/** * Create a hull collision shape from linked vertices to this bone. * Vertices have to be previoulsly gathered in a map using buildPointMap method * @param link * @param model * @return */ public static HullCollisionShape makeShapeFromPointMap(Map<Integer, List<Float>> pointsMap, List<Integer> boneIndices, Vector3f initialScale, Vector3f initialPosition) { ArrayList<Float> points = new ArrayList<Float>(); for (Integer index : boneIndices) { List<Float> l = pointsMap.get(index); if (l != null) { for (int i = 0; i < l.size(); i += 3) { Vector3f pos = new Vector3f(); pos.x = l.get(i); pos.y = l.get(i + 1); pos.z = l.get(i + 2); pos.subtractLocal(initialPosition).multLocal(initialScale); points.add(pos.x); points.add(pos.y); points.add(pos.z); } } } float[] p = new float[points.size()]; for (int i = 0; i < points.size(); i++) { p[i] = points.get(i); } return new HullCollisionShape(p); }
return new HullCollisionShape(p);
return new HullCollisionShape(p);
return new HullCollisionShape(p);
return new HullCollisionShape(p);
return new HullCollisionShape(p);
/** * 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; } }