本文整理汇总了Java中com.jme3.scene.Mesh.getVertexCount方法的典型用法代码示例。如果您正苦于以下问题:Java Mesh.getVertexCount方法的具体用法?Java Mesh.getVertexCount怎么用?Java Mesh.getVertexCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.scene.Mesh
的用法示例。
在下文中一共展示了Mesh.getVertexCount方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BIHTree
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
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);
}
示例2: renderMesh
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public void renderMesh(Mesh mesh, int lod, int count) {
if (mesh.getVertexCount() == 0) {
return;
}
if (context.pointSize != mesh.getPointSize()) {
glPointSize(mesh.getPointSize());
context.pointSize = mesh.getPointSize();
}
if (context.lineWidth != mesh.getLineWidth()) {
glLineWidth(mesh.getLineWidth());
context.lineWidth = mesh.getLineWidth();
}
statistics.onMeshDrawn(mesh, lod);
// if (GLContext.getCapabilities().GL_ARB_vertex_array_object){
// renderMeshVertexArray(mesh, lod, count);
// }else{
renderMeshDefault(mesh, lod, count);
// }
}
示例3: WrappedIndexBuffer
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
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();
}
}
示例4: 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;
}
示例5: 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;
}
示例6: convert
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public static IndexedMesh convert(Mesh mesh) {
IndexedMesh jBulletIndexedMesh = new IndexedMesh();
jBulletIndexedMesh.triangleIndexBase = ByteBuffer.allocate(mesh.getTriangleCount() * 3 * 4);
jBulletIndexedMesh.vertexBase = ByteBuffer.allocate(mesh.getVertexCount() * 3 * 4);
IndexBuffer indices = mesh.getIndicesAsList();
FloatBuffer vertices = mesh.getFloatBuffer(Type.Position);
vertices.rewind();
int verticesLength = mesh.getVertexCount() * 3;
jBulletIndexedMesh.numVertices = mesh.getVertexCount();
jBulletIndexedMesh.vertexStride = 12; //3 verts * 4 bytes per.
for (int i = 0; i < verticesLength; i++) {
float tempFloat = vertices.get();
jBulletIndexedMesh.vertexBase.putFloat(tempFloat);
}
int indicesLength = mesh.getTriangleCount() * 3;
jBulletIndexedMesh.numTriangles = mesh.getTriangleCount();
jBulletIndexedMesh.triangleIndexStride = 12; //3 index entries * 4 bytes each.
for (int i = 0; i < indicesLength; i++) {
jBulletIndexedMesh.triangleIndexBase.putInt(indices.get(i));
}
vertices.rewind();
vertices.clear();
return jBulletIndexedMesh;
}
示例7: compressIndexBuffer
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public static void compressIndexBuffer(Mesh mesh){
int vertCount = mesh.getVertexCount();
VertexBuffer vb = mesh.getBuffer(Type.Index);
Format targetFmt;
if (vb.getFormat() == Format.UnsignedInt && vertCount <= 0xffff){
if (vertCount <= 256)
targetFmt = Format.UnsignedByte;
else
targetFmt = Format.UnsignedShort;
}else if (vb.getFormat() == Format.UnsignedShort && vertCount <= 0xff){
targetFmt = Format.UnsignedByte;
}else{
return;
}
IndexBuffer src = mesh.getIndexBuffer();
Buffer newBuf = VertexBuffer.createBuffer(targetFmt, vb.getNumComponents(), src.size());
VertexBuffer newVb = new VertexBuffer(Type.Index);
newVb.setupData(vb.getUsage(), vb.getNumComponents(), targetFmt, newBuf);
mesh.clearBuffer(Type.Index);
mesh.setBuffer(newVb);
IndexBuffer dst = mesh.getIndexBuffer();
for (int i = 0; i < src.size(); i++){
dst.put(i, src.get(i));
}
}
示例8: buildForImpl
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
@Override
@FXThread
protected void buildForImpl(@NotNull final Object object, @Nullable final Object parent, @NotNull final VBox container,
@NotNull final ModelChangeConsumer changeConsumer) {
if (!(object instanceof Mesh)) return;
final Mesh mesh = (Mesh) object;
final Mesh.Mode mode = mesh.getMode();
final int id = mesh.getId();
final int instanceCount = mesh.getInstanceCount();
final int vertexCount = mesh.getVertexCount();
final int numLodLevels = mesh.getNumLodLevels();
final int triangleCount = mesh.getTriangleCount();
final DefaultSinglePropertyControl<ModelChangeConsumer, Mesh, Integer> idControl =
new DefaultSinglePropertyControl<>(id, Messages.MODEL_PROPERTY_ID, changeConsumer);
idControl.setSyncHandler(Mesh::getId);
idControl.setToStringFunction(value -> Integer.toString(value));
idControl.setEditObject(mesh);
final DefaultSinglePropertyControl<ModelChangeConsumer, Mesh, Integer> instanceCountControl =
new DefaultSinglePropertyControl<>(instanceCount, Messages.MODEL_PROPERTY_INSTANCE_COUNT, changeConsumer);
instanceCountControl.setSyncHandler(Mesh::getInstanceCount);
instanceCountControl.setToStringFunction(value -> Integer.toString(value));
instanceCountControl.setEditObject(mesh);
final DefaultSinglePropertyControl<ModelChangeConsumer, Mesh, Integer> vertexCountControl =
new DefaultSinglePropertyControl<>(vertexCount, Messages.MODEL_PROPERTY_VERTEX_COUNT, changeConsumer);
vertexCountControl.setSyncHandler(Mesh::getVertexCount);
vertexCountControl.setToStringFunction(value -> Integer.toString(value));
vertexCountControl.setEditObject(mesh);
final DefaultSinglePropertyControl<ModelChangeConsumer, Mesh, Integer> triangleCountControl =
new DefaultSinglePropertyControl<>(triangleCount, Messages.MODEL_PROPERTY_TRIANGLE_COUNT, changeConsumer);
triangleCountControl.setSyncHandler(Mesh::getTriangleCount);
triangleCountControl.setToStringFunction(value -> Integer.toString(value));
triangleCountControl.setEditObject(mesh);
final DefaultSinglePropertyControl<ModelChangeConsumer, Mesh, Integer> numLodLevelsControl =
new DefaultSinglePropertyControl<>(numLodLevels, Messages.MODEL_PROPERTY_NUM_LOD_LEVELS, changeConsumer);
numLodLevelsControl.setSyncHandler(Mesh::getNumLodLevels);
numLodLevelsControl.setToStringFunction(value -> Integer.toString(value));
numLodLevelsControl.setEditObject(mesh);
final EnumPropertyControl<ModelChangeConsumer, Mesh, Mesh.Mode> modeControl =
new EnumPropertyControl<>(mode, Messages.MODEL_PROPERTY_MODE, changeConsumer, MODES);
modeControl.setApplyHandler(Mesh::setMode);
modeControl.setSyncHandler(Mesh::getMode);
modeControl.setEditObject(mesh);
FXUtils.addToPane(idControl, container);
FXUtils.addToPane(instanceCountControl, container);
FXUtils.addToPane(vertexCountControl, container);
FXUtils.addToPane(triangleCountControl, container);
FXUtils.addToPane(numLodLevelsControl, container);
FXUtils.addToPane(modeControl, container);
}
示例9: renderMesh
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public void renderMesh(Mesh mesh, int lod, int count) {
if (mesh.getVertexCount() == 0) {
return;
}
if (context.pointSize != mesh.getPointSize()) {
glPointSize(mesh.getPointSize());
context.pointSize = mesh.getPointSize();
}
if (context.lineWidth != mesh.getLineWidth()) {
glLineWidth(mesh.getLineWidth());
context.lineWidth = mesh.getLineWidth();
}
boolean dynamic = false;
if (mesh.getBuffer(Type.InterleavedData) != null) {
throw new UnsupportedOperationException("Interleaved meshes are not supported");
}
if (mesh.getNumLodLevels() == 0) {
IntMap<VertexBuffer> bufs = mesh.getBuffers();
for (Entry<VertexBuffer> entry : bufs) {
if (entry.getValue().getUsage() != VertexBuffer.Usage.Static) {
dynamic = true;
break;
}
}
} else {
dynamic = true;
}
statistics.onMeshDrawn(mesh, lod);
// if (!dynamic) {
// dealing with a static object, generate display list
// renderMeshDisplayList(mesh);
// } else {
renderMeshDefault(mesh, lod, count);
// }
}
示例10: onMeshDrawn
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
/**
* Called by the Renderer when a mesh has been drawn.
*
*/
public void onMeshDrawn(Mesh mesh, int lod){
numObjects ++;
numTriangles += mesh.getTriangleCount(lod);
numVertices += mesh.getVertexCount();
}
示例11: 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;
}