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

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

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

Mesh.setMode介绍

[英]Change the Mesh's mode. By default the mode is Mode#Triangles.
[中]更改网格的模式。默认情况下,模式为模式#三角形。

代码示例

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

protected final void createMesh() {
  if( mesh == null ) {
    mesh = new Mesh();
    mesh.setMode(Mesh.Mode.Lines);
  }
  
  mesh.setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(size * 4 * 3));
  
  FloatBuffer cb = BufferUtils.createFloatBuffer(size * 4 * 4);
  for( int i = 0; i < size; i++ ) {
    // For each index we add 4 colors, one for each line
    // endpoint for two layers.
    cb.put(0.5f).put(0.5f).put(0).put(1);
    cb.put(1).put(1).put(0).put(1);
    cb.put(0).put(0.5f).put(0.5f).put(1);
    cb.put(0).put(1).put(1).put(1);
  }         
  mesh.setBuffer(Type.Color, 4, cb);
}

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

private Mesh createTriangleStripMesh() {
  Mesh strip = new Mesh();
  strip.setMode(Mode.TriangleStrip);
  FloatBuffer vb = BufferUtils.createFloatBuffer(3*3*3); // 3 rows * 3 columns * 3 floats
  vb.rewind();
  vb.put(new float[]{0,2,0}); vb.put(new float[]{1,2,0}); vb.put(new float[]{2,2,0});
  vb.put(new float[]{0,1,0}); vb.put(new float[]{1,1,0}); vb.put(new float[]{2,1,0});
  vb.put(new float[]{0,0,0}); vb.put(new float[]{1,0,0}); vb.put(new float[]{2,0,0});
  FloatBuffer nb = BufferUtils.createFloatBuffer(3*3*3);
  nb.rewind();
  nb.put(new float[]{0,0,1}); nb.put(new float[]{0,0,1}); nb.put(new float[]{0,0,1});
  nb.put(new float[]{0,0,1}); nb.put(new float[]{0,0,1}); nb.put(new float[]{0,0,1});
  nb.put(new float[]{0,0,1}); nb.put(new float[]{0,0,1}); nb.put(new float[]{0,0,1});
  FloatBuffer tb = BufferUtils.createFloatBuffer(3*3*2);
  tb.rewind();
  tb.put(new float[]{0,0}); tb.put(new float[]{0.5f,0}); tb.put(new float[]{1,0});
  tb.put(new float[]{0,0.5f}); tb.put(new float[]{0.5f,0.5f}); tb.put(new float[]{1,0.5f});
  tb.put(new float[]{0,1}); tb.put(new float[]{0.5f,1}); tb.put(new float[]{1,1});
  int[] indexes = new int[]{0,3,1,4,2,5, 5,3, 3,6,4,7,5,8};
  IntBuffer ib = BufferUtils.createIntBuffer(indexes.length);
  ib.put(indexes);
  strip.setBuffer(Type.Position, 3, vb);
  strip.setBuffer(Type.Normal, 3, nb);
  strip.setBuffer(Type.TexCoord, 2, tb);
  strip.setBuffer(Type.Index, 3, ib);
  strip.updateBound();
  return strip;
}

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

