本文整理汇总了Java中com.jme3.scene.Mesh.getNumLodLevels方法的典型用法代码示例。如果您正苦于以下问题:Java Mesh.getNumLodLevels方法的具体用法?Java Mesh.getNumLodLevels怎么用?Java Mesh.getNumLodLevels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.scene.Mesh
的用法示例。
在下文中一共展示了Mesh.getNumLodLevels方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setSpatial
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
@Override
public void setSpatial(Spatial spatial) {
if (!(spatial instanceof Geometry)) {
throw new IllegalArgumentException("LodControl can only be attached to Geometry!");
}
super.setSpatial(spatial);
Geometry geom = (Geometry) spatial;
Mesh mesh = geom.getMesh();
numLevels = mesh.getNumLodLevels();
for (int i = 0; i < numLevels; i++)
if (mesh.getLodLevel( i ) == null)
numLevels--;
numTris = new int[numLevels];
for (int i = numLevels - 1; i >= 0; i--) {
numTris[i] = mesh.getTriangleCount(i);
}
}
示例2: updateItem
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
@Override
protected void updateItem(@Nullable final Integer level, final boolean empty) {
super.updateItem(level, empty);
final Geometry geometry = getEditObject();
final Mesh mesh = geometry.getMesh();
if (level == null || mesh == null) {
setText("None");
return;
}
int elements;
if (level < mesh.getNumLodLevels()) {
final VertexBuffer lodLevel = mesh.getLodLevel(level);
elements = lodLevel.getNumElements();
} else {
elements = mesh.getTriangleCount();
}
setText(Messages.MODEL_PROPERTY_LEVEL + ": " + level + " (" + elements + " " +
Messages.MODEL_PROPERTY_TRIANGLE_COUNT + ")");
}
示例3: reload
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
@Override
@FXThread
protected void reload() {
if (!hasEditObject()) return;
final Geometry geometry = getEditObject();
final Mesh mesh = geometry.getMesh();
if (mesh == null) return;
final Integer element = getPropertyValue();
final ComboBox<Integer> levelComboBox = getLevelComboBox();
final ObservableList<Integer> items = levelComboBox.getItems();
items.clear();
final int numLodLevels = mesh.getNumLodLevels();
for (int i = 0; i < numLodLevels; i++) {
items.add(i);
}
if (items.isEmpty()) {
items.add(0);
}
levelComboBox.getSelectionModel().select(element);
}
示例4: renderMeshVertexArray
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
private void renderMeshVertexArray(Mesh mesh, int lod, int count) {
if (mesh.getId() == -1){
updateVertexArray(mesh);
}else{
// TODO: Check if it was updated
}
if (context.boundVertexArray != mesh.getId()) {
ARBVertexArrayObject.glBindVertexArray(mesh.getId());
context.boundVertexArray = mesh.getId();
}
// IntMap<VertexBuffer> buffers = mesh.getBuffers();
VertexBuffer indices = null;
if (mesh.getNumLodLevels() > 0) {
indices = mesh.getLodLevel(lod);
} else {
indices = mesh.getBuffer(Type.Index);
}
if (indices != null) {
drawTriangleList(indices, mesh, count);
} else {
drawTriangleArray(mesh.getMode(), count, mesh.getVertexCount());
}
clearVertexAttribs();
clearTextureUnits();
}
示例5: setSpatial
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
@Override
public void setSpatial(Spatial spatial){
if (!(spatial instanceof Geometry))
throw new IllegalArgumentException("LodControl can only be attached to Geometry!");
super.setSpatial(spatial);
Geometry geom = (Geometry) spatial;
Mesh mesh = geom.getMesh();
numLevels = mesh.getNumLodLevels();
numTris = new int[numLevels];
for (int i = numLevels - 1; i >= 0; i--)
numTris[i] = mesh.getTriangleCount(i);
}
示例6: 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);
}
示例7: processGenerate
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
/**
* Process of generating.
*/
@FXThread
private void processGenerate() {
final Geometry geometry = getGeometry();
final Mesh mesh = getMesh();
final int currentLevels = mesh.getNumLodLevels();
final VertexBuffer[] prevLodLevels = new VertexBuffer[currentLevels];
for (int i = 0; i < currentLevels; i++) {
prevLodLevels[i] = mesh.getLodLevel(i);
}
final ReductionMethod method = getMethod();
final TriangleReductionMethod resultMethod =
method == ReductionMethod.CONSTANT ? TriangleReductionMethod.CONSTANT :
TriangleReductionMethod.PROPORTIONAL;
final ListView<Number> levelsList = getLevelsList();
final ObservableList<Number> items = levelsList.getItems();
final float[] values = new float[items.size()];
for (int i = 0; i < items.size(); i++) {
values[i] = items.get(i).floatValue();
}
final LodGenerator generator = new LodGenerator(geometry);
final VertexBuffer[] newLodLevels = generator.computeLods(resultMethod, values);
EXECUTOR_MANAGER.addFXTask(() -> {
final NodeTree<?> nodeTree = getNodeTree();
final ChangeConsumer consumer = notNull(nodeTree.getChangeConsumer());
final PropertyOperation<ChangeConsumer, Geometry, VertexBuffer[]> operation =
new PropertyOperation<>(geometry, Messages.MODEL_PROPERTY_LOD, newLodLevels, prevLodLevels);
operation.setApplyHandler((geom, buffers) -> geom.getMesh().setLodLevels(buffers));
consumer.execute(operation);
EditorUtil.decrementLoading();
});
}
示例8: renderMeshDefault
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
private void renderMeshDefault(Mesh mesh, int lod, int count) {
VertexBuffer indices = null;
VertexBuffer interleavedData = mesh.getBuffer(Type.InterleavedData);
if (interleavedData != null && interleavedData.isUpdateNeeded()) {
updateBufferData(interleavedData);
}
//IntMap<VertexBuffer> buffers = mesh.getBuffers();
ArrayList<VertexBuffer> buffersList = mesh.getBufferList();
if (mesh.getNumLodLevels() > 0) {
indices = mesh.getLodLevel(lod);
} else {
indices = mesh.getBuffer(Type.Index);
}
//for (Entry<VertexBuffer> entry : buffers) {
// VertexBuffer vb = entry.getValue();
for (int i = 0; i < buffersList.size(); i++){
VertexBuffer vb = buffersList.get(i);
if (vb.getBufferType() == Type.InterleavedData
|| vb.getUsage() == Usage.CpuOnly // ignore cpu-only buffers
|| vb.getBufferType() == Type.Index) {
continue;
}
if (vb.getStride() == 0) {
// not interleaved
setVertexAttrib(vb);
} else {
// interleaved
setVertexAttrib(vb, interleavedData);
}
}
if (indices != null) {
drawTriangleList(indices, mesh, count);
} else {
drawTriangleArray(mesh.getMode(), count, mesh.getVertexCount());
}
clearVertexAttribs();
clearTextureUnits();
}
示例9: renderMeshDefault
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
private void renderMeshDefault(Mesh mesh, int lod, int count) {
VertexBuffer indices = null;
VertexBuffer interleavedData = mesh.getBuffer(Type.InterleavedData);
if (interleavedData != null && interleavedData.isUpdateNeeded()) {
updateBufferData(interleavedData);
}
IntMap<VertexBuffer> buffers = mesh.getBuffers();
if (mesh.getNumLodLevels() > 0) {
indices = mesh.getLodLevel(lod);
} else {
indices = buffers.get(Type.Index.ordinal());
}
for (Entry<VertexBuffer> entry : buffers) {
VertexBuffer vb = entry.getValue();
if (vb.getBufferType() == Type.InterleavedData
|| vb.getUsage() == Usage.CpuOnly // ignore cpu-only buffers
|| vb.getBufferType() == Type.Index) {
continue;
}
if (vb.getStride() == 0) {
// not interleaved
setVertexAttrib(vb);
} else {
// interleaved
setVertexAttrib(vb, interleavedData);
}
}
if (indices != null) {
drawTriangleList(indices, mesh, count);
} else {
glDrawArrays(convertElementMode(mesh.getMode()), 0, mesh.getVertexCount());
}
// TODO: Fix these to use IDList??
clearVertexAttribs();
clearTextureUnits();
clearSetFixedFuncBindings();
}
示例10: 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);
// }
}