forked from nova/jmonkey-test
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.6 KiB
50 lines
1.6 KiB
package wow.doge.mygame.game.subsystems.level
|
|
import com.jme3.asset.AssetManager
|
|
import com.jme3.bullet.control.RigidBodyControl
|
|
import com.jme3.bullet.util.CollisionShapeFactory
|
|
import com.jme3.light.AmbientLight
|
|
import com.jme3.light.DirectionalLight
|
|
import com.jme3.math.ColorRGBA
|
|
import com.jme3.math.Vector3f
|
|
import com.jme3.renderer.ViewPort
|
|
import com.jme3.scene.Spatial
|
|
object DefaultGameLevel {
|
|
|
|
def apply(
|
|
assetManager: AssetManager,
|
|
viewPort: ViewPort
|
|
) = {
|
|
lazy val sceneModel: Spatial = assetManager.loadModel("main.scene")
|
|
lazy val sceneShape = CollisionShapeFactory.createMeshShape(
|
|
sceneModel.toNode match {
|
|
case Right(node) => node
|
|
case Left(ex) =>
|
|
throw new NotImplementedError("No fallback sceneshape")
|
|
}
|
|
)
|
|
lazy val landscape: RigidBodyControl =
|
|
new RigidBodyControl(sceneShape, 0)
|
|
|
|
viewPort.setBackgroundColor(new ColorRGBA(0.7f, 0.8f, 1f, 1f))
|
|
sceneModel.setLocalScale(2f)
|
|
sceneModel.addControl(landscape)
|
|
// discard { rootNode.attachChild(sceneModel) }
|
|
// bulletAppState.getPhysicsSpace.add(landscape)
|
|
// bulletAppState.getPhysicsSpace.add(player)
|
|
|
|
val al = new AmbientLight();
|
|
al.setColor(ColorRGBA.White.mult(1.3f));
|
|
// app.rootNode.addLight(al);
|
|
|
|
val dl = new DirectionalLight();
|
|
dl.setColor(ColorRGBA.White);
|
|
dl.setDirection(new Vector3f(2.8f, -2.8f, -2.8f).normalizeLocal());
|
|
// app.rootNode.addLight(dl);
|
|
new GameLevel(
|
|
model = sceneModel,
|
|
physicsControl = landscape,
|
|
ambientLight = al,
|
|
directionalLight = dl
|
|
)
|
|
}
|
|
}
|