use of com.jme3.scene.Geometry in project jmonkeyengine by jMonkeyEngine.
the class HelloPhysics method makeCannonBall.
/** This method creates one individual physical cannon ball.
* By defaul, the ball is accelerated and flies
* from the camera position in the camera direction.*/
public void makeCannonBall() {
/** Create a cannon ball geometry and attach to scene graph. */
Geometry ball_geo = new Geometry("cannon ball", sphere);
ball_geo.setMaterial(stone_mat);
rootNode.attachChild(ball_geo);
/** Position the cannon ball */
ball_geo.setLocalTranslation(cam.getLocation());
/** Make the ball physcial with a mass > 0.0f */
ball_phy = new RigidBodyControl(1f);
/** Add physical ball to physics space. */
ball_geo.addControl(ball_phy);
bulletAppState.getPhysicsSpace().add(ball_phy);
/** Accelerate the physcial ball to shoot it. */
ball_phy.setLinearVelocity(cam.getDirection().mult(25));
}
use of com.jme3.scene.Geometry in project jmonkeyengine by jMonkeyEngine.
the class TestCameraNode method simpleInitApp.
public void simpleInitApp() {
// load a teapot model
teaGeom = (Geometry) assetManager.loadModel("Models/Teapot/Teapot.obj");
Material mat = new Material(assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
teaGeom.setMaterial(mat);
//create a node to attach the geometry and the camera node
teaNode = new Node("teaNode");
teaNode.attachChild(teaGeom);
rootNode.attachChild(teaNode);
// create a floor
mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
Geometry ground = new Geometry("ground", new Quad(50, 50));
ground.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
ground.setLocalTranslation(-25, -1, 25);
ground.setMaterial(mat);
rootNode.attachChild(ground);
//creating the camera Node
camNode = new CameraNode("CamNode", cam);
//Setting the direction to Spatial to camera, this means the camera will copy the movements of the Node
camNode.setControlDir(ControlDirection.SpatialToCamera);
//attaching the camNode to the teaNode
teaNode.attachChild(camNode);
//setting the local translation of the cam node to move it away from the teanNode a bit
camNode.setLocalTranslation(new Vector3f(-10, 0, 0));
//setting the camNode to look at the teaNode
camNode.lookAt(teaNode.getLocalTranslation(), Vector3f.UNIT_Y);
//disable the default 1st-person flyCam (don't forget this!!)
flyCam.setEnabled(false);
registerInput();
}
use of com.jme3.scene.Geometry in project jmonkeyengine by jMonkeyEngine.
the class TestLightRadius method simpleInitApp.
@Override
public void simpleInitApp() {
Torus torus = new Torus(10, 6, 1, 3);
// Torus torus = new Torus(50, 30, 1, 3);
Geometry g = new Geometry("Torus Geom", torus);
g.rotate(-FastMath.HALF_PI, 0, 0);
g.center();
// g.move(0, 1, 0);
Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
mat.setFloat("Shininess", 32f);
mat.setBoolean("UseMaterialColors", true);
mat.setColor("Ambient", ColorRGBA.Black);
mat.setColor("Diffuse", ColorRGBA.White);
mat.setColor("Specular", ColorRGBA.White);
// mat.setBoolean("VertexLighting", true);
// mat.setBoolean("LowQuality", true);
g.setMaterial(mat);
rootNode.attachChild(g);
lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
rootNode.attachChild(lightMdl);
pl = new PointLight();
pl.setColor(ColorRGBA.Green);
pl.setRadius(4f);
rootNode.addLight(pl);
DirectionalLight dl = new DirectionalLight();
dl.setColor(ColorRGBA.Red);
dl.setDirection(new Vector3f(0, 1, 0));
rootNode.addLight(dl);
}
use of com.jme3.scene.Geometry in project jmonkeyengine by jMonkeyEngine.
the class TestManyLightsSingle method reloadScene.
protected void reloadScene(Geometry g, Geometry boxGeo, Node cubeNodes) {
MaterialDebugAppState debug = stateManager.getState(MaterialDebugAppState.class);
Material m = debug.reloadMaterial(g.getMaterial());
if (m != null) {
g.setMaterial(m);
}
m = debug.reloadMaterial(boxGeo.getMaterial());
if (m != null) {
cubeNodes.setMaterial(m);
}
}
use of com.jme3.scene.Geometry in project jmonkeyengine by jMonkeyEngine.
the class TestPointLightShadows method simpleInitApp.
@Override
public void simpleInitApp() {
flyCam.setMoveSpeed(10);
cam.setLocation(new Vector3f(0.040581334f, 1.7745866f, 6.155161f));
cam.setRotation(new Quaternion(4.3868728E-5f, 0.9999293f, -0.011230096f, 0.0039059948f));
al = new AmbientLight(ColorRGBA.White.mult(0.02f));
rootNode.addLight(al);
Node scene = (Node) assetManager.loadModel("Models/Test/CornellBox.j3o");
scene.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
rootNode.attachChild(scene);
rootNode.getChild("Cube").setShadowMode(RenderQueue.ShadowMode.Receive);
lightNode = (Node) rootNode.getChild("Lamp");
Geometry lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
//Geometry lightMdl = new Geometry("Light", new Box(.1f,.1f,.1f));
lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
lightMdl.setShadowMode(RenderQueue.ShadowMode.Off);
lightNode.attachChild(lightMdl);
//lightMdl.setLocalTranslation(lightNode.getLocalTranslation());
Geometry box = new Geometry("box", new Box(0.2f, 0.2f, 0.2f));
//Geometry lightMdl = new Geometry("Light", new Box(.1f,.1f,.1f));
box.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
box.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
rootNode.attachChild(box);
box.setLocalTranslation(-1f, 0.5f, -2);
plsr = new PointLightShadowRenderer(assetManager, SHADOWMAP_SIZE);
plsr.setLight((PointLight) scene.getLocalLightList().get(0));
plsr.setEdgeFilteringMode(EdgeFilteringMode.PCF4);
plsr.setShadowZExtend(15);
plsr.setShadowZFadeLength(5);
plsr.setShadowIntensity(0.9f);
// plsr.setFlushQueues(false);
//plsr.displayFrustum();
plsr.displayDebug();
viewPort.addProcessor(plsr);
plsf = new PointLightShadowFilter(assetManager, SHADOWMAP_SIZE);
plsf.setLight((PointLight) scene.getLocalLightList().get(0));
plsf.setShadowZExtend(15);
plsf.setShadowZFadeLength(5);
plsf.setShadowIntensity(0.8f);
plsf.setEdgeFilteringMode(EdgeFilteringMode.PCF4);
plsf.setEnabled(false);
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
fpp.addFilter(plsf);
viewPort.addProcessor(fpp);
inputManager.addListener(this, "ShadowUp", "ShadowDown");
ShadowTestUIManager uiMan = new ShadowTestUIManager(assetManager, plsr, plsf, guiNode, inputManager, viewPort);
}
Aggregations