本文整理汇总了Java中com.jme3.scene.Mesh.getFloatBuffer方法的典型用法代码示例。如果您正苦于以下问题:Java Mesh.getFloatBuffer方法的具体用法?Java Mesh.getFloatBuffer怎么用?Java Mesh.getFloatBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.scene.Mesh
的用法示例。
在下文中一共展示了Mesh.getFloatBuffer方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convert
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public static Mesh convert(IndexedMesh mesh) {
Mesh jmeMesh = new Mesh();
jmeMesh.setBuffer(Type.Index, 3, BufferUtils.createShortBuffer(mesh.numTriangles * 3));
jmeMesh.setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(mesh.numVertices * 3));
IndexBuffer indicess = jmeMesh.getIndexBuffer();
FloatBuffer vertices = jmeMesh.getFloatBuffer(Type.Position);
for (int i = 0; i < mesh.numTriangles * 3; i++) {
indicess.put(i, mesh.triangleIndexBase.getInt(i * 4));
}
for (int i = 0; i < mesh.numVertices * 3; i++) {
vertices.put(i, mesh.vertexBase.getFloat(i * 4));
}
jmeMesh.updateCounts();
jmeMesh.updateBound();
jmeMesh.getFloatBuffer(Type.Position).clear();
return jmeMesh;
}
示例2: createGeometry
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
protected Geometry createGeometry(ArrayList<Face> faceList, String matName) throws IOException{
if (faceList.isEmpty())
throw new IOException("No geometry data to generate mesh");
// Create mesh from the faces
Mesh mesh = constructMesh(faceList);
Geometry geom = new Geometry(objName + "-geom-" + (geomIndex++), mesh);
Material material = null;
if (matName != null && matList != null){
// Get material from material list
material = matList.get(matName);
}
if (material == null){
// create default material
material = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
material.setFloat("Shininess", 64);
}
geom.setMaterial(material);
if (material.isTransparent())
geom.setQueueBucket(Bucket.Transparent);
else
geom.setQueueBucket(Bucket.Opaque);
if (material.getMaterialDef().getName().contains("Lighting")
|| mesh.getFloatBuffer(Type.Normal) == null){
logger.log(Level.WARNING, "OBJ mesh {0} doesn't contain normals! "
+ "It might not display correctly", geom.getName());
}
return geom;
}
示例3: getPoints
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
protected float[] getPoints(Mesh mesh) {
FloatBuffer vertices = mesh.getFloatBuffer(Type.Position);
vertices.rewind();
int components = mesh.getVertexCount() * 3;
float[] pointsArray = new float[components];
for (int i = 0; i < components; i += 3) {
pointsArray[i] = vertices.get();
pointsArray[i + 1] = vertices.get();
pointsArray[i + 2] = vertices.get();
}
return pointsArray;
}
示例4: buildPointMapForMesh
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
private static Map<Integer, List<Float>> buildPointMapForMesh(Mesh mesh, Map<Integer, List<Float>> map) {
FloatBuffer vertices = mesh.getFloatBuffer(Type.Position);
ByteBuffer boneIndices = (ByteBuffer) mesh.getBuffer(Type.BoneIndex).getData();
FloatBuffer boneWeight = (FloatBuffer) mesh.getBuffer(Type.BoneWeight).getData();
vertices.rewind();
boneIndices.rewind();
boneWeight.rewind();
int vertexComponents = mesh.getVertexCount() * 3;
int k, start, index;
float maxWeight = 0;
for (int i = 0; i < vertexComponents; i += 3) {
start = i / 3 * 4;
index = 0;
maxWeight = -1;
for (k = start; k < start + 4; k++) {
float weight = boneWeight.get(k);
if (weight > maxWeight) {
maxWeight = weight;
index = boneIndices.get(k);
}
}
List<Float> points = map.get(index);
if (points == null) {
points = new ArrayList<Float>();
map.put(index, points);
}
points.add(vertices.get(i));
points.add(vertices.get(i + 1));
points.add(vertices.get(i + 2));
}
return map;
}
示例5: optimize
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public Mesh optimize(Mesh mesh) {
nmgen = new NavmeshGenerator(cellSize, cellHeight, minTraversableHeight,
maxTraversableStep, maxTraversableSlope,
clipLedges, traversableAreaBorderSize,
smoothingThreshold, useConservativeExpansion,
minUnconnectedRegionSize, mergeRegionSize,
maxEdgeLength, edgeMaxDeviation, maxVertsPerPoly,
contourSampleDistance, contourMaxDeviation);
FloatBuffer pb = mesh.getFloatBuffer(Type.Position);
IndexBuffer ib = mesh.getIndexBuffer();
// copy positions to float array
float[] positions = new float[pb.capacity()];
pb.clear();
pb.get(positions);
// generate int array of indices
int[] indices = new int[ib.size()];
for (int i = 0; i < indices.length; i++) {
indices[i] = ib.get(i);
}
TriangleMesh triMesh = buildNavMesh(positions, indices, intermediateData);
if (triMesh == null) {
return null;
}
int[] indices2 = triMesh.indices;
float[] positions2 = triMesh.vertices;
Mesh mesh2 = new Mesh();
mesh2.setBuffer(Type.Position, 3, positions2);
mesh2.setBuffer(Type.Index, 3, indices2);
mesh2.updateBound();
mesh2.updateCounts();
return mesh2;
}
示例6: computeLodEntropy
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public static float computeLodEntropy(Mesh terrainBlock, IntBuffer lodIndices){
// Bounding box for the terrain block
BoundingBox bbox = (BoundingBox) terrainBlock.getBound();
// Vertex positions for the block
FloatBuffer positions = terrainBlock.getFloatBuffer(Type.Position);
// Prepare to cast rays
Vector3f pos = new Vector3f();
Vector3f dir = new Vector3f(0, -1, 0);
Ray ray = new Ray(pos, dir);
// Prepare collision results
CollisionResults results = new CollisionResults();
// Set the LOD indices on the block
VertexBuffer originalIndices = terrainBlock.getBuffer(Type.Index);
terrainBlock.clearBuffer(Type.Index);
terrainBlock.setBuffer(Type.Index, 3, lodIndices);
// Recalculate collision mesh
terrainBlock.createCollisionData();
float entropy = 0;
for (int i = 0; i < positions.capacity() / 3; i++){
BufferUtils.populateFromBuffer(pos, positions, i);
float realHeight = pos.y;
pos.addLocal(0, bbox.getYExtent(), 0);
ray.setOrigin(pos);
results.clear();
terrainBlock.collideWith(ray, Matrix4f.IDENTITY, bbox, results);
if (results.size() > 0){
Vector3f contactPoint = results.getClosestCollision().getContactPoint();
float delta = Math.abs(realHeight - contactPoint.y);
entropy = Math.max(delta, entropy);
}
}
// Restore original indices
terrainBlock.clearBuffer(Type.Index);
terrainBlock.setBuffer(originalIndices);
return entropy;
}
示例7: getPoints
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
/**
* returns a list of points for the given bone
* @param mesh
* @param boneIndex
* @param offset
* @param link
* @return
*/
private static List<Float> getPoints(Mesh mesh, int boneIndex, Vector3f initialScale, Vector3f offset, float weightThreshold) {
FloatBuffer vertices = mesh.getFloatBuffer(Type.Position);
ByteBuffer boneIndices = (ByteBuffer) mesh.getBuffer(Type.BoneIndex).getData();
FloatBuffer boneWeight = (FloatBuffer) mesh.getBuffer(Type.BoneWeight).getData();
vertices.rewind();
boneIndices.rewind();
boneWeight.rewind();
ArrayList<Float> results = new ArrayList<Float>();
int vertexComponents = mesh.getVertexCount() * 3;
for (int i = 0; i < vertexComponents; i += 3) {
int k;
boolean add = false;
int start = i / 3 * 4;
for (k = start; k < start + 4; k++) {
if (boneIndices.get(k) == boneIndex && boneWeight.get(k) >= weightThreshold) {
add = true;
break;
}
}
if (add) {
Vector3f pos = new Vector3f();
pos.x = vertices.get(i);
pos.y = vertices.get(i + 1);
pos.z = vertices.get(i + 2);
pos.subtractLocal(offset).multLocal(initialScale);
results.add(pos.x);
results.add(pos.y);
results.add(pos.z);
}
}
return results;
}