use of com.jme3.renderer.ViewPort in project jmonkeyengine by jMonkeyEngine.
the class TestPostWater method createBox.
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);
}
use of com.jme3.renderer.ViewPort in project jmonkeyengine by jMonkeyEngine.
the class EnvironmentCamera method createOffScreenFrameBuffer.
/**
* create an offscreen frame buffer.
*
* @param mapSize
* @param offView
* @return
*/
protected FrameBuffer createOffScreenFrameBuffer(int mapSize, ViewPort offView) {
// create offscreen framebuffer
final FrameBuffer offBuffer = new FrameBuffer(mapSize, mapSize, 1);
offBuffer.setDepthBuffer(Image.Format.Depth);
offView.setOutputFrameBuffer(offBuffer);
return offBuffer;
}
use of com.jme3.renderer.ViewPort in project jmonkeyengine by jMonkeyEngine.
the class WaterFilter method initFilter.
@Override
protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
if (reflectionScene == null) {
reflectionScene = vp.getScenes().get(0);
DirectionalLight l = findLight((Node) reflectionScene);
if (l != null) {
lightDirection = l.getDirection();
}
}
this.renderManager = renderManager;
this.viewPort = vp;
reflectionPass = new Pass();
reflectionPass.init(renderManager.getRenderer(), reflectionMapSize, reflectionMapSize, Format.RGBA8, Format.Depth);
reflectionCam = new Camera(reflectionMapSize, reflectionMapSize);
reflectionView = new ViewPort("reflectionView", reflectionCam);
reflectionView.setClearFlags(true, true, true);
reflectionView.attachScene(reflectionScene);
reflectionView.setOutputFrameBuffer(reflectionPass.getRenderFrameBuffer());
plane = new Plane(Vector3f.UNIT_Y, new Vector3f(0, waterHeight, 0).dot(Vector3f.UNIT_Y));
reflectionProcessor = new ReflectionProcessor(reflectionCam, reflectionPass.getRenderFrameBuffer(), plane);
reflectionProcessor.setReflectionClipPlane(plane);
reflectionView.addProcessor(reflectionProcessor);
normalTexture = (Texture2D) manager.loadTexture("Common/MatDefs/Water/Textures/water_normalmap.dds");
if (foamTexture == null) {
foamTexture = (Texture2D) manager.loadTexture("Common/MatDefs/Water/Textures/foam.jpg");
}
if (causticsTexture == null) {
causticsTexture = (Texture2D) manager.loadTexture("Common/MatDefs/Water/Textures/caustics.jpg");
}
heightTexture = (Texture2D) manager.loadTexture("Common/MatDefs/Water/Textures/heightmap.jpg");
normalTexture.setWrap(WrapMode.Repeat);
foamTexture.setWrap(WrapMode.Repeat);
causticsTexture.setWrap(WrapMode.Repeat);
heightTexture.setWrap(WrapMode.Repeat);
material = new Material(manager, "Common/MatDefs/Water/Water.j3md");
material.setTexture("HeightMap", heightTexture);
material.setTexture("CausticsMap", causticsTexture);
material.setTexture("FoamMap", foamTexture);
material.setTexture("NormalMap", normalTexture);
material.setTexture("ReflectionMap", reflectionPass.getRenderedTexture());
material.setFloat("WaterTransparency", waterTransparency);
material.setFloat("NormalScale", normalScale);
material.setFloat("R0", refractionConstant);
material.setFloat("MaxAmplitude", maxAmplitude);
material.setVector3("LightDir", lightDirection);
material.setColor("LightColor", lightColor);
material.setFloat("ShoreHardness", shoreHardness);
material.setFloat("RefractionStrength", refractionStrength);
material.setFloat("WaveScale", waveScale);
material.setVector3("FoamExistence", foamExistence);
material.setFloat("SunScale", sunScale);
material.setVector3("ColorExtinction", colorExtinction);
material.setFloat("Shininess", shininess);
material.setColor("WaterColor", waterColor);
material.setColor("DeepWaterColor", deepWaterColor);
material.setVector2("WindDirection", windDirection);
material.setFloat("FoamHardness", foamHardness);
material.setBoolean("UseRipples", useRipples);
material.setBoolean("UseHQShoreline", useHQShoreline);
material.setBoolean("UseSpecular", useSpecular);
material.setBoolean("UseFoam", useFoam);
material.setBoolean("UseCaustics", useCaustics);
material.setBoolean("UseRefraction", useRefraction);
material.setFloat("ReflectionDisplace", reflectionDisplace);
material.setFloat("FoamIntensity", foamIntensity);
material.setFloat("UnderWaterFogDistance", underWaterFogDistance);
material.setFloat("CausticsIntensity", causticsIntensity);
if (center != null) {
material.setVector3("Center", center);
material.setFloat("Radius", radius * radius);
material.setBoolean("SquareArea", shapeType == AreaShape.Square);
}
material.setFloat("WaterHeight", waterHeight);
}
use of com.jme3.renderer.ViewPort in project jmonkeyengine by jMonkeyEngine.
the class TestBareBonesApp method initialize.
@Override
public void initialize() {
super.initialize();
System.out.println("Initialize");
// create a box
boxGeom = new Geometry("Box", new Box(2, 2, 2));
// load some default material
boxGeom.setMaterial(assetManager.loadMaterial("Interface/Logo/Logo.j3m"));
// attach box to display in primary viewport
viewPort.attachScene(boxGeom);
}
use of com.jme3.renderer.ViewPort in project jmonkeyengine by jMonkeyEngine.
the class PosterizationFilter method initFilter.
@Override
protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
material = new Material(manager, "Common/MatDefs/Post/Posterization.j3md");
material.setInt("NumColors", numColors);
material.setFloat("Gamma", gamma);
material.setFloat("Strength", strength);
}
Aggregations