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

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

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

Mesh.getTriangle介绍

[英]Gets the triangle vertex positions at the given triangle index and stores them into the Triangle argument. Also sets the triangle index to the index argument.
[中]获取给定三角形索引处的三角形顶点位置,并将其存储到三角形参数中。还将三角形索引设置为index参数。

代码示例

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

@Override
public void setMeshes(List<Mesh> meshes) {
  this.vertices = new ArrayList<List<Vector3f>>(meshes.size());
  this.normals = new ArrayList<List<Vector3f>>(meshes.size());
  for (Mesh mesh : meshes) {
    Vector3f[] vertexTable = BufferUtils.getVector3Array(mesh.getFloatBuffer(Type.Position));
    int[] indices = new int[3];
    List<Vector3f> vertices = new ArrayList<Vector3f>(mesh.getTriangleCount() * 3);
    List<Vector3f> normals = new ArrayList<Vector3f>(mesh.getTriangleCount());
    for (int i = 0; i < mesh.getTriangleCount(); ++i) {
      mesh.getTriangle(i, indices);
      vertices.add(vertexTable[indices[0]]);
      vertices.add(vertexTable[indices[1]]);
      vertices.add(vertexTable[indices[2]]);
      normals.add(FastMath.computeNormal(vertexTable[indices[0]], vertexTable[indices[1]], vertexTable[indices[2]]));
    }
    this.vertices.add(vertices);
    this.normals.add(normals);
  }
}

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

int[] indices = new int[3];
for (int i = 0; i < mesh.getTriangleCount(); ++i) {
  mesh.getTriangle(i, indices);
  triangleTextureElements.add(new TriangleTextureElement(i, boundingBox, this, uvsArray, indices, blenderContext));

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

/**
 * Gets the triangle vertex positions at the given triangle index
 * and stores them into the {@link Triangle} argument.
 * Also sets the triangle index to the <code>index</code> argument.
 *
 * @param index The index of the triangle.
 * Should be between 0 and {@link #getTriangleCount()}.
 *
 * @param tri The triangle to store the positions in
 */
public void getTriangle(int index, Triangle tri){
  getTriangle(index, tri.get1(), tri.get2(), tri.get3());
  tri.setIndex(index);
  tri.setNormal(null);
}

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

@Override
public void setMeshes(List<Mesh> meshes) {
  this.vertices = new ArrayList<List<Vector3f>>(meshes.size());
  this.normals = new ArrayList<List<Vector3f>>(meshes.size());
  for (Mesh mesh : meshes) {
    Vector3f[] vertexTable = BufferUtils.getVector3Array(mesh.getFloatBuffer(Type.Position));
    int[] indices = new int[3];
    List<Vector3f> vertices = new ArrayList<Vector3f>(mesh.getTriangleCount() * 3);
    List<Vector3f> normals = new ArrayList<Vector3f>(mesh.getTriangleCount());
    for (int i = 0; i < mesh.getTriangleCount(); ++i) {
      mesh.getTriangle(i, indices);
      vertices.add(vertexTable[indices[0]]);
      vertices.add(vertexTable[indices[1]]);
      vertices.add(vertexTable[indices[2]]);
      normals.add(FastMath.computeNormal(vertexTable[indices[0]], vertexTable[indices[1]], vertexTable[indices[2]]));
    }
    this.vertices.add(vertices);
    this.normals.add(normals);
  }
}

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

public void computeFromTris(int[] indices, Mesh mesh, int start, int end) {
  if (end - start <= 0) {
    return;
  }
  TempVars vars = TempVars.get();
  Vector3f vect1 = vars.vect1;
  Vector3f vect2 = vars.vect2;
  Triangle triangle = vars.triangle;
  Vector3f min = vect1.set(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY);
  Vector3f max = vect2.set(Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY);
  Vector3f point;
  for (int i = start; i < end; i++) {
    mesh.getTriangle(indices[i], triangle);
    point = triangle.get(0);
    checkMinMax(min, max, point);
    point = triangle.get(1);
    checkMinMax(min, max, point);
    point = triangle.get(2);
    checkMinMax(min, max, point);
  }
  center.set(min.addLocal(max));
  center.multLocal(0.5f);
  xExtent = max.x - center.x;
  yExtent = max.y - center.y;
  zExtent = max.z - center.z;
  vars.release();
}

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

@Override
public void setMeshes(List<Mesh> meshes) {
  this.vertices = new ArrayList<List<Vector3f>>(meshes.size());
  this.normals = new ArrayList<List<Vector3f>>(meshes.size());
  for (Mesh mesh : meshes) {
    Vector3f[] vertexTable = BufferUtils.getVector3Array(mesh.getFloatBuffer(Type.Position));
    int[] indices = new int[3];
    List<Vector3f> vertices = new ArrayList<Vector3f>(mesh.getTriangleCount() * 3);
    List<Vector3f> normals = new ArrayList<Vector3f>(mesh.getTriangleCount());
    for (int i = 0; i < mesh.getTriangleCount(); ++i) {
      mesh.getTriangle(i, indices);
      vertices.add(vertexTable[indices[0]]);
      vertices.add(vertexTable[indices[1]]);
      vertices.add(vertexTable[indices[2]]);
      normals.add(FastMath.computeNormal(vertexTable[indices[0]], vertexTable[indices[1]], vertexTable[indices[2]]));
    }
    this.vertices.add(vertices);
    this.normals.add(normals);
  }
}

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

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: org.jmonkeyengine/jme3-dae

private List<Triangle> getTrianglesSharingIndex(int index, Mesh mesh)
  {
   List<Triangle> result = new LinkedList<Triangle>();
   int[] buffer = new int[3];
   for (int i = 0; i < mesh.getTriangleCount(); i++)
   {
     mesh.getTriangle(i, buffer);

     if ((buffer[0] == index) || (buffer[1] == index) || (buffer[2] == index))
     {
      Triangle t = new Triangle(new Vector3f(), new Vector3f(), new Vector3f());
      mesh.getTriangle(i, t);
      result.add(t);
     }
   }

   return result;
  }
}

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

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: info.projectkyoto/mms-engine

