protected TemporalMesh getTemporalMesh(Node node) { List<Spatial> children = node.getChildren(); if (children != null && children.size() == 1 && children.get(0) instanceof TemporalMesh) { return (TemporalMesh) children.get(0); } return null; } }
public static void gatherGeoms(Spatial scene, List<Geometry> geoms) { if (scene instanceof Node) { Node node = (Node) scene; for (Spatial child : node.getChildren()) { gatherGeoms(child, geoms); } } else if (scene instanceof Geometry) { geoms.add((Geometry) scene); } }
private void findGeoms(Node node, List<Geometry> geoms) { for (Spatial spatial : node.getChildren()) { if (spatial instanceof Geometry) { geoms.add((Geometry) spatial); } else if (spatial instanceof Node) { findGeoms((Node) spatial, geoms); } } }
public static void dump( String indent, Node n ) { System.out.println(indent + objectToString(n)); dumpSpatialProperties(indent + " ", n); if( !n.getChildren().isEmpty() ) { System.out.println(indent + " children:"); for( Spatial s : n.getChildren() ) { dump(indent + " ", s); } } }
private void findTargets(Node node) { for (Spatial child : node.getChildren()) { if (child instanceof Geometry) { findTargets((Geometry) child); } else if (child instanceof Node) { findTargets((Node) child); } } }
private void findTargets(Node node) { for (Spatial child : node.getChildren()) { if (child instanceof Geometry) { findTargets((Geometry) child); } else if (child instanceof Node) { findTargets((Node) child); } } }
private DirectionalLight findLight(Node node) { for (Light light : node.getWorldLightList()) { if (light instanceof DirectionalLight) { return (DirectionalLight) light; } } for (Spatial child : node.getChildren()) { if (child instanceof Node) { return findLight((Node) child); } } return null; }
private <T extends Control> T findControl(Spatial s, Class<T> controlClass) { T ctrl = s.getControl(controlClass); if (ctrl != null) { return ctrl; } if (s instanceof Node) { Node n = (Node) s; for (Spatial spatial : n.getChildren()) { ctrl = findControl(spatial, controlClass); if (ctrl != null) { return ctrl; } } } return null; }
private void stopAnim(Spatial s) { AnimComposer control = s.getControl(AnimComposer.class); if (control != null) { control.reset(); } if (s instanceof Node) { Node n = (Node) s; for (Spatial spatial : n.getChildren()) { stopAnim(spatial); } } }
private void ungroupSceneGraph(Spatial s) { if (s instanceof Node) { for (Spatial sp : ((Node) s).getChildren()) { ungroupSceneGraph(sp); } } else if (s instanceof Geometry) { Geometry g = (Geometry) s; if (g.isGrouped()) { // Will invoke onGeometryUnassociated automatically. g.unassociateFromGroupNode(); if (InstancedNode.getGeometryStartIndex(g) != -1) { throw new AssertionError(); } } } }
/** * recursively visit the subgraph and unbatch geometries * * @param s */ private void unbatchSubGraph(Spatial s) { if (s instanceof Node) { for (Spatial sp : ((Node) s).getChildren()) { unbatchSubGraph(sp); } } else if (s instanceof Geometry) { Geometry g = (Geometry) s; if (g.isGrouped()) { g.unassociateFromGroupNode(); } } }
/** * Will reload the spatial's materials whenever the trigger is fired * @param trigger the trigger * @param spat the spatial to reload */ public void registerBinding(Trigger trigger, final Spatial spat) { if(spat instanceof Geometry){ GeometryBinding binding = new GeometryBinding(trigger, (Geometry)spat); bindings.add(binding); if (isInitialized()) { bind(binding); } }else if (spat instanceof Node){ for (Spatial child : ((Node)spat).getChildren()) { registerBinding(trigger, child); } } }
public static void generate(Spatial s){ if(s instanceof Node){ Node n = (Node)s; for (Spatial child : n.getChildren()) { generate(child); } } else if (s instanceof Geometry){ Geometry g = (Geometry)s; MikkTSpaceImpl context = new MikkTSpaceImpl(g.getMesh()); if(!genTangSpaceDefault(context)){ Logger.getLogger(MikktspaceTangentGenerator.class.getName()).log(Level.SEVERE, "Failed to generate tangents for geometry " + g.getName()); } TangentUtils.generateBindPoseTangentsIfNecessary(g.getMesh()); } }
private void dumpScene(Spatial s, int indent) { System.err.println(indentString.substring(0, indent) + s.getName() + " (" + s.getClass().getSimpleName() + ") / " + s.getLocalTransform().getTranslation().toString() + ", " + s.getLocalTransform().getRotation().toString() + ", " + s.getLocalTransform().getScale().toString()); if (s instanceof Node) { Node n = (Node) s; for (Spatial spatial : n.getChildren()) { dumpScene(spatial, indent + 1); } } } }
private void instance(Spatial n) { if (n instanceof Geometry) { Geometry g = (Geometry) n; if (!g.isGrouped() && g.getBatchHint() != BatchHint.Never) { addToInstancedGeometry(g); } } else if (n instanceof Node) { for (Spatial child : ((Node) n).getChildren()) { if (child instanceof GeometryGroupNode) { continue; } instance(child); } } }
private void updateMarkerElevations() { for (Spatial s : markers.getChildren()) { float h = terrain.getHeight(new Vector2f(s.getLocalTranslation().x, s.getLocalTranslation().z)); s.setLocalTranslation(s.getLocalTranslation().x, h+1, s.getLocalTranslation().z); } }
public static void generate(Spatial scene, boolean splitMirrored) { if (scene instanceof Node) { Node node = (Node) scene; for (Spatial child : node.getChildren()) { generate(child, splitMirrored); } } else { Geometry geom = (Geometry) scene; Mesh mesh = geom.getMesh(); // Check to ensure mesh has texcoords and normals before generating if (mesh.getBuffer(Type.TexCoord) != null && mesh.getBuffer(Type.Normal) != null){ generate(geom.getMesh(),true, splitMirrored); } } }
@Override public void simpleInitApp() { BulletAppState bulletAppState = new BulletAppState(); stateManager.attach(bulletAppState); String sinbadPath = "Models/Sinbad/SinbadOldAnim.j3o"; Node sinbad = (Node) assetManager.loadModel(sinbadPath); Node extender = new Node(); for (Spatial child : sinbad.getChildren()) { extender.attachChild(child); } sinbad.attachChild(extender); //Note: PhysicsRagdollControl is still a WIP, constructor will change KinematicRagdollControl ragdoll = new KinematicRagdollControl(0.5f); sinbad.addControl(ragdoll); stop(); } }
private void dumpScene(Spatial s, int indent) { System.err.println(indentString.substring(0, indent) + s.getName() + " (" + s.getClass().getSimpleName() + ") / " + s.getLocalTransform().getTranslation().toString() + ", " + s.getLocalTransform().getRotation().toString() + ", " + s.getLocalTransform().getScale().toString()); if (s instanceof Node) { Node n = (Node) s; for (Spatial spatial : n.getChildren()) { dumpScene(spatial, indent + 1); } } } }
private void reset() { // Reset the pickups for(Spatial pickUp : pickUps.getChildren()) { GhostControl pickUpControl = pickUp.getControl(GhostControl.class); if(pickUpControl != null) { pickUpControl.setEnabled(true); } pickUp.setLocalScale(1.0f); } // Reset the player player.setPhysicsLocation(PLAYER_START.clone()); player.setAngularVelocity(Vector3f.ZERO.clone()); player.setLinearVelocity(Vector3f.ZERO.clone()); // Reset the score score = 0; // Reset the message messageText.setLocalScale(0.0f); }