Testing out JmonkeyEngine to make a game in Scala with Akka Actors within a pure FP layer
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

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. package wow.doge.mygame.game.subsystems.level
  2. import com.jme3.asset.AssetManager
  3. import com.jme3.bullet.control.RigidBodyControl
  4. import com.jme3.bullet.util.CollisionShapeFactory
  5. import com.jme3.light.AmbientLight
  6. import com.jme3.light.DirectionalLight
  7. import com.jme3.math.ColorRGBA
  8. import com.jme3.math.Vector3f
  9. import com.jme3.renderer.ViewPort
  10. import com.jme3.scene.Spatial
  11. object DefaultGameLevel {
  12. def apply(
  13. assetManager: AssetManager,
  14. viewPort: ViewPort
  15. ) = {
  16. lazy val sceneModel: Spatial = assetManager.loadModel("main.scene")
  17. lazy val sceneShape = CollisionShapeFactory.createMeshShape(
  18. sceneModel.toNode match {
  19. case util.Right(node) => node
  20. case util.Left(ex) =>
  21. throw new NotImplementedError("No fallback sceneshape")
  22. }
  23. )
  24. lazy val landscape: RigidBodyControl =
  25. new RigidBodyControl(sceneShape, 0)
  26. viewPort.setBackgroundColor(new ColorRGBA(0.7f, 0.8f, 1f, 1f))
  27. sceneModel.setLocalScale(2f)
  28. sceneModel.addControl(landscape)
  29. // discard { rootNode.attachChild(sceneModel) }
  30. // bulletAppState.getPhysicsSpace.add(landscape)
  31. // bulletAppState.getPhysicsSpace.add(player)
  32. val al = new AmbientLight();
  33. al.setColor(ColorRGBA.White.mult(1.3f));
  34. // app.rootNode.addLight(al);
  35. val dl = new DirectionalLight();
  36. dl.setColor(ColorRGBA.White);
  37. dl.setDirection(new Vector3f(2.8f, -2.8f, -2.8f).normalizeLocal());
  38. // app.rootNode.addLight(dl);
  39. new Level(
  40. model = sceneModel,
  41. physicsControl = landscape,
  42. ambientLight = al,
  43. directionalLight = dl
  44. )
  45. }
  46. }