Mesh m = geoms[g].getMesh();
for (int i = 0; i < m.getTriangleCount(); i++){
  m.getTriangle(i, t);
  OCTTriangle ot = new OCTTriangle(t.get1(), t.get2(), t.get3(), i, g);
  allTris.add(ot);

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

/**
 * Gets the triangle vertex positions at the given triangle index 
 * and stores them into the {@link Triangle} argument.
 * Also sets the triangle index to the <code>index</code> argument.
 * 
 * @param index The index of the triangle. 
 * Should be between 0 and {@link #getTriangleCount()}.
 * 
 * @param tri The triangle to store the positions in
 */
public void getTriangle(int index, Triangle tri){
  getTriangle(index, tri.get1(), tri.get2(), tri.get3());
  tri.setIndex(index);
  tri.setNormal(null);
}

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

/**
 * Gets the triangle vertex positions at the given triangle index
 * and stores them into the {@link Triangle} argument.
 * Also sets the triangle index to the <code>index</code> argument.
 *
 * @param index The index of the triangle.
 * Should be between 0 and {@link #getTriangleCount()}.
 *
 * @param tri The triangle to store the positions in
 */
public void getTriangle(int index, Triangle tri){
  getTriangle(index, tri.get1(), tri.get2(), tri.get3());
  tri.setIndex(index);
  tri.setNormal(null);
}

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

in.getTriangle(t.getTriangleIndex(), vertIndicies);

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

public void computeFromTris(int[] indices, Mesh mesh, int start, int end) {
  if (end - start <= 0) {
    return;
  }
  TempVars vars = TempVars.get();
  Vector3f vect1 = vars.vect1;
  Vector3f vect2 = vars.vect2;
  Triangle triangle = vars.triangle;
  Vector3f min = vect1.set(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY);
  Vector3f max = vect2.set(Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY);
  Vector3f point;
  for (int i = start; i < end; i++) {
    mesh.getTriangle(indices[i], triangle);
    point = triangle.get(0);
    checkMinMax(min, max, point);
    point = triangle.get(1);
    checkMinMax(min, max, point);
    point = triangle.get(2);
    checkMinMax(min, max, point);
  }
  center.set(min.addLocal(max));
  center.multLocal(0.5f);
  xExtent = max.x - center.x;
  yExtent = max.y - center.y;
  zExtent = max.z - center.z;
  vars.release();
}

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

public void computeFromTris(int[] indices, Mesh mesh, int start, int end) {
  if (end - start <= 0) {
    return;
  }
  TempVars vars = TempVars.get();
  Vector3f vect1 = vars.vect1;
  Vector3f vect2 = vars.vect2;
  Triangle triangle = vars.triangle;
  Vector3f min = vect1.set(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY);
  Vector3f max = vect2.set(Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY);
  Vector3f point;
  for (int i = start; i < end; i++) {
    mesh.getTriangle(indices[i], triangle);
    point = triangle.get(0);
    checkMinMax(min, max, point);
    point = triangle.get(1);
    checkMinMax(min, max, point);
    point = triangle.get(2);
    checkMinMax(min, max, point);
  }
  center.set(min.addLocal(max));
  center.multLocal(0.5f);
  xExtent = max.x - center.x;
  yExtent = max.y - center.y;
  zExtent = max.z - center.z;
  vars.release();
}

相关文章