com.jme3.scene.Geometry.getMesh()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(197)

本文整理了Java中com.jme3.scene.Geometry.getMesh()方法的一些代码示例,展示了Geometry.getMesh()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Geometry.getMesh()方法的具体详情如下:
包路径:com.jme3.scene.Geometry
类名称:Geometry
方法名:getMesh

Geometry.getMesh介绍

[英]Returns the mesh to use for this geometry
[中]返回用于此几何体的网格

代码示例

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

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();
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

/**
 * 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();
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

/**
 * 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());
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

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;
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@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);
      }
    }
  }
});

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

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);
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

/**
 * 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);
  }
  
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

/**
 * 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);
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@Override
  public void visit(Geometry g) {
    for (Joint joint : armature.getJointList()) {
      if (g.getMesh().isAnimatedByJoint(armature.getJointIndex(joint))) {
        deformingJoints.add(joint);
      }
    }
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

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) {

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

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);
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

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);
  }     
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

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);
    }
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

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;
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

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);
    }
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

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);
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

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);
    }
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

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);
    }
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@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);
  }
});

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

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);
  }
}

相关文章