Search in sources :

Example 81 with Material

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);
}
Also used : Texture2D(com.jme3.texture.Texture2D) Format(com.jme3.texture.Image.Format) Picture(com.jme3.ui.Picture) Material(com.jme3.material.Material) FrameBuffer(com.jme3.texture.FrameBuffer)

Example 82 with Material

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;
    }
}
Also used : Material(com.jme3.material.Material)

Example 83 with Material

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;
}
Also used : Geometry(com.jme3.scene.Geometry) Vector3f(com.jme3.math.Vector3f) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material)

Example 84 with Material

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);
}
Also used : Geometry(com.jme3.scene.Geometry) Material(com.jme3.material.Material)

Example 85 with Material

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;
}
Also used : Geometry(com.jme3.scene.Geometry) Dome(com.jme3.scene.shape.Dome) Vector3f(com.jme3.math.Vector3f) Node(com.jme3.scene.Node) Material(com.jme3.material.Material) Box(com.jme3.scene.shape.Box)

Aggregations

Material (com.jme3.material.Material)310 Geometry (com.jme3.scene.Geometry)191 Vector3f (com.jme3.math.Vector3f)120 Box (com.jme3.scene.shape.Box)81 Texture (com.jme3.texture.Texture)70 Spatial (com.jme3.scene.Spatial)53 DirectionalLight (com.jme3.light.DirectionalLight)49 ColorRGBA (com.jme3.math.ColorRGBA)47 Node (com.jme3.scene.Node)47 Sphere (com.jme3.scene.shape.Sphere)44 Quaternion (com.jme3.math.Quaternion)31 Quad (com.jme3.scene.shape.Quad)26 ArrayList (java.util.ArrayList)25 Texture2D (com.jme3.texture.Texture2D)21 KeyTrigger (com.jme3.input.controls.KeyTrigger)20 Mesh (com.jme3.scene.Mesh)20 RigidBodyControl (com.jme3.bullet.control.RigidBodyControl)19 TextureKey (com.jme3.asset.TextureKey)18 TerrainQuad (com.jme3.terrain.geomipmap.TerrainQuad)18 ParticleEmitter (com.jme3.effect.ParticleEmitter)17