Search in sources :

Example 71 with AssetManager

use of com.jme3.asset.AssetManager in project jmonkeyengine by jMonkeyEngine.

the class AssetLinkNode method read.

@Override
public void read(JmeImporter e) throws IOException {
    super.read(e);
    InputCapsule capsule = e.getCapsule(this);
    BinaryImporter importer = BinaryImporter.getInstance();
    AssetManager loaderManager = e.getAssetManager();
    assetLoaderKeys = (ArrayList<ModelKey>) capsule.readSavableArrayList("assetLoaderKeyList", new ArrayList<ModelKey>());
    for (Iterator<ModelKey> it = assetLoaderKeys.iterator(); it.hasNext(); ) {
        ModelKey modelKey = it.next();
        AssetInfo info = loaderManager.locateAsset(modelKey);
        Spatial child = null;
        if (info != null) {
            child = (Spatial) importer.load(info);
        }
        if (child != null) {
            child.parent = this;
            children.add(child);
            assetChildren.put(modelKey, child);
        } else {
            Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Cannot locate {0} for asset link node {1}", new Object[] { modelKey, key });
        }
    }
}
Also used : BinaryImporter(com.jme3.export.binary.BinaryImporter) ModelKey(com.jme3.asset.ModelKey) AssetManager(com.jme3.asset.AssetManager) InputCapsule(com.jme3.export.InputCapsule) AssetInfo(com.jme3.asset.AssetInfo)

Example 72 with AssetManager

use of com.jme3.asset.AssetManager in project jmonkeyengine by jMonkeyEngine.

the class StaticPassLightingLogic method makeCurrent.

@Override
public Shader makeCurrent(AssetManager assetManager, RenderManager renderManager, EnumSet<Caps> rendererCaps, LightList lights, DefineList defines) {
    // TODO: if it ever changes that render isn't called
    // right away with the same geometry after makeCurrent, it would be
    // a problem.
    // Do a radix sort.
    tempDirLights.clear();
    tempPointLights.clear();
    tempSpotLights.clear();
    for (Light light : lights) {
        switch(light.getType()) {
            case Directional:
                tempDirLights.add((DirectionalLight) light);
                break;
            case Point:
                tempPointLights.add((PointLight) light);
                break;
            case Spot:
                tempSpotLights.add((SpotLight) light);
                break;
        }
    }
    defines.set(numDirLightsDefineId, tempDirLights.size());
    defines.set(numPointLightsDefineId, tempPointLights.size());
    defines.set(numSpotLightsDefineId, tempSpotLights.size());
    return techniqueDef.getShader(assetManager, rendererCaps, defines);
}
Also used : DirectionalLight(com.jme3.light.DirectionalLight) SpotLight(com.jme3.light.SpotLight) Light(com.jme3.light.Light) PointLight(com.jme3.light.PointLight)

Example 73 with AssetManager

use of com.jme3.asset.AssetManager 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 74 with AssetManager

use of com.jme3.asset.AssetManager 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 75 with AssetManager

use of com.jme3.asset.AssetManager 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)213 Geometry (com.jme3.scene.Geometry)138 Vector3f (com.jme3.math.Vector3f)137 Box (com.jme3.scene.shape.Box)73 Texture (com.jme3.texture.Texture)73 DirectionalLight (com.jme3.light.DirectionalLight)66 Node (com.jme3.scene.Node)52 Sphere (com.jme3.scene.shape.Sphere)47 Quaternion (com.jme3.math.Quaternion)46 Spatial (com.jme3.scene.Spatial)43 FilterPostProcessor (com.jme3.post.FilterPostProcessor)38 ColorRGBA (com.jme3.math.ColorRGBA)37 KeyTrigger (com.jme3.input.controls.KeyTrigger)31 RigidBodyControl (com.jme3.bullet.control.RigidBodyControl)27 BulletAppState (com.jme3.bullet.BulletAppState)26 Quad (com.jme3.scene.shape.Quad)23 TextureKey (com.jme3.asset.TextureKey)22 ActionListener (com.jme3.input.controls.ActionListener)21 AmbientLight (com.jme3.light.AmbientLight)20 Texture2D (com.jme3.texture.Texture2D)20