use of com.jme3.scene.Spatial in project jmonkeyengine by jMonkeyEngine.
the class TestCartoonEdge method setupModel.
public void setupModel() {
Spatial model = assetManager.loadModel("Models/MonkeyHead/MonkeyHead.mesh.xml");
makeToonish(model);
model.rotate(0, FastMath.PI, 0);
// signpost.setLocalTranslation(12, 3.5f, 30);
// model.scale(0.10f);
// signpost.setShadowMode(ShadowMode.CastAndReceive);
rootNode.attachChild(model);
}
use of com.jme3.scene.Spatial in project jmonkeyengine by jMonkeyEngine.
the class TestMonkeyHead method simpleInitApp.
@Override
public void simpleInitApp() {
viewPort.setBackgroundColor(ColorRGBA.DarkGray);
Spatial bumpy = (Spatial) assetManager.loadModel("Models/MonkeyHead/MonkeyHead.mesh.xml");
rootNode.attachChild(bumpy);
lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
rootNode.attachChild(lightMdl);
// flourescent main light
pl = new PointLight();
pl.setColor(new ColorRGBA(0.88f, 0.92f, 0.95f, 1.0f));
rootNode.addLight(pl);
// sunset light
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(-0.1f, -0.7f, 1).normalizeLocal());
dl.setColor(new ColorRGBA(0.44f, 0.30f, 0.20f, 1.0f));
rootNode.addLight(dl);
// skylight
dl = new DirectionalLight();
dl.setDirection(new Vector3f(-0.6f, -1, -0.6f).normalizeLocal());
dl.setColor(new ColorRGBA(0.10f, 0.22f, 0.44f, 1.0f));
rootNode.addLight(dl);
// white ambient light
dl = new DirectionalLight();
dl.setDirection(new Vector3f(1, -0.5f, -0.1f).normalizeLocal());
dl.setColor(new ColorRGBA(0.50f, 0.40f, 0.50f, 1.0f));
rootNode.addLight(dl);
}
use of com.jme3.scene.Spatial in project jmonkeyengine by jMonkeyEngine.
the class TestTransparentCartoonEdge method simpleInitApp.
public void simpleInitApp() {
renderManager.setAlphaToCoverage(true);
cam.setLocation(new Vector3f(0.14914267f, 0.58147097f, 4.7686534f));
cam.setRotation(new Quaternion(-0.0044764364f, 0.9767943f, 0.21314798f, 0.020512417f));
// cam.setLocation(new Vector3f(2.0606942f, 3.20342f, 6.7860126f));
// cam.setRotation(new Quaternion(-0.017481906f, 0.98241085f, -0.12393151f, -0.13857932f));
viewPort.setBackgroundColor(ColorRGBA.DarkGray);
Quad q = new Quad(20, 20);
q.scaleTextureCoordinates(Vector2f.UNIT_XY.mult(5));
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.Receive);
rootNode.attachChild(geom);
// create the geometry and attach it
Spatial teaGeom = assetManager.loadModel("Models/Tree/Tree.mesh.j3o");
teaGeom.setQueueBucket(Bucket.Transparent);
teaGeom.setShadowMode(ShadowMode.Cast);
makeToonish(teaGeom);
AmbientLight al = new AmbientLight();
al.setColor(ColorRGBA.White.mult(2));
rootNode.addLight(al);
DirectionalLight dl1 = new DirectionalLight();
dl1.setDirection(new Vector3f(1, -1, 1).normalizeLocal());
dl1.setColor(new ColorRGBA(0.965f, 0.949f, 0.772f, 1f).mult(0.7f));
rootNode.addLight(dl1);
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
dl.setColor(new ColorRGBA(0.965f, 0.949f, 0.772f, 1f).mult(0.7f));
rootNode.addLight(dl);
rootNode.attachChild(teaGeom);
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
CartoonEdgeFilter toon = new CartoonEdgeFilter();
toon.setEdgeWidth(0.5f);
toon.setEdgeIntensity(1.0f);
toon.setNormalThreshold(0.8f);
fpp.addFilter(toon);
viewPort.addProcessor(fpp);
}
use of com.jme3.scene.Spatial in project jmonkeyengine by jMonkeyEngine.
the class VRGuiManager method positionGuiNow.
/**
* Position the GUI without delay.
* @param tpf the time per frame.
*/
protected void positionGuiNow(float tpf) {
if (environment != null) {
wantsReposition = false;
if (environment.isInVR() == false) {
return;
}
guiQuadNode.setLocalScale(guiDistance * guiScale * 4f, 4f * guiDistance * guiScale, 1f);
switch(posMode) {
case MANUAL:
case AUTO_CAM_ALL_SKIP_PITCH:
case AUTO_CAM_ALL:
if (camLeft != null && camRight != null) {
// get middle point
temppos.set(camLeft.getLocation()).interpolateLocal(camRight.getLocation(), 0.5f);
positionTo(temppos, camLeft.getRotation(), tpf);
}
rotateScreenTo(camLeft.getRotation(), tpf);
break;
case AUTO_OBSERVER_POS_CAM_ROTATION:
Object obs = environment.getObserver();
if (obs != null) {
if (obs instanceof Camera) {
positionTo(((Camera) obs).getLocation(), camLeft.getRotation(), tpf);
} else {
positionTo(((Spatial) obs).getWorldTranslation(), camLeft.getRotation(), tpf);
}
}
rotateScreenTo(camLeft.getRotation(), tpf);
break;
case AUTO_OBSERVER_ALL:
case AUTO_OBSERVER_ALL_CAMHEIGHT:
obs = environment.getObserver();
if (obs != null) {
Quaternion q;
if (obs instanceof Camera) {
q = ((Camera) obs).getRotation();
temppos.set(((Camera) obs).getLocation());
} else {
q = ((Spatial) obs).getWorldRotation();
temppos.set(((Spatial) obs).getWorldTranslation());
}
if (posMode == VRGUIPositioningMode.AUTO_OBSERVER_ALL_CAMHEIGHT) {
temppos.y = camLeft.getLocation().y;
}
positionTo(temppos, q, tpf);
rotateScreenTo(q, tpf);
}
break;
}
} else {
throw new IllegalStateException("VR GUI manager is not attached to any environment.");
}
}
use of com.jme3.scene.Spatial in project jmonkeyengine by jMonkeyEngine.
the class VRViewManagerOSVR method setupViewBuffers.
private ViewPort setupViewBuffers(Camera cam, String viewName) {
if (environment != null) {
if (environment.getApplication() != null) {
// create offscreen framebuffer
FrameBuffer offBufferLeft = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1);
//offBufferLeft.setSrgb(true);
//setup framebuffer's texture
Texture2D offTex = new Texture2D(cam.getWidth(), cam.getHeight(), Image.Format.RGBA8);
offTex.setMinFilter(Texture.MinFilter.BilinearNoMipMaps);
offTex.setMagFilter(Texture.MagFilter.Bilinear);
//setup framebuffer to use texture
offBufferLeft.setDepthBuffer(Image.Format.Depth);
offBufferLeft.setColorTexture(offTex);
ViewPort viewPort = environment.getApplication().getRenderManager().createPreView(viewName, cam);
viewPort.setClearFlags(true, true, true);
viewPort.setBackgroundColor(ColorRGBA.Black);
Iterator<Spatial> spatialIter = environment.getApplication().getViewPort().getScenes().iterator();
while (spatialIter.hasNext()) {
viewPort.attachScene(spatialIter.next());
}
//set viewport to render to offscreen framebuffer
viewPort.setOutputFrameBuffer(offBufferLeft);
return viewPort;
} else {
throw new IllegalStateException("This VR environment is not attached to any application.");
}
} else {
throw new IllegalStateException("This VR view manager is not attached to any VR environment.");
}
}
Aggregations