本文整理汇总了Java中com.jme3.scene.Mesh类的典型用法代码示例。如果您正苦于以下问题:Java Mesh类的具体用法?Java Mesh怎么用?Java Mesh使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Mesh类属于com.jme3.scene包,在下文中一共展示了Mesh类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addObject
import com.jme3.scene.Mesh; //导入依赖的package包/类
@Override
protected Spatial addObject(Entity e) {
Vector3f loc = e.get(PhysicsPosition.class).getLocation();
Mesh mesh = MeshFactory.createSphere(0.25f);
Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
material.setColor("Color", ColorRGBA.Orange);
TextureKey key = new TextureKey("Interface/grid-shaded.png");
key.setGenerateMips(true);
Texture texture = assetManager.loadTexture(key);
texture.setWrap(Texture.WrapMode.Repeat);
material.setTexture("ColorMap", texture);
Geometry geometry = new Geometry("PhysicsPosition: "+e.getId(), mesh);
geometry.setMaterial(material);
geometry.setLocalTranslation(loc);
rootNode.attachChild(geometry);
return geometry;
}
示例2: updateObject
import com.jme3.scene.Mesh; //导入依赖的package包/类
@Override
protected void updateObject(Spatial geom, Entity e) {
if(geom instanceof Node){
LOGGER.info("Can't update mesh for "+e.getId()+" recreate it!");
return;
}
Mesh mesh = factory.getMesh(e.get(componentType));
((Geometry)geom).setMesh(mesh);
geom.updateModelBound();
RigidBody body = e.get(RigidBody.class);
if(body.isKinematic()){
geom.setMaterial(createMaterial(ColorRGBA.Green));
}else {
if(body.getMass() == 0) {
geom.setMaterial(createMaterial(ColorRGBA.Cyan.mult(ColorRGBA.DarkGray)));
}else {
geom.setMaterial(createMaterial(ColorRGBA.Red));
}
}
}
示例3: 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);
}
}
示例4: useStandardGenerator
import com.jme3.scene.Mesh; //导入依赖的package包/类
/**
* Generate tangents using a standard algorithm.
*
* @param spatial the spatial.
* @param splitMirrored the split mirrored.
*/
public static void useStandardGenerator(@NotNull final Spatial spatial, final boolean splitMirrored) {
try {
NodeUtils.visitGeometry(spatial, geometry -> {
final Mesh mesh = geometry.getMesh();
final VertexBuffer texCoord = mesh.getBuffer(VertexBuffer.Type.TexCoord);
if (texCoord != null) {
TangentBinormalGenerator.generate(geometry, splitMirrored);
}
});
} catch (final Exception e) {
EditorUtil.handleException(LOGGER, null, e);
}
}
示例5: useMikktspaceGenerator
import com.jme3.scene.Mesh; //导入依赖的package包/类
/**
* Generate tangents using a Mikktspace algorithm.
*
* @param spatial the spatial.
*/
public static void useMikktspaceGenerator(@NotNull final Spatial spatial) {
try {
NodeUtils.visitGeometry(spatial, geometry -> {
final Mesh mesh = geometry.getMesh();
final VertexBuffer texCoord = mesh.getBuffer(VertexBuffer.Type.TexCoord);
if (texCoord != null) {
MikktspaceTangentGenerator.generate(geometry);
}
});
} catch (final Exception e) {
EditorUtil.handleException(LOGGER, null, e);
}
}
示例6: 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 + ")");
}
示例7: 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);
}
示例8: processOk
import com.jme3.scene.Mesh; //导入依赖的package包/类
@Override
@FXThread
protected void processOk() {
final NodeTree<?> nodeTree = getNodeTree();
final TreeNode<?> node = getNode();
final Geometry geometry = (Geometry) node.getElement();
final Mesh newMesh = geometry.getMesh();
final Mesh oldMesh = newMesh.deepClone();
final ComboBox<AlgorithmType> algorithmTypeComboBox = getAlgorithmTypeComboBox();
final AlgorithmType algorithmType = algorithmTypeComboBox.getSelectionModel().getSelectedItem();
if (algorithmType == AlgorithmType.STANDARD) {
final CheckBox splitMirroredCheckBox = getSplitMirroredCheckBox();
TangentGenerator.useStandardGenerator(geometry, splitMirroredCheckBox.isSelected());
} else {
TangentGenerator.useMikktspaceGenerator(geometry);
}
final ChangeConsumer changeConsumer = notNull(nodeTree.getChangeConsumer());
changeConsumer.execute(new ChangeMeshOperation(newMesh, oldMesh, geometry));
super.processOk();
}
示例9: getChildren
import com.jme3.scene.Mesh; //导入依赖的package包/类
@Override
public @NotNull Array<TreeNode<?>> getChildren(@NotNull final NodeTree<?> nodeTree) {
if (!(nodeTree instanceof ModelNodeTree)) return TreeNode.EMPTY_ARRAY;
final Array<TreeNode<?>> result = ArrayFactory.newArray(TreeNode.class);
final Geometry geometry = getElement();
final Mesh mesh = geometry.getMesh();
final Material material = geometry.getMaterial();
if (mesh != null) result.add(FACTORY_REGISTRY.createFor(mesh));
result.add(FACTORY_REGISTRY.createFor(material));
result.addAll(super.getChildren(nodeTree));
return result;
}
示例10: getHash
import com.jme3.scene.Mesh; //导入依赖的package包/类
protected String getHash(Mesh m, VHACDParameters p) throws Exception {
ByteArrayOutputStream bao=new ByteArrayOutputStream();
VertexBuffer p_b=m.getBuffer(Type.Position);
VertexBuffer i_b=m.getBuffer(Type.Index);
p.toOutputStream(bao);
_EXPORTER.save(p_b,bao);
_EXPORTER.save(i_b,bao);
byte bytes[]=bao.toByteArray();
bao.close();
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(bytes);
byte[] digest = md.digest();
BigInteger bigInt = new BigInteger(1,digest);
String hash = bigInt.toString(16);
while(hash.length() < 32 )hash = "0"+hash;
return hash;
}
示例11: findGeometries
import com.jme3.scene.Mesh; //导入依赖的package包/类
private List<Geometry> findGeometries(Node node, List<Geometry> geoms, NavMeshGenerator generator, Node originalRoot) {
if (node instanceof Terrain) {
Terrain terr = (Terrain)node;
Mesh merged = generator.terrain2mesh(terr);
Geometry g = new Geometry("mergedTerrain");
g.setMesh(merged);
if (node != originalRoot) {
g.setLocalScale(((Node)terr).getLocalScale());
g.setLocalTranslation(((Node)terr).getLocalTranslation());
}
geoms.add(g);
return geoms;
}
for (Iterator<Spatial> it = node.getChildren().iterator(); it.hasNext();) {
Spatial spatial = it.next();
if (spatial instanceof Geometry) {
geoms.add((Geometry) spatial);
} else if (spatial instanceof Node) {
findGeometries((Node) spatial, geoms, generator, originalRoot);
}
}
return geoms;
}
示例12: simpleInitApp
import com.jme3.scene.Mesh; //导入依赖的package包/类
@Override
public void simpleInitApp() {
flyCam.setMoveSpeed(20);
Sphere sphereMesh = new Sphere(32, 32, 1);
sphereMesh.setTextureMode(Sphere.TextureMode.Projected);
sphereMesh.updateGeometry(32, 32, 1, false, false);
addMesh("Sphere", sphereMesh, new Vector3f(-1, 0, 0));
Quad quadMesh = new Quad(1, 1);
quadMesh.updateGeometry(1, 1);
addMesh("Quad", quadMesh, new Vector3f(1, 0, 0));
Mesh strip = createTriangleStripMesh();
addMesh("strip", strip, new Vector3f(0, -3, 0));
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(1, -1, -1).normalizeLocal());
dl.setColor(ColorRGBA.White);
rootNode.addLight(dl);
}
示例13: addMesh
import com.jme3.scene.Mesh; //导入依赖的package包/类
private void addMesh(String name, Mesh mesh, Vector3f translation) {
TangentBinormalGenerator.generate(mesh);
Geometry testGeom = new Geometry(name, mesh);
Material mat = assetManager.loadMaterial("Textures/BumpMapTest/Tangent.j3m");
testGeom.setMaterial(mat);
testGeom.getLocalTranslation().set(translation);
rootNode.attachChild(testGeom);
Geometry debug = new Geometry(
"Debug " + name,
TangentBinormalGenerator.genTbnLines(mesh, 0.08f)
);
Material debugMat = assetManager.loadMaterial("Common/Materials/VertexColor.j3m");
debug.setMaterial(debugMat);
debug.setCullHint(Spatial.CullHint.Never);
debug.getLocalTranslation().set(translation);
rootNode.attachChild(debug);
}
示例14: simpleInitApp
import com.jme3.scene.Mesh; //导入依赖的package包/类
public void simpleInitApp() {
Geometry teaGeom = (Geometry) assetManager.loadModel("Models/Teapot/Teapot.obj");
Mesh teaMesh = teaGeom.getMesh();
ModelConverter.generateStrips(teaMesh, true, false, 24, 0);
// show normals as material
Material mat = new Material(assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
for (int y = -10; y < 10; y++){
for (int x = -10; x < 10; x++){
Geometry teaClone = new Geometry("teapot", teaMesh);
teaClone.setMaterial(mat);
teaClone.setLocalTranslation(x * .5f, 0, y * .5f);
teaClone.setLocalScale(.5f);
rootNode.attachChild(teaClone);
}
}
cam.setLocation(new Vector3f(8.378951f, 5.4324f, 8.795956f));
cam.setRotation(new Quaternion(-0.083419204f, 0.90370524f, -0.20599906f, -0.36595422f));
}
示例15: 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);
}