private int computeNbTri() { int nbTri = 0; for (Geometry geometry : listGeoms) { if (geometry.getMesh().getNumLodLevels() > 0) { nbTri += geometry.getMesh().getLodLevel(lodLevel).getNumElements(); } else { nbTri += geometry.getMesh().getTriangleCount(); } } return nbTri; }
public void displayNonDeformingJoint(boolean display) { joints.getChild(0).setCullHint(display ? CullHint.Dynamic : CullHint.Always); outlines.getChild(0).setCullHint(display ? CullHint.Dynamic : CullHint.Always); wires.getChild(0).setCullHint(display ? CullHint.Dynamic : CullHint.Always); ((Node) outlines.getChild(1)).getChild(0).setCullHint(display ? CullHint.Dynamic : CullHint.Always); ((Node) wires.getChild(1)).getChild(0).setCullHint(display ? CullHint.Dynamic : CullHint.Always); }
@Override protected void setParent(Node parent) { super.setParent(parent); // If the geometry is managed by group node we need to unassociate. if (parent == null && isGrouped()) { unassociateFromGroupNode(); } }
@Test public void testOverrides_RemoveAfterAttach() { Node scene = createDummyScene(); scene.updateGeometricState(); Node root = new Node("Root Node"); root.updateGeometricState(); scene.getChild("A").addMatParamOverride(mpoInt("val", 5)); root.attachChild(scene); validateScene(root); scene.getChild("A").clearMatParamOverrides(); validateScene(root); }
@Override public void update(float tpf) { if (spatial == null) { throw new IllegalArgumentException("The spatial to follow is null, please use the setTarget method"); } target.setLocalTranslation(spatial.getWorldTranslation()); camNode.lookAt(target.getWorldTranslation(), upVector); target.updateLogicalState(tpf); target.updateGeometricState(); }
/** * Access whichever spatial translation corresponds to the physics location. * * @return the pre-existing location vector (in physics-space coordinates, * not null) */ protected Vector3f getSpatialTranslation() { if (applyLocal) { return spatial.getLocalTranslation(); } return spatial.getWorldTranslation(); }
@Test public void testOverrides_IdenticalNames() { Node scene = createDummyScene(); scene.getChild("A").addMatParamOverride(mpoInt("val", 5)); scene.getChild("C").addMatParamOverride(mpoInt("val", 7)); validateScene(scene); }
/** * Updates the bounding volume of the mesh. Should be called when the * mesh has been modified. */ public void updateModelBound() { mesh.updateBound(); setBoundRefresh(); }
/** * Creates a MotionPath for the given spatial on the given motion path. * @param spatial * @param path */ public MotionEvent(Spatial spatial, MotionPath path) { super(); spatial.addControl(this); this.path = path; }
/** * disable the display of the path and the waypoints */ public void disableDebugShape() { debugNode.detachAllChildren(); debugNode = null; assetManager = null; }
@Override protected void updateWorldTransforms() { super.updateWorldTransforms(); computeWorldMatrix(); if (isGrouped()) { groupNode.onTransformChange(this); } // geometry requires lights to be sorted worldLights.sort(true); }
@Override public boolean checkCulling(Camera cam) { if (isGrouped()) { setLastFrustumIntersection(Camera.FrustumIntersect.Outside); return false; } return super.checkCulling(cam); }
@Override public Spatial detachChildAt(int index) { Spatial s = super.detachChildAt(index); if (s instanceof Node) { unbatchSubGraph(s); } return s; }
/** * Sets the material to use for this geometry. * * @param material the material to use for this geometry */ @Override public void setMaterial(Material material) { this.material = material; nbSimultaneousGPUMorph = -1; if (isGrouped()) { groupNode.onMaterialChange(this); } }
@Test public void testOverrides_AddAfterAttach() { Node scene = createDummyScene(); scene.updateGeometricState(); Node root = new Node("Root Node"); root.updateGeometricState(); root.attachChild(scene); scene.getChild("A").addMatParamOverride(mpoInt("val", 5)); validateScene(root); }
/** * Creates a MotionPath for the given spatial on the given motion path. * @param spatial * @param path */ public MotionEvent(Spatial spatial, MotionPath path, LoopMode loopMode) { super(); spatial.addControl(this); this.path = path; this.loopMode = loopMode; }
@Test public void testOverrides_AddBeforeAttach() { Node scene = createDummyScene(); scene.getChild("A").addMatParamOverride(mpoInt("val", 5)); scene.updateGeometricState(); Node root = new Node("Root Node"); root.updateGeometricState(); root.attachChild(scene); validateScene(root); }
@Test public void testOverrides_RemoveBeforeAttach() { Node scene = createDummyScene(); scene.updateGeometricState(); Node root = new Node("Root Node"); root.updateGeometricState(); scene.getChild("A").addMatParamOverride(mpoInt("val", 5)); validateScene(scene); scene.getChild("A").clearMatParamOverrides(); validateScene(scene); root.attachChild(scene); validateScene(root); }