public String getActionName() { return geom.getName() + "Reload"; }
public void collide(Bone bone, PhysicsCollisionObject object, PhysicsCollisionEvent event) { if (object.getUserObject() != null && object.getUserObject() instanceof Geometry) { Geometry geom = (Geometry) object.getUserObject(); if ("Floor".equals(geom.getName())) { return; } } ragdoll.setRagdollMode(); }
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()); } }
if (!g.isGrouped() || rebatch) { if (g.getMaterial() == null) { throw new IllegalStateException("No material is set for Geometry: " + g.getName() + " please set a material before batching");
@Override public Node clone(boolean cloneMaterials) { BatchNode clone = (BatchNode) super.clone(cloneMaterials); if (batches.size() > 0) { for (Batch b : batches) { for (int i = 0; i < clone.children.size(); i++) { if (clone.children.get(i).getName().equals(b.geometry.getName())) { clone.children.remove(i); break; } } } clone.needsFullRebatch = true; clone.batches = new SafeArrayList<Batch>(Batch.class); clone.batchesByGeom = new HashMap<Geometry, Batch>(); clone.batch(); } return clone; }
/** * <code>updateWorldBound</code> updates the bounding volume that contains * this geometry. The location of the geometry is based on the location of * all this node's parents. * * @see Spatial#updateWorldBound() */ @Override protected void updateWorldBound() { super.updateWorldBound(); if (mesh == null) { throw new NullPointerException("Geometry: " + getName() + " has null mesh"); } if (mesh.getBound() != null) { if (ignoreTransform) { // we do not transform the model bound by the world transform, // just use the model bound as-is worldBound = mesh.getBound().clone(worldBound); } else { worldBound = mesh.getBound().transform(worldTransform, worldBound); } } }
&& mesh.getFloatBuffer(Type.Normal) == null){ logger.log(Level.WARNING, "OBJ mesh {0} doesn't contain normals! " + "It might not display correctly", geom.getName());
private void renderSubScene(Spatial scene, ViewPort vp) { // check culling first. if (!scene.checkCulling(vp.getCamera())) { return; } scene.runControlRender(this, vp); if (scene instanceof Node) { // Recurse for all children Node n = (Node) scene; List<Spatial> children = n.getChildren(); // Saving cam state for culling int camState = vp.getCamera().getPlaneState(); for (int i = 0; i < children.size(); i++) { // Restoring cam state before proceeding children recursively vp.getCamera().setPlaneState(camState); renderSubScene(children.get(i), vp); } } else if (scene instanceof Geometry) { // add to the render queue Geometry gm = (Geometry) scene; if (gm.getMaterial() == null) { throw new IllegalStateException("No material is set for Geometry: " + gm.getName()); } vp.getQueue().addToQueue(gm, scene.getQueueBucket()); } }
if (batch != null) { list.add(0, batch.geometry); batchName = batch.geometry.getName(); batch.geometry.removeFromParent(); } else {
/** * Cast a ray at the geometries and report all collisions. */ void castRay() { CollisionResults results = new CollisionResults(); rootNode.collideWith(ray, results); int numResults = results.size(); for (int resultI = 0; resultI < numResults; resultI++) { CollisionResult result = results.getCollision(resultI); Geometry geometry = result.getGeometry(); String name = geometry.getName(); if (name.equals("white lines")) { assert false; // phantom triangle } } }
throw new IllegalStateException("No material is set for Geometry: " + gm.getName());
private void createDebugTangents(Geometry geom) { Geometry debug = new Geometry( "Debug " + geom.getName(), TangentBinormalGenerator.genTbnLines(geom.getMesh(), 0.8f) ); Material debugMat = assetManager.loadMaterial("Common/Materials/VertexColor.j3m"); debug.setMaterial(debugMat); debug.setCullHint(Spatial.CullHint.Never); debug.getLocalTranslation().set(geom.getWorldTranslation()); debugNode.attachChild(debug); } }
String hit = results.getCollision(i).getGeometry().getName(); System.out.println("* Collision #" + i); System.out.println(" You shot " + hit + " at " + pt + ", " + dist + " wu away.");
throw new IllegalArgumentException("Geometry " + geom.getName() + " has no " + outBuf.getBufferType() + " buffer whereas other geoms have. all geometries should have the same types of buffers.\n Try to use GeometryBatchFactory.alignBuffer() on the BatchNode before batching"); } else if (outBuf == null) { throw new IllegalArgumentException("Geometry " + geom.getName() + " has a " + outBuf.getBufferType() + " buffer whereas other geoms don't. all geometries should have the same types of buffers.\n Try to use GeometryBatchFactory.alignBuffer() on the BatchNode before batching"); } else { inBuf.copyElements(0, outBuf, globalVertIndex, geomVertCount);
public String getActionName() { return geom.getName() + "Reload"; }
private static Map<String, List<Geometry>> packByName(List<Geometry> geometries) { // geom name is NAME+INDEX, this group geometries by name Map<String, List<Geometry>> res = new HashMap<String, List<Geometry>>(); for (Geometry geometry : geometries) { String name = getNamePart(geometry.getName()); List<Geometry> list = res.get(name); if (list == null) res.put(name, list = new LinkedList<Geometry>()); list.add(geometry); } return res; }
protected BatchedGeometry(GeometryBatch batch, Geometry geom) { this.batch = batch; vertexCount = geom.getVertexCount(); triangleCount = geom.getTriangleCount(); name = geom.getName(); }
private void dumpGeometry(Geometry geometry) { System.out.println("Geometry " + geometry.getName()); Material mat = geometry.getMaterial(); if (mat != null) { for (MatParam matParam : mat.getParams()) { System.out.println(matParam.getName() + " = " + matParam.getValue()); } } } }