本文整理汇总了Java中com.jme3.scene.Mesh.getTriangle方法的典型用法代码示例。如果您正苦于以下问题:Java Mesh.getTriangle方法的具体用法?Java Mesh.getTriangle怎么用?Java Mesh.getTriangle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.scene.Mesh
的用法示例。
在下文中一共展示了Mesh.getTriangle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setMeshes
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
@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);
}
}
示例2: computeFromTris
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
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();
}
示例3: Octree
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public Octree(Spatial scene, int minTrisPerNode){
scene.updateGeometricState();
List<Geometry> geomsList = getGeometries(scene);
geoms = new Geometry[geomsList.size()];
geomsList.toArray(geoms);
// generate bound box for all geom
bbox = new BoundingBox();
for (Geometry geom : geoms){
BoundingVolume bv = geom.getWorldBound();
bbox.mergeLocal(bv);
}
// set largest extent
float extent = Math.max(bbox.getXExtent(), Math.max(bbox.getYExtent(), bbox.getZExtent()));
bbox.setXExtent(extent);
bbox.setYExtent(extent);
bbox.setZExtent(extent);
this.minTrisPerNode = minTrisPerNode;
Triangle t = new Triangle();
for (int g = 0; g < geoms.length; g++){
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);
// convert triangle to world space
// geom.getWorldTransform().transformVector(t.get1(), t.get1());
// geom.getWorldTransform().transformVector(t.get2(), t.get2());
// geom.getWorldTransform().transformVector(t.get3(), t.get3());
}
}
}