Package net.anzix.fsz.world

Source Code of net.anzix.fsz.world.FlatTerrain

package net.anzix.fsz.world;

import com.ardor3d.math.ColorRGBA;
import com.ardor3d.math.Vector3;
import com.ardor3d.scenegraph.shape.Box;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import net.anzix.fsz.NodeRepository;
import net.anzix.fsz.eventbus.Event;
import net.anzix.fsz.eventbus.EventListener;
import net.anzix.fsz.eventbus.event.Init;
import net.anzix.fsz.math.Double2D;

/**
*
* @author elek
*/
@Singleton
public class FlatTerrain implements EventListener, Terrain {

    double width = 100;

    double height = 100;

    @Inject
    private NodeRepository nodes;
   
    @Inject
    Physics physics;

    public void onEvent(Event event) {
        if (event instanceof Init) {
            Box floor = new Box("Floor", new Vector3(), width, 1, height);
            floor.setTranslation(0, -30, 0);
           // floor.setRandomColors();
            floor.setSolidColor(ColorRGBA.GREEN);
            nodes.attachToParent(NodeRepository.ROOT_NODE,floor);
            nodes.getNode(NodeRepository.ROOT_NODE).updateGeometricState(0);
           
            physics.addFloor(floor);
           
        }
    }

    public Double2D getSize() {
        return new Double2D(width, height);
    }
}
TOP

Related Classes of net.anzix.fsz.world.FlatTerrain

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.