public void setParent(Node node) { for(int i = 0; i < geometries.size(); ++i) { Geometry geom = geometries.get(i); geom.setName(node.getName() + (i > 0 ? "-" + i : "")); geom.updateModelBound(); node.attachChild(geom); } }
private static Geometry createDebugShape(CollisionShape shape) { Geometry geom = new Geometry(); geom.setMesh(DebugShapeFactory.getDebugMesh(shape)); // geom.setLocalScale(shape.getScale()); geom.updateModelBound(); return geom; }
/** * Create a geometry for visualizing the specified shape. * * @param shape (not null, unaffected) * @return a new geometry (not null) */ private static Geometry createDebugShape(CollisionShape shape) { Geometry geom = new Geometry(); geom.setMesh(DebugShapeFactory.getDebugMesh(shape)); // geom.setLocalScale(shape.getScale()); geom.updateModelBound(); return geom; }
/** * This method returns the bounding box of the given geometries. * * @param geometries * the list of geometries * @return bounding box of the given geometries */ public static BoundingBox getBoundingBox(Geometry... geometries) { BoundingBox result = null; for (Geometry geometry : geometries) { geometry.updateModelBound(); BoundingVolume bv = geometry.getModelBound(); if (bv instanceof BoundingBox) { return (BoundingBox) bv; } else if (bv instanceof BoundingSphere) { BoundingSphere bs = (BoundingSphere) bv; float r = bs.getRadius(); return new BoundingBox(bs.getCenter(), r, r, r); } else { throw new IllegalStateException("Unknown bounding volume type: " + bv.getClass().getName()); } } return result; }
/** * This method returns the bounding sphere of the given geometries. * * @param geometries * the list of geometries * @return bounding sphere of the given geometries */ /* package */static BoundingSphere getBoundingSphere(Geometry... geometries) { BoundingSphere result = null; for (Geometry geometry : geometries) { geometry.updateModelBound(); BoundingVolume bv = geometry.getModelBound(); if (bv instanceof BoundingBox) { BoundingBox bb = (BoundingBox) bv; float r = Math.max(bb.getXExtent(), bb.getYExtent()); r = Math.max(r, bb.getZExtent()); return new BoundingSphere(r, bb.getCenter()); } else if (bv instanceof BoundingSphere) { return (BoundingSphere) bv; } else { throw new IllegalStateException("Unknown bounding volume type: " + bv.getClass().getName()); } } return result; }
out.updateModelBound(); retVal.add(out);
private void updateBoneMesh(Geometry geom, Vector3f start, Vector3f[] ends) { if (geom.getMesh() instanceof ArmatureInterJointsWire) { ((ArmatureInterJointsWire) geom.getMesh()).updatePoints(start, ends); } else if (geom.getMesh() instanceof Line) { ((Line) geom.getMesh()).updatePoints(start, ends[0]); } geom.updateModelBound(); }
batch.geometry.updateModelBound(); batches.add(batch);
geom.updateModelBound(); geomArray[index] = geom; index++;
protected void updateSubBatch(Geometry bg) { Batch batch = batchesByGeom.get(bg); if (batch != null) { Mesh mesh = batch.geometry.getMesh(); Mesh origMesh = bg.getMesh(); VertexBuffer pvb = mesh.getBuffer(VertexBuffer.Type.Position); VertexBuffer nvb = mesh.getBuffer(VertexBuffer.Type.Normal); VertexBuffer tvb = mesh.getBuffer(VertexBuffer.Type.Tangent); VertexBuffer opvb = origMesh.getBuffer(VertexBuffer.Type.Position); VertexBuffer onvb = origMesh.getBuffer(VertexBuffer.Type.Normal); VertexBuffer otvb = origMesh.getBuffer(VertexBuffer.Type.Tangent); FloatBuffer posBuf = getFloatBuffer(pvb); FloatBuffer normBuf = getFloatBuffer(nvb); FloatBuffer tanBuf = getFloatBuffer(tvb); FloatBuffer oposBuf = getFloatBuffer(opvb); FloatBuffer onormBuf = getFloatBuffer(onvb); FloatBuffer otanBuf = getFloatBuffer(otvb); Matrix4f transformMat = getTransformMatrix(bg); doTransforms(oposBuf, onormBuf, otanBuf, posBuf, normBuf, tanBuf, bg.startIndex, bg.startIndex + bg.getVertexCount(), transformMat); pvb.updateData(posBuf); if (nvb != null) { nvb.updateData(normBuf); } if (tvb != null) { tvb.updateData(tanBuf); } batch.geometry.updateModelBound(); } }
public void setParent(Node node) { for(int i = 0; i < geometries.size(); ++i) { Geometry geom = geometries.get(i); geom.setName(node.getName() + (i > 0 ? "-" + i : "")); geom.updateModelBound(); node.attachChild(geom); } }
private static Geometry createDebugShape(CollisionShape shape) { Geometry geom = new Geometry(); geom.setMesh(DebugShapeFactory.getDebugMesh(shape)); // geom.setLocalScale(shape.getScale()); geom.updateModelBound(); return geom; }
private static Geometry createDebugShape(CollisionShape shape) { Geometry geom = new Geometry(); geom.setMesh(DebugShapeFactory.getDebugMesh(shape)); // geom.setLocalScale(shape.getScale()); geom.updateModelBound(); return geom; }
private static Geometry createDebugShape(CollisionShape shape) { Geometry geom = new Geometry(); geom.setMesh(DebugShapeFactory.getDebugMesh(shape)); // geom.setLocalScale(shape.getScale()); geom.updateModelBound(); return geom; }
if(rootNode != null) { geom.setName(rootNode.getName() + "-mesh"); geom.updateModelBound(); rootNode.attachChild(geom); break;
public void setCurrentSequence(String name) { currentSequence = findSequence(name); currentIndex = 0; if (geometry.getMesh() == null) { geometry.setMesh(currentSequence[currentIndex]); geometry.setModelBound(new BoundingBox()); geometry.updateModelBound(); setModelBound(new BoundingBox()); updateModelBound(); } else if (currentSequence != null) { geometry.setMesh(currentSequence[currentIndex]); } else { System.err.println("Can't play animation " + name); return; } if (totalAnimationTime != 0) { animationFrameTime = totalAnimationTime / currentSequence.length; } }
batch.geometry.updateModelBound(); batch.geometry.updateWorldBound(); batch.needMeshUpdate = false;
protected void updateSubBatch(Geometry bg) { Batch batch = batchesByGeom.get(bg); if (batch != null) { Mesh mesh = batch.geometry.getMesh(); Mesh origMesh = bg.getMesh(); VertexBuffer pvb = mesh.getBuffer(VertexBuffer.Type.Position); VertexBuffer nvb = mesh.getBuffer(VertexBuffer.Type.Normal); VertexBuffer tvb = mesh.getBuffer(VertexBuffer.Type.Tangent); VertexBuffer opvb = origMesh.getBuffer(VertexBuffer.Type.Position); VertexBuffer onvb = origMesh.getBuffer(VertexBuffer.Type.Normal); VertexBuffer otvb = origMesh.getBuffer(VertexBuffer.Type.Tangent); FloatBuffer posBuf = getFloatBuffer(pvb); FloatBuffer normBuf = getFloatBuffer(nvb); FloatBuffer tanBuf = getFloatBuffer(tvb); FloatBuffer oposBuf = getFloatBuffer(opvb); FloatBuffer onormBuf = getFloatBuffer(onvb); FloatBuffer otanBuf = getFloatBuffer(otvb); Matrix4f transformMat = getTransformMatrix(bg); doTransforms(oposBuf, onormBuf, otanBuf, posBuf, normBuf, tanBuf, bg.startIndex, bg.startIndex + bg.getVertexCount(), transformMat); pvb.updateData(posBuf); if (nvb != null) { nvb.updateData(normBuf); } if (tvb != null) { tvb.updateData(tanBuf); } batch.geometry.updateModelBound(); } }
protected Node generatePointCloudGraphFrom(FloatBuffer pointCoordinates3d, FloatBuffer colorsRGBA, FloatBuffer sizes, float size) { Node result = new Node("Autogenerated Point Cloud Node"); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md"); mat.getAdditionalRenderState().setPointSprite(true); mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha); mat.setBoolean("PointSprite", true); mat.setFloat("Quadratic", size); Mesh m = new Mesh(); m.setMode(Mode.Points); m.setBuffer(VertexBuffer.Type.Position, 3, pointCoordinates3d); m.setBuffer(VertexBuffer.Type.Color, 4, colorsRGBA); m.setBuffer(VertexBuffer.Type.Size, 1, sizes); m.setStatic(); m.updateBound(); Geometry g = new Geometry("AutoGenerated Point Cloud", m); g.setShadowMode(ShadowMode.Off); g.setQueueBucket(Bucket.Transparent); g.setMaterial(mat); g.updateModelBound(); g.setCullHint(CullHint.Never); result.attachChild(g); result.updateModelBound(); return result; }