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(); }
/** * Construct a LodGenerator for the given geometry * * @param geom the geometry to consider to generate de Lods. */ public LodGenerator(Geometry geom) { mesh = geom.getMesh(); build(); }
/** * Applies the texture coordinates to the given geometry * if its DiffuseMap or ColorMap exists in the atlas. * @param geom The geometry to change the texture coordinate buffer on. * @return true if texture has been found and coords have been changed, false otherwise. */ public boolean applyCoords(Geometry geom) { return applyCoords(geom, 0, geom.getMesh()); }
@Override public void visit(Spatial spatial) { if (spatial instanceof Geometry) { Geometry geom = (Geometry) spatial; 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) { meshes.add(mesh); } } } });
private void endLevelOfDetail() { // set the lod data for each mesh for (Entry<List<VertexBuffer>> entry : lodLevels) { Mesh m = geoms.get(entry.getKey()).getMesh(); List<VertexBuffer> levels = entry.getValue(); VertexBuffer[] levelArray = new VertexBuffer[levels.size()]; levels.toArray(levelArray); m.setLodLevels(levelArray); } }
/** * If specified the geometry has an animated mesh, add its mesh and material * to the lists of animation targets. */ private void findTargets(Geometry geometry) { Mesh mesh = geometry.getMesh(); if (mesh != null && mesh.isAnimated()) { targets.add(geometry); } }
/** * If specified the geometry has an animated mesh, add its mesh and material * to the lists of animation targets. */ private void findTargets(Geometry geometry) { Mesh mesh = geometry.getMesh(); if (mesh != null && mesh.isAnimated()) { targets.add(geometry); } }
@Override public void visit(Geometry g) { for (Joint joint : armature.getJointList()) { if (g.getMesh().isAnimatedByJoint(armature.getJointIndex(joint))) { deformingJoints.add(joint); } } } }
private void initOpenCL2() { //bind vertex buffer to OpenCL VertexBuffer vb = geom.getMesh().getBuffer(VertexBuffer.Type.Position); buffer = clContext.bindVertexBuffer(vb, MemoryAccess.READ_WRITE).register(); ws = new com.jme3.opencl.Kernel.WorkSize(geom.getMesh().getVertexCount()); } private void updateOpenCL(float tpf) {
private void controlRenderSoftware() { resetToBind(); // reset morph meshes to bind pose offsetMatrices = armature.computeSkinningMatrices(); for (Geometry geometry : targets) { Mesh mesh = geometry.getMesh(); // NOTE: This assumes code higher up has // already ensured this mesh is animated. // Otherwise a crash will happen in skin update. softwareSkinUpdate(mesh, offsetMatrices); } }
private void controlRenderSoftware() { resetToBind(); // reset morph meshes to bind pose offsetMatrices = skeleton.computeSkinningMatrices(); for (Geometry geometry : targets) { Mesh mesh = geometry.getMesh(); // NOTE: This assumes code higher up has // already ensured this mesh is animated. // Otherwise a crash will happen in skin update. softwareSkinUpdate(mesh, offsetMatrices); } }
private void switchToSoftware() { numberOfJointsParam.setEnabled(false); jointMatricesParam.setEnabled(false); for (Geometry geometry : targets) { Mesh mesh = geometry.getMesh(); if (mesh != null && mesh.isAnimated()) { mesh.prepareForAnim(true); } } }
public Triangle getTriangle(Triangle store){ if (store == null) store = new Triangle(); Mesh m = geometry.getMesh(); m.getTriangle(triangleIndex, store); store.calculateCenter(); store.calculateNormal(); return store; }
private void switchToSoftware() { numberOfBonesParam.setEnabled(false); boneMatricesParam.setEnabled(false); for (Geometry geometry : targets) { Mesh mesh = geometry.getMesh(); if (mesh != null && mesh.isAnimated()) { mesh.prepareForAnim(true); } } }
public static void renderMeshFromGeometry(Renderer renderer, Geometry geom) { Mesh mesh = geom.getMesh(); int lodLevel = geom.getLodLevel(); if (geom instanceof InstancedGeometry) { InstancedGeometry instGeom = (InstancedGeometry) geom; renderer.renderMesh(mesh, lodLevel, instGeom.getActualNumInstances(), instGeom.getAllInstanceData()); } else { renderer.renderMesh(mesh, lodLevel, 1, null); } }
private void switchToHardware() { numberOfBonesParam.setEnabled(true); boneMatricesParam.setEnabled(true); // Next full 10 bones (e.g. 30 on 24 bones) int numBones = ((skeleton.getBoneCount() / 10) + 1) * 10; numberOfBonesParam.setValue(numBones); for (Geometry geometry : targets) { Mesh mesh = geometry.getMesh(); if (mesh != null && mesh.isAnimated()) { mesh.prepareForAnim(false); } } }
private void switchToHardware() { numberOfJointsParam.setEnabled(true); jointMatricesParam.setEnabled(true); // Next full 10 bones (e.g. 30 on 24 bones) int numBones = ((armature.getJointCount() / 10) + 1) * 10; numberOfJointsParam.setValue(numBones); for (Geometry geometry : targets) { Mesh mesh = geometry.getMesh(); if (mesh != null && mesh.isAnimated()) { mesh.prepareForAnim(false); } } }
@Override public void visit(Geometry g) { Mesh m = g.getMesh(); Geometry debug = new Geometry( "debug tangents geom", TangentBinormalGenerator.genNormalLines(m, 0.1f) ); debug.setMaterial(debugMat); debug.setCullHint(Spatial.CullHint.Never); debug.setLocalTransform(g.getWorldTransform()); debugTangents.attachChild(debug); } });
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); } }