use of com.jme3.scene.shape.Quad in project jmonkeyengine by jMonkeyEngine.
the class TestBitmapText3D method simpleInitApp.
@Override
public void simpleInitApp() {
Quad q = new Quad(6, 3);
Geometry g = new Geometry("quad", q);
g.setLocalTranslation(0, -3, -0.0001f);
g.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
rootNode.attachChild(g);
BitmapFont fnt = assetManager.loadFont("Interface/Fonts/Default.fnt");
BitmapText txt = new BitmapText(fnt, false);
txt.setBox(new Rectangle(0, 0, 6, 3));
txt.setQueueBucket(Bucket.Transparent);
txt.setSize(0.5f);
txt.setText(txtB);
rootNode.attachChild(txt);
}
use of com.jme3.scene.shape.Quad in project jmonkeyengine by jMonkeyEngine.
the class TestTangentGen method simpleInitApp.
@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);
}
use of com.jme3.scene.shape.Quad in project jmonkeyengine by jMonkeyEngine.
the class TestTransparentShadow method simpleInitApp.
public void simpleInitApp() {
cam.setLocation(new Vector3f(5.700248f, 6.161693f, 5.1404157f));
cam.setRotation(new Quaternion(-0.09441641f, 0.8993388f, -0.24089815f, -0.35248178f));
viewPort.setBackgroundColor(ColorRGBA.DarkGray);
Quad q = new Quad(20, 20);
q.scaleTextureCoordinates(Vector2f.UNIT_XY.mult(10));
TangentBinormalGenerator.generate(q);
Geometry geom = new Geometry("floor", q);
Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
geom.setMaterial(mat);
geom.rotate(-FastMath.HALF_PI, 0, 0);
geom.center();
geom.setShadowMode(ShadowMode.CastAndReceive);
rootNode.attachChild(geom);
AmbientLight al = new AmbientLight();
al.setColor(ColorRGBA.White.mult(0.7f));
rootNode.addLight(al);
DirectionalLight dl1 = new DirectionalLight();
dl1.setDirection(new Vector3f(0, -1, 0.5f).normalizeLocal());
dl1.setColor(ColorRGBA.White.mult(1.5f));
rootNode.addLight(dl1);
// create the geometry and attach it
Spatial tree = assetManager.loadModel("Models/Tree/Tree.mesh.j3o");
tree.setQueueBucket(Bucket.Transparent);
tree.setShadowMode(ShadowMode.CastAndReceive);
rootNode.attachChild(tree);
// Uses Texture from jme3-test-data library!
ParticleEmitter fire = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 30);
Material mat_red = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
mat_red.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/flame.png"));
fire.setShadowMode(ShadowMode.Cast);
fire.setMaterial(mat_red);
fire.setImagesX(2);
// 2x2 texture animation
fire.setImagesY(2);
// red
fire.setEndColor(new ColorRGBA(1f, 0f, 0f, 1f));
// yellow
fire.setStartColor(new ColorRGBA(1f, 1f, 0f, 0.5f));
fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 2, 0));
fire.setStartSize(0.6f);
fire.setEndSize(0.1f);
fire.setGravity(0, 0, 0);
fire.setLowLife(0.5f);
fire.setHighLife(1.5f);
fire.getParticleInfluencer().setVelocityVariation(0.3f);
fire.setLocalTranslation(5.0f, 0, 1.0f);
fire.setLocalScale(0.3f);
fire.setQueueBucket(Bucket.Translucent);
rootNode.attachChild(fire);
Material mat2 = assetManager.loadMaterial("Common/Materials/RedColor.j3m");
Geometry ball = new Geometry("sphere", new Sphere(16, 16, 0.5f));
ball.setMaterial(mat2);
ball.setShadowMode(ShadowMode.CastAndReceive);
rootNode.attachChild(ball);
ball.setLocalTranslation(-1.0f, 1.5f, 1.0f);
final DirectionalLightShadowRenderer dlsRenderer = new DirectionalLightShadowRenderer(assetManager, 1024, 1);
dlsRenderer.setLight(dl1);
dlsRenderer.setLambda(0.55f);
dlsRenderer.setShadowIntensity(0.8f);
dlsRenderer.setShadowCompareMode(CompareMode.Software);
dlsRenderer.setEdgeFilteringMode(EdgeFilteringMode.Nearest);
dlsRenderer.displayDebug();
viewPort.addProcessor(dlsRenderer);
inputManager.addMapping("stabilize", new KeyTrigger(KeyInput.KEY_B));
inputManager.addListener(new ActionListener() {
@Override
public void onAction(String name, boolean isPressed, float tpf) {
if (name.equals("stabilize") && isPressed) {
dlsRenderer.setEnabledStabilization(!dlsRenderer.isEnabledStabilization());
}
}
}, "stabilize");
}
use of com.jme3.scene.shape.Quad in project jmonkeyengine by jMonkeyEngine.
the class TestTwoSideLighting method simpleInitApp.
@Override
public void simpleInitApp() {
// Two-sided lighting requires single pass.
renderManager.setPreferredLightMode(TechniqueDef.LightMode.SinglePass);
renderManager.setSinglePassLightBatchSize(4);
cam.setLocation(new Vector3f(5.936224f, 3.3759952f, -3.3202777f));
cam.setRotation(new Quaternion(0.16265652f, -0.4811838f, 0.09137692f, 0.8565368f));
Geometry quadGeom = new Geometry("quad", new Quad(1, 1));
quadGeom.move(1, 0, 0);
Material mat1 = assetManager.loadMaterial("Textures/BumpMapTest/SimpleBump.j3m");
// Display both front and back faces.
mat1.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off);
quadGeom.setMaterial(mat1);
// SimpleBump material requires tangents.
TangentBinormalGenerator.generate(quadGeom);
rootNode.attachChild(quadGeom);
Geometry teapot = (Geometry) assetManager.loadModel("Models/Teapot/Teapot.obj");
teapot.move(-1, 0, 0);
teapot.setLocalScale(2f);
Material mat2 = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
mat2.setFloat("Shininess", 25);
mat2.setBoolean("UseMaterialColors", true);
mat2.setColor("Ambient", ColorRGBA.Black);
mat2.setColor("Diffuse", ColorRGBA.Gray);
mat2.setColor("Specular", ColorRGBA.Gray);
// Only display backfaces.
mat2.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Front);
teapot.setMaterial(mat2);
rootNode.attachChild(teapot);
lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
lightMdl.getMesh().setStatic();
rootNode.attachChild(lightMdl);
pl = new PointLight();
pl.setColor(ColorRGBA.White);
pl.setRadius(4f);
rootNode.addLight(pl);
}
use of com.jme3.scene.shape.Quad in project jmonkeyengine by jMonkeyEngine.
the class TestChaseCameraAppState method simpleInitApp.
public void simpleInitApp() {
// Load a teapot model
teaGeom = (Geometry) assetManager.loadModel("Models/Teapot/Teapot.obj");
Material mat_tea = new Material(assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
teaGeom.setMaterial(mat_tea);
rootNode.attachChild(teaGeom);
// Load a floor model
Material mat_ground = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat_ground.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_ground);
rootNode.attachChild(ground);
//disable the flyCam
stateManager.detach(stateManager.getState(FlyCamAppState.class));
// Enable a chase cam
ChaseCameraAppState chaseCamAS = new ChaseCameraAppState();
chaseCamAS.setTarget(teaGeom);
stateManager.attach(chaseCamAS);
//Uncomment this to invert the camera's vertical rotation Axis
//chaseCamAS.setInvertVerticalAxis(true);
//Uncomment this to invert the camera's horizontal rotation Axis
//chaseCamAS.setInvertHorizontalAxis(true);
//Uncomment this to enable rotation when the middle mouse button is pressed (like Blender)
//WARNING : setting this trigger disable the rotation on right and left mouse button click
//chaseCamAS.setToggleRotationTrigger(new MouseButtonTrigger(MouseInput.BUTTON_MIDDLE));
//Uncomment this to set mutiple triggers to enable rotation of the cam
//Here space bar and middle mouse button
//chaseCamAS.setToggleRotationTrigger(new MouseButtonTrigger(MouseInput.BUTTON_MIDDLE),new KeyTrigger(KeyInput.KEY_SPACE));
//registering inputs for target's movement
registerInput();
}
Aggregations