use of com.jme3.material.Material in project jmonkeyengine by jMonkeyEngine.
the class HDRRenderer method initialize.
public void initialize(RenderManager rm, ViewPort vp) {
if (!enabled)
return;
renderer = rm.getRenderer();
renderManager = rm;
viewPort = vp;
// loadInitial()
fsQuad = new Picture("HDR Fullscreen Quad");
Format lumFmt = Format.RGB8;
scene64FB = new FrameBuffer(64, 64, 1);
scene64 = new Texture2D(64, 64, lumFmt);
scene64FB.setColorTexture(scene64);
scene64.setMagFilter(fbMagFilter);
scene64.setMinFilter(fbMinFilter);
scene8FB = new FrameBuffer(8, 8, 1);
scene8 = new Texture2D(8, 8, lumFmt);
scene8FB.setColorTexture(scene8);
scene8.setMagFilter(fbMagFilter);
scene8.setMinFilter(fbMinFilter);
scene1FB[0] = new FrameBuffer(1, 1, 1);
scene1[0] = new Texture2D(1, 1, lumFmt);
scene1FB[0].setColorTexture(scene1[0]);
scene1FB[1] = new FrameBuffer(1, 1, 1);
scene1[1] = new Texture2D(1, 1, lumFmt);
scene1FB[1].setColorTexture(scene1[1]);
// prepare tonemap shader
tone = new Material(manager, "Common/MatDefs/Hdr/ToneMap.j3md");
tone.setFloat("A", 0.18f);
tone.setFloat("White", 100);
// load();
int w = vp.getCamera().getWidth();
int h = vp.getCamera().getHeight();
reshape(vp, w, h);
}
use of com.jme3.material.Material in project jmonkeyengine by jMonkeyEngine.
the class OpaqueComparator method compare.
@Override
public int compare(Geometry o1, Geometry o2) {
Material m1 = o1.getMaterial();
Material m2 = o2.getMaterial();
int compareResult = Integer.compare(m1.getSortId(), m2.getSortId());
if (compareResult == 0) {
// use the same shader.
// sort front-to-back then.
float d1 = distanceToCam(o1);
float d2 = distanceToCam(o2);
if (d1 == d2)
return 0;
else if (d1 < d2)
return -1;
else
return 1;
} else {
return compareResult;
}
}
use of com.jme3.material.Material in project jmonkeyengine by jMonkeyEngine.
the class CubeField method createFirstCube.
private Geometry createFirstCube() {
Vector3f loc = player.getLocalTranslation();
loc.addLocal(4, 0, 0);
Box b = new Box(1, 1, 1);
Geometry geom = new Geometry("Box", b);
geom.setLocalTranslation(loc);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Blue);
geom.setMaterial(mat);
return geom;
}
use of com.jme3.material.Material in project jmonkeyengine by jMonkeyEngine.
the class CubeField method randomizeCube.
/**
* Randomly Places a cube on the map between 30 and 90 paces away from player
*/
private void randomizeCube() {
Geometry cube = fcube.clone();
int playerX = (int) player.getLocalTranslation().getX();
int playerZ = (int) player.getLocalTranslation().getZ();
// float x = FastMath.nextRandomInt(playerX + difficulty + 10, playerX + difficulty + 150);
float x = FastMath.nextRandomInt(playerX + difficulty + 30, playerX + difficulty + 90);
float z = FastMath.nextRandomInt(playerZ - difficulty - 50, playerZ + difficulty + 50);
cube.getLocalTranslation().set(x, 0, z);
// playerX+difficulty+30,playerX+difficulty+90
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
if (!solidBox) {
mat.getAdditionalRenderState().setWireframe(true);
}
mat.setColor("Color", obstacleColors.get(FastMath.nextRandomInt(0, obstacleColors.size() - 1)));
cube.setMaterial(mat);
rootNode.attachChild(cube);
cubeField.add(cube);
}
use of com.jme3.material.Material in project jmonkeyengine by jMonkeyEngine.
the class CubeField method createPlayer.
private Node createPlayer() {
Dome b = new Dome(Vector3f.ZERO, 10, 100, 1);
Geometry playerMesh = new Geometry("Box", b);
playerMaterial = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
playerMaterial.setColor("Color", ColorRGBA.Red);
playerMesh.setMaterial(playerMaterial);
playerMesh.setName("player");
Box floor = new Box(100, 0, 100);
Geometry floorMesh = new Geometry("Box", floor);
Vector3f translation = Vector3f.ZERO.add(playerMesh.getLocalTranslation().getX(), playerMesh.getLocalTranslation().getY() - 1, 0);
floorMesh.setLocalTranslation(translation);
floorMaterial = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
floorMaterial.setColor("Color", ColorRGBA.LightGray);
floorMesh.setMaterial(floorMaterial);
floorMesh.setName("floor");
Node playerNode = new Node();
playerNode.attachChild(playerMesh);
playerNode.attachChild(floorMesh);
return playerNode;
}
Aggregations