本文整理了Java中com.jme3.scene.Geometry
类的一些代码示例,展示了Geometry
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Geometry
类的具体详情如下:
包路径:com.jme3.scene.Geometry
类名称:Geometry
[英]Geometry
defines a leaf node of the scene graph. The leaf node contains the geometric data for rendering objects. It manages all rendering information such as a Material object to define how the surface should be shaded and the Mesh data to contain the actual geometry.
[中]Geometry
定义场景图的叶节点。叶节点包含用于渲染对象的几何数据。它管理所有渲染信息(如材质对象),以定义曲面应如何着色以及网格数据以包含实际几何体。
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public void addBrick(Vector3f ori) {
Geometry reBoxg = new Geometry("brick", brick);
reBoxg.setMaterial(mat);
reBoxg.setLocalTranslation(ori);
reBoxg.rotate(0f, (float)Math.toRadians(angle) , 0f );
reBoxg.addControl(new RigidBodyControl(1.5f));
reBoxg.setShadowMode(ShadowMode.CastAndReceive);
reBoxg.getControl(RigidBodyControl.class).setFriction(1.6f);
this.batchNode.attachChild(reBoxg);
this.getPhysicsSpace().add(reBoxg);
nbBrick++;
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
@Override
public void simpleInitApp() {
Quad quadMesh = new Quad(512,512);
Geometry quad = new Geometry("Quad", quadMesh);
quad.setQueueBucket(Bucket.Gui);
mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setTexture("ColorMap", assetManager.loadTexture("Textures/ColoredTex/Monkey.png"));
quad.setMaterial(mat);
guiNode.attachChildAt(quad, 0);
nextColor = ColorRGBA.randomColor();
prevColor = ColorRGBA.Black;
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
private void createDebugTangents(Geometry geom) {
Geometry debug = new Geometry(
"Debug " + geom.getName(),
TangentBinormalGenerator.genTbnLines(geom.getMesh(), 0.8f)
);
Material debugMat = assetManager.loadMaterial("Common/Materials/VertexColor.j3m");
debug.setMaterial(debugMat);
debug.setCullHint(Spatial.CullHint.Never);
debug.getLocalTranslation().set(geom.getWorldTranslation());
debugNode.attachChild(debug);
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
private static Geometry createDebugShape(CollisionShape shape) {
Geometry geom = new Geometry();
geom.setMesh(DebugShapeFactory.getDebugMesh(shape));
// geom.setLocalScale(shape.getScale());
geom.updateModelBound();
return geom;
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
private void updateBoneMesh(Geometry geom, Vector3f start, Vector3f[] ends) {
if (geom.getMesh() instanceof ArmatureInterJointsWire) {
((ArmatureInterJointsWire) geom.getMesh()).updatePoints(start, ends);
} else if (geom.getMesh() instanceof Line) {
((Line) geom.getMesh()).updatePoints(start, ends[0]);
}
geom.updateModelBound();
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public void reload() {
Material reloadedMat = reloadMaterial(geom.getMaterial());
//if the reload is successful, we re setup the material with its params and reassign it to the box
if (reloadedMat != null) {
// setupMaterial(reloadedMat);
geom.setMaterial(reloadedMat);
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
private void attachRandomGeometry(Node node, Material mat) {
Box box = new Box(0.25f, 0.25f, 0.25f);
Torus torus = new Torus(16, 16, 0.2f, 0.8f);
Geometry[] boxes = new Geometry[]{
new Geometry("box1", box),
new Geometry("box2", box),
new Geometry("box3", box),
new Geometry("torus1", torus),
new Geometry("torus2", torus),
new Geometry("torus3", torus)
};
for (int i = 0; i < boxes.length; i++) {
Geometry geometry = boxes[i];
geometry.setLocalTranslation((float) Math.random() * 10 -10, (float) Math.random() * 10 -10, (float) Math.random() * 10 -10);
geometry.setLocalRotation(new Quaternion().fromAngles((float) Math.random() * FastMath.PI, (float) Math.random() * FastMath.PI, (float) Math.random() * FastMath.PI));
geometry.setLocalScale((float) Math.random() * 10 -10, (float) Math.random() * 10 -10, (float) Math.random() * 10 -10);
geometry.setMaterial(mat);
node.attachChild(geometry);
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
private Geometry createInstance(float x, float z) {
Mesh mesh;
if (FastMath.nextRandomInt(0, 1) == 1) mesh = mesh2;
else mesh = mesh1;
Geometry geometry = new Geometry("randomGeom", mesh);
geometry.setMaterial(materials[FastMath.nextRandomInt(0, materials.length - 1)]);
geometry.setLocalTranslation(x, 0, z);
return geometry;
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Instantiate an enabled control to visualize the specified joint.
*
* @param debugAppState which app state (not null, alias created)
* @param body the joint to visualize (not null, alias created)
*/
public BulletJointDebugControl(BulletDebugAppState debugAppState, PhysicsJoint body) {
super(debugAppState);
this.body = body;
this.geomA = new Geometry(body.toString());
arrowA = new Arrow(Vector3f.ZERO);
geomA.setMesh(arrowA);
geomA.setMaterial(debugAppState.DEBUG_GREEN);
this.geomB = new Geometry(body.toString());
arrowB = new Arrow(Vector3f.ZERO);
geomB.setMesh(arrowB);
geomB.setMaterial(debugAppState.DEBUG_GREEN);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
private void createBox() {
//creating a transluscent box
box = new Geometry("box", new Box(50, 50, 50));
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", new ColorRGBA(1.0f, 0, 0, 0.3f));
mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
//mat.getAdditionalRenderState().setDepthWrite(false);
//mat.getAdditionalRenderState().setDepthTest(false);
box.setMaterial(mat);
box.setQueueBucket(Bucket.Translucent);
//creating a post view port
// ViewPort post=renderManager.createPostView("transpPost", cam);
// post.setClearFlags(false, true, true);
box.setLocalTranslation(-600, 0, 300);
//attaching the box to the post viewport
//Don't forget to updateGeometricState() the box in the simpleUpdate
// post.attachScene(box);
rootNode.attachChild(box);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
@Override
public void simpleInitApp() {
Quad q = new Quad(1, 1);
Geometry g = new Geometry("quad", q);
g.setLocalTranslation(-500, -500, 0);
g.setLocalScale(1000);
rootNode.attachChild(g);
cam.setLocation(new Vector3f(0.0f, 0.0f, 0.40647888f));
cam.setRotation(new Quaternion(0.0f, 1.0f, 0.0f, 0.0f));
Texture tex = assetManager.loadTexture("Interface/Logo/Monkey.jpg");
Material mat = new Material(assetManager, "Common/MatDefs/Misc/UnshadedNodes.j3md");
//Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Yellow);
mat.setTexture("ColorMap", tex);
g.setMaterial(mat);
//place the geoms in the transparent bucket so that they are rendered back to front for maximum overdraw
g.setQueueBucket(RenderQueue.Bucket.Transparent);
for (int i = 0; i < 1000; i++) {
Geometry cl = g.clone(false);
cl.move(0, 0, -(i + 1));
rootNode.attachChild(cl);
}
flyCam.setMoveSpeed(20);
Logger.getLogger("com.jme3").setLevel(Level.WARNING);
this.setAppProfiler(new Profiler());
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
if (needsFullRebatch) {
for (Batch batch : batches.getArray()) {
batch.geometry.removeFromParent();
if (batch != null) {
list.add(0, batch.geometry);
batchName = batch.geometry.getName();
batch.geometry.removeFromParent();
} else {
batch = new Batch();
batch.geometry = new Geometry(batchName);
batch.geometry.setMaterial(material);
this.attachChild(batch.geometry);
batch.geometry.setMesh(m);
batch.geometry.getMesh().updateCounts();
batch.geometry.updateModelBound();
batches.add(batch);
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public void setupFloor() {
Material mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall.j3m");
Box floor = new Box(50, 1f, 50);
TangentBinormalGenerator.generate(floor);
floor.scaleTextureCoordinates(new Vector2f(5, 5));
Geometry floorGeom = new Geometry("Floor", floor);
floorGeom.setMaterial(mat);
floorGeom.setShadowMode(ShadowMode.Receive);
rootNode.attachChild(floorGeom);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
Geometry cube1 = new Geometry("box", boxshape1);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Blue);
cube1.setMaterial(mat);
rootNode.attachChild(cube1);
cube1.move(0, 1.5f, 0);
Geometry cube2 = cube1.clone(true);
cube2.move(0.2f, 0 , 0);
cube2.setQueueBucket(RenderQueue.Bucket.Transparent);
cube2.getMaterial().setColor("Color", ColorRGBA.Red);
rootNode.attachChild(cube2);
Geometry cube3 = cube1.clone();
Geometry cube4 = cube2.clone(true);
cube4.getMaterial().getAdditionalRenderState().setDepthFunc(RenderState.TestFunction.Less);
cube3.move(0,-3,0);
cube4.move(0,-3,0);
rootNode.attachChild(cube3);
rootNode.attachChild(cube4);
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
geoms[i] = geomArray[i].clone(false);
Geometry geom = new Geometry(null, mesh);
geom.setMaterial(defaultMat);
} else {
useNormalsFlag = false;
geom.setMaterial(readMaterial(materialIndex));
if (geom.getMaterial().getAdditionalRenderState().getBlendMode() == RenderState.BlendMode.Alpha) {
geom.setQueueBucket(RenderQueue.Bucket.Transparent);
geom.setName(name + (primitives.size() > 1 ? ("_" + index) : ""));
geom.updateModelBound();
geomArray[index] = geom;
index++;
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public void makeSphereWire(BoundingSphere sphere) {
sphereGeom = new Geometry("box", new Sphere(16, 16, 10));
sphereGeom.setMaterial(new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"));
sphereGeom.getMaterial().getAdditionalRenderState().setWireframe(true);
sphereGeom.setLocalTranslation(sphere.getCenter());
rootNode.attachChild(sphereGeom);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public void setupFloor() {
Quad q = new Quad(20, 20);
q.scaleTextureCoordinates(Vector2f.UNIT_XY.mult(10));
Geometry geom = new Geometry("floor", q);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.White);
geom.setMaterial(mat);
geom.rotate(-FastMath.HALF_PI, 0, 0);
geom.center();
geom.move(0, -0.3f, 0);
geom.setShadowMode(RenderQueue.ShadowMode.Receive);
rootNode.attachChild(geom);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
Geometry g = new Geometry("marker");
g.setMesh(s);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Red);
g.setMaterial(mat);
g.setLocalTranslation(0, -100, 0);
rootNode.attachChild(g);
Geometry g2 = new Geometry("marker");
g2.setMesh(s);
mat.setColor("Color", ColorRGBA.Red);
g2.setMaterial(mat);
g2.setLocalTranslation(10, -100, 0);
rootNode.attachChild(g2);
Geometry g3 = new Geometry("marker");
g3.setMesh(s);
mat.setColor("Color", ColorRGBA.Red);
g3.setMaterial(mat);
g3.setLocalTranslation(0, -100, 10);
rootNode.attachChild(g3);
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
List<Geometry> outList = matToGeom.get(geom.getMaterial());
if (outList == null) {
if (geom.getMaterial().contentEquals(mat)){
outList = matToGeom.get(mat);
matToGeom.put(geom.getMaterial(), outList);
Geometry out = new Geometry("batch[" + (batchNum++) + "]", mesh);
out.setMaterial(mat);
out.updateModelBound();
retVal.add(out);
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
Geometry sky = new Geometry("Sky", sphereMesh);
sky.setQueueBucket(Bucket.Sky);
sky.setCullHint(Spatial.CullHint.Never);
sky.setModelBound(new BoundingSphere(Float.POSITIVE_INFINITY, Vector3f.ZERO));
texture.setWrap(Texture.WrapMode.EdgeClamp);
skyMat.setTexture("Texture", texture);
sky.setMaterial(skyMat);
内容来源于网络,如有侵权,请联系作者删除!