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

x33g5p2x  于2022-01-25 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(112)

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

Mesh.getMode介绍

[英]Returns the mesh mode
[中]返回网格模式

代码示例

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

if (geometry.getMesh().getMode() == Mode.Triangles) {// there is no need to flip the indexes for lines and points
  LOGGER.finer("Flipping index order in triangle mesh.");
  Buffer indexBuffer = geometry.getMesh().getBuffer(Type.Index).getData();

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

boolean useInstancing = count > 1 && caps.contains(Caps.MeshInstancing);
if (mesh.getMode() == Mode.Hybrid) {
  int[] modeStart = mesh.getModeStart();
  int[] elementLengths = mesh.getElementLengths();
    glext.glDrawElementsInstancedARB(convertElementMode(mesh.getMode()),
        indexBuf.getData().limit(),
        convertFormat(indexBuf.getFormat()),
        count);
  } else {
    gl.glDrawRangeElements(convertElementMode(mesh.getMode()),
        0,
        vertCount,

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

public BIHTree(Mesh mesh, int maxTrisPerNode) {
  this.mesh = mesh;
  this.maxTrisPerNode = maxTrisPerNode;
  if (maxTrisPerNode < 1) {
    throw new IllegalArgumentException("maxTrisPerNode cannot be less than 1");
  }
  if (mesh == null) {
    throw new IllegalArgumentException("Mesh cannot be null");
  }
  bihSwapTmp = new float[9];
  VertexBuffer vBuffer = mesh.getBuffer(Type.Position);
  if(vBuffer == null){
    throw new IllegalArgumentException("A mesh should at least contain a Position buffer");
  }        
  IndexBuffer ib = mesh.getIndexBuffer();
  FloatBuffer vb = (FloatBuffer) vBuffer.getData();
  
  if (ib == null) {
    ib = new VirtualIndexBuffer(mesh.getVertexCount(), mesh.getMode());
  } else if (mesh.getMode() != Mode.Triangles) {
    ib = new WrappedIndexBuffer(mesh);
  }
  numTris = ib.size() / 3;
  initTriList(vb, ib);
}

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

public WrappedIndexBuffer(Mesh mesh){
  super(mesh.getVertexCount(), mesh.getMode());
  this.ib = mesh.getIndexBuffer();
  switch (meshMode){
    case Points:
      numIndices = mesh.getTriangleCount();
      break;
    case Lines:
    case LineLoop:
    case LineStrip:
      numIndices = mesh.getTriangleCount() * 2;
      break;
    case Triangles:
    case TriangleStrip:
    case TriangleFan:
      numIndices = mesh.getTriangleCount() * 3;
      break;
    default:
      throw new UnsupportedOperationException();
  }
}

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

switch (mesh.getMode()) {
  case Triangles:
    vertices = processTriangles(mesh, index, v, t, splitMirrored);
  default:
    throw new UnsupportedOperationException(
        mesh.getMode() + " is not supported.");

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

/**
 * This type of collision shape is mesh-accurate and meant for immovable
 * "world objects". Examples include terrain, houses or whole shooter
 * levels.
 * <p>
 * Objects with "mesh" type collision shape will not collide with each
 * other.
 */
private static MeshCollisionShape createSingleMeshShape(Geometry geom, Spatial parent) {
  Mesh mesh = geom.getMesh();
  Transform trans = getTransform(geom, parent);
  if (mesh != null && mesh.getMode() == Mesh.Mode.Triangles) {
    MeshCollisionShape mColl = new MeshCollisionShape(mesh);
    mColl.setScale(trans.getScale());
    return mColl;
  } else {
    return null;
  }
}

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

/**
 * This type of collision shape is mesh-accurate and meant for immovable
 * "world objects". Examples include terrain, houses or whole shooter
 * levels.
 * <p>
 * Objects with "mesh" type collision shape will not collide with each
 * other.
 */
private static MeshCollisionShape createSingleMeshShape(Geometry geom, Spatial parent) {
  Mesh mesh = geom.getMesh();
  Transform trans = getTransform(geom, parent);
  if (mesh != null && mesh.getMode() == Mesh.Mode.Triangles) {
    MeshCollisionShape mColl = new MeshCollisionShape(mesh);
    mColl.setScale(trans.getScale());
    return mColl;
  } else {
    return null;
  }
}

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

private void startFaces(String count) throws SAXException {
  int numFaces = parseInt(count);
  int indicesPerFace = 0;
  switch (mesh.getMode()) {
    case Triangles:
      indicesPerFace = 3;
      break;
    case Lines:
      indicesPerFace = 2;
      break;
    case Points:
      indicesPerFace = 1;
      break;
    default:
      throw new SAXException("Strips or fans not supported!");
  }
  int numIndices = indicesPerFace * numFaces;
  vb = new VertexBuffer(VertexBuffer.Type.Index);
  if (!usesBigIndices) {
    sb = BufferUtils.createShortBuffer(numIndices);
    ib = null;
    vb.setupData(Usage.Static, indicesPerFace, Format.UnsignedShort, sb);
  } else {
    ib = BufferUtils.createIntBuffer(numIndices);
    sb = null;
    vb.setupData(Usage.Static, indicesPerFace, Format.UnsignedInt, ib);
  }
  mesh.setBuffer(vb);
}

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

public void renderMesh(Mesh mesh, int lod, int count, VertexBuffer[] instanceData) {
    if (mesh.getVertexCount() == 0 || mesh.getTriangleCount() == 0 || count == 0) {
      return;
    }

    if (count > 1 && !caps.contains(Caps.MeshInstancing)) {
      throw new RendererException("Mesh instancing is not supported by the video hardware");
    }

    if (mesh.getLineWidth() != 1f && context.lineWidth != mesh.getLineWidth()) {
      gl.glLineWidth(mesh.getLineWidth());
      context.lineWidth = mesh.getLineWidth();
    }

    if (gl4 != null && mesh.getMode().equals(Mode.Patch)) {
      gl4.glPatchParameter(mesh.getPatchVertexCount());
    }
    statistics.onMeshDrawn(mesh, lod, count);
//        if (ctxCaps.GL_ARB_vertex_array_object){
//            renderMeshVertexArray(mesh, lod, count);
//        }else{
    renderMeshDefault(mesh, lod, count, instanceData);
//        }
  }

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

private void pushFace(String v1, String v2, String v3) throws SAXException {
  // TODO: fan/strip support
  switch (mesh.getMode()) {
    case Triangles:
      pushIndex(parseInt(v1));
      pushIndex(parseInt(v2));
      pushIndex(parseInt(v3));
      break;
    case Lines:
      pushIndex(parseInt(v1));
      pushIndex(parseInt(v2));
      break;
    case Points:
      pushIndex(parseInt(v1));
      break;
  }
}

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

private void renderMeshVertexArray(Mesh mesh, int lod, int count, VertexBuffer instanceData) {
    if (mesh.getId() == -1) {
      updateVertexArray(mesh, instanceData);
    } else {
      // TODO: Check if it was updated
    }

    if (context.boundVertexArray != mesh.getId()) {
      gl3.glBindVertexArray(mesh.getId());
      context.boundVertexArray = mesh.getId();
    }

//        IntMap<VertexBuffer> buffers = mesh.getBuffers();
    VertexBuffer indices;
    if (mesh.getNumLodLevels() > 0) {
      indices = mesh.getLodLevel(lod);
    } else {
      indices = mesh.getBuffer(Type.Index);
    }
    if (indices != null) {
      drawTriangleList(indices, mesh, count);
    } else {
      drawTriangleArray(mesh.getMode(), count, mesh.getVertexCount());
    }
    clearVertexAttribs();
  }

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

public static void convertToList(Mesh mesh){
  IndexBuffer inBuf = mesh.getIndicesAsList();
  IndexBuffer outBuf = IndexBuffer.createIndexBuffer(mesh.getVertexCount(),
                            inBuf.size());
  for (int i = 0; i < inBuf.size(); i++){
    outBuf.put(i, inBuf.get(i));
  }
  mesh.clearBuffer(Type.Index);
  switch (mesh.getMode()){
    case LineLoop:
    case LineStrip:
      mesh.setMode(Mode.Lines);
      break;
    case TriangleStrip:
    case TriangleFan:
      mesh.setMode(Mode.Triangles);
      break;
    default:
      break;
  }
  if (outBuf instanceof IndexIntBuffer){
    mesh.setBuffer(Type.Index, 3, (IntBuffer)outBuf.getBuffer());
  }else{
    mesh.setBuffer(Type.Index, 3, (ShortBuffer)outBuf.getBuffer());
  }
}

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

drawTriangleList(indices, mesh, count);
} else {
  drawTriangleArray(mesh.getMode(), count, mesh.getVertexCount());

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

switch (geom.getMesh().getMode()) {
  case Points:
    listMode = Mesh.Mode.Points;

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

switch (geom.getMesh().getMode()) {
  case Points:
    listMode = Mode.Points;

代码示例来源:origin: info.projectkyoto/mms-engine

public BIHTree(Mesh mesh, int maxTrisPerNode) {
  this.mesh = mesh;
  this.maxTrisPerNode = maxTrisPerNode;
  if (maxTrisPerNode < 1 || mesh == null) {
    throw new IllegalArgumentException();
  }
  bihSwapTmp = new float[9];
  FloatBuffer vb = (FloatBuffer) mesh.getBuffer(Type.Position).getData();
  IndexBuffer ib = mesh.getIndexBuffer();
  if (ib == null) {
    ib = new VirtualIndexBuffer(mesh.getVertexCount(), mesh.getMode());
  } else if (mesh.getMode() != Mode.Triangles) {
    ib = new WrappedIndexBuffer(mesh);
  }
  numTris = ib.size() / 3;
  initTriList(vb, ib);
}

代码示例来源:origin: org.jmonkeyengine/jme3-bullet

/**
 * This type of collision shape is mesh-accurate and meant for immovable "world objects".
 * Examples include terrain, houses or whole shooter levels.<br>
 * Objects with "mesh" type collision shape will not collide with each other.
 */
private static MeshCollisionShape createSingleMeshShape(Geometry geom, Spatial parent) {
  Mesh mesh = geom.getMesh();
  Transform trans = getTransform(geom, parent);
  if (mesh != null && mesh.getMode() == Mesh.Mode.Triangles) {
    MeshCollisionShape mColl = new MeshCollisionShape(mesh);
    mColl.setScale(trans.getScale());
    return mColl;
  } else {
    return null;
  }
}

代码示例来源:origin: org.jmonkeyengine/jme3-plugins

private void pushFace(String v1, String v2, String v3) throws SAXException {
  // TODO: fan/strip support
  switch (mesh.getMode()) {
    case Triangles:
      pushIndex(parseInt(v1));
      pushIndex(parseInt(v2));
      pushIndex(parseInt(v3));
      break;
    case Lines:
      pushIndex(parseInt(v1));
      pushIndex(parseInt(v2));
      break;
    case Points:
      pushIndex(parseInt(v1));
      break;
  }
}

代码示例来源:origin: us.ihmc.thirdparty.jme/jme3-plugins

private void pushFace(String v1, String v2, String v3) throws SAXException {
  // TODO: fan/strip support
  switch (mesh.getMode()) {
    case Triangles:
      pushIndex(parseInt(v1));
      pushIndex(parseInt(v2));
      pushIndex(parseInt(v3));
      break;
    case Lines:
      pushIndex(parseInt(v1));
      pushIndex(parseInt(v2));
      break;
    case Points:
      pushIndex(parseInt(v1));
      break;
  }
}

代码示例来源:origin: info.projectkyoto/mms-engine

private void pushFace(String v1, String v2, String v3) throws SAXException {
  // TODO: fan/strip support
  switch (mesh.getMode()) {
    case Triangles:
      pushIndex(parseInt(v1));
      pushIndex(parseInt(v2));
      pushIndex(parseInt(v3));
      break;
    case Lines:
      pushIndex(parseInt(v1));
      pushIndex(parseInt(v2));
      break;
    case Points:
      pushIndex(parseInt(v1));
      break;
  }
}

相关文章