private void startSubMesh(String matName, String usesharedvertices, String use32bitIndices, String opType) throws SAXException {
  mesh = new Mesh();
  if (opType == null || opType.equals("triangle_list")) {
    mesh.setMode(Mesh.Mode.Triangles);
    mesh.setMode(Mesh.Mode.Lines);
  } else {
    throw new SAXException("Unsupported operation type: " + opType);

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

protected Mesh constructMesh(ArrayList<Face> faceList){
  Mesh m = new Mesh();
  m.setMode(Mode.Triangles);

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

private List<Geometry> createGeometries() throws IOException {
  Mesh mesh = new Mesh();
  mesh.setMode(Mode.Triangles);

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

mesh.setMode(Mode.LineStrip);
if (meshBuffers.isShortIndexBuffer()) {
  mesh.setBuffer(Type.Index, 1, (ShortBuffer) meshBuffers.getIndexBuffer());

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

jmeMesh.setMode(Mesh.Mode.Triangles);

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

private static void initGeom(Mesh m, Vector3f[] points) {
  if (points != null)
    m.setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(points));
  m.setBuffer(Type.Index, 2,
      new short[]{
          0, 1,
          1, 2,
          2, 3,
          3, 0,
          4, 5,
          5, 6,
          6, 7,
          7, 4,
          0, 4,
          1, 5,
          2, 6,
          3, 7,
      }
  );
  m.getBuffer(Type.Index).setUsage(Usage.Static);
  m.setMode(Mode.Lines);
}

代码示例来源: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

pointsMesh.setMode(Mode.Points);
pointsMesh.setPointSize(blenderContext.getBlenderKey().getPointsSize());
if (pointBuffers.isShortIndexBuffer()) {

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

Mesh mesh = new Mesh();
Integer mode = getAsInteger(meshObject, "mode");
mesh.setMode(getMeshMode(mode));
Integer indices = getAsInteger(meshObject, "indices");
if (indices != null) {

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

lineMesh.setMode(Mesh.Mode.Lines);

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

@Override
public void simpleInitApp() {
  Mesh mesh = new Mesh();
  mesh.setBuffer(VertexBuffer.Type.Index, 1, BufferUtils.createIntBuffer(new int[]{1}));
  mesh.setBuffer(VertexBuffer.Type.Position, 3, BufferUtils.createFloatBuffer(new float[]{0, 0, 0}));
  mesh.setMode(Mesh.Mode.Points);
  mesh.setBound(new BoundingBox(new Vector3f(0, 0, 0), 10, 10, 10));
  mesh.updateCounts();
  Geometry geometry = new Geometry("Test", mesh);
  geometry.updateGeometricState();
  geometry.setMaterial(new Material(assetManager, "Materials/Geom/SimpleGeom.j3md"));
  //geometry.getMaterial().getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off);
  //geometry.setMaterial(assetManager.loadMaterial("Materials/Geom/SimpleTess.j3md"));
  rootNode.attachChild(geometry);
  Geometry geometry1 = new Geometry("T1", new Sphere(10, 10, 1));
  geometry1.setMaterial(new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"));
  rootNode.attachChild(geometry1);
}

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

/**
 * Attach a pair of parallel white lines in the z=1 plane.
 */
void createWhiteLines() {
  Mesh lineMesh = new Mesh();
  lineMesh.setMode(Mesh.Mode.Lines);
  float[] corners = new float[]{
    -1f, -1f, 0f,
    -1f, 1f, 0f,
    1f, 1f, 0f,
    1f, -1f, 0f
  };
  lineMesh.setBuffer(VertexBuffer.Type.Position, 3, corners);
  short[] indices = new short[]{0, 1, 2, 3};
  lineMesh.setBuffer(VertexBuffer.Type.Index, 2, indices);
  lineMesh.updateBound();
  Geometry whiteLines = new Geometry("white lines", lineMesh);
  Material white = assetManager.loadMaterial("Common/Materials/WhiteColor.j3m");
  whiteLines.setMaterial(white);
  whiteLines.move(0f, 0f, 1f);
  rootNode.attachChild(whiteLines);
}

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

lineMesh.setMode(Mesh.Mode.Lines);

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

public Mesh createMesh(Vector3f scale, Vector2f tcScale, Vector2f tcOffset, float offsetAmount, int totalSize, boolean center, int lod, boolean rightLod, boolean topLod, boolean leftLod, boolean bottomLod) {
  FloatBuffer pb = writeVertexArray(null, scale, center);
  FloatBuffer texb = writeTexCoordArray(null, tcOffset, tcScale, offsetAmount, totalSize);
  FloatBuffer nb = writeNormalArray(null, scale);
  Buffer ib;
  IndexBuffer idxB = writeIndexArrayLodDiff(lod, rightLod, topLod, leftLod, bottomLod, totalSize);
  if (idxB.getBuffer() instanceof IntBuffer)
    ib = (IntBuffer)idxB.getBuffer();
  else
    ib = (ShortBuffer)idxB.getBuffer();
  FloatBuffer bb = BufferUtils.createFloatBuffer(getWidth() * getHeight() * 3);
  FloatBuffer tanb = BufferUtils.createFloatBuffer(getWidth() * getHeight() * 3);
  writeTangentArray(nb, tanb, bb, texb, scale);
  Mesh m = new Mesh();
  m.setMode(Mode.TriangleStrip);
  m.setBuffer(Type.Position, 3, pb);
  m.setBuffer(Type.Normal, 3, nb);
  m.setBuffer(Type.Tangent, 3, tanb);
  m.setBuffer(Type.Binormal, 3, bb);
  m.setBuffer(Type.TexCoord, 2, texb);
  if (ib instanceof IntBuffer)
    m.setBuffer(Type.Index, 3, (IntBuffer)ib);
  else if (ib instanceof ShortBuffer)
    m.setBuffer(Type.Index, 3, (ShortBuffer)ib);
  m.setStatic();
  m.updateBound();
  return m;
}

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

outMesh.setMode(mode);

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

outMesh.setMode(mode);
if (totalVerts >= 65536) {

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

protected final void createMesh() {
  if( mesh == null ) {
    mesh = new Mesh();
    mesh.setMode(Mesh.Mode.Lines);
  }
  
  mesh.setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(size * 4 * 3));
  
  FloatBuffer cb = BufferUtils.createFloatBuffer(size * 4 * 4);
  for( int i = 0; i < size; i++ ) {
    // For each index we add 4 colors, one for each line
    // endpoint for two layers.
    cb.put(0.5f).put(0.5f).put(0).put(1);
    cb.put(1).put(1).put(0).put(1);
    cb.put(0).put(0.5f).put(0.5f).put(1);
    cb.put(0).put(1).put(1).put(1);
  }         
  mesh.setBuffer(Type.Color, 4, cb);
}

代码示例来源:origin: us.ihmc/SensorProcessing

protected Node generatePointCloudGraphFrom(FloatBuffer pointCoordinates3d, FloatBuffer colorsRGBA, FloatBuffer sizes, float size)
{
 Node result = new Node("Autogenerated Point Cloud Node");
 Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
 mat.getAdditionalRenderState().setPointSprite(true);
 mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
 mat.setBoolean("PointSprite", true);
 mat.setFloat("Quadratic", size);
 Mesh m = new Mesh();
 m.setMode(Mode.Points);
 m.setBuffer(VertexBuffer.Type.Position, 3, pointCoordinates3d);
 m.setBuffer(VertexBuffer.Type.Color, 4, colorsRGBA);
 m.setBuffer(VertexBuffer.Type.Size, 1, sizes);
 m.setStatic();
 m.updateBound();
 Geometry g = new Geometry("AutoGenerated Point Cloud", m);
 g.setShadowMode(ShadowMode.Off);
 g.setQueueBucket(Bucket.Transparent);
 g.setMaterial(mat);
 g.updateModelBound();
 g.setCullHint(CullHint.Never);
 result.attachChild(g);
 result.updateModelBound();
 return result;
}

相关文章