Commits

Philipp Dörfler committed f79a0fc

Began removing jME 2 code

  • Participants
  • Parent commits bc31492

Comments (0)

Files changed (1)

File src/main/scala/org/swiftsteel/app/SwiftSteel.scala

 import org.swiftsteel.model.math._
 import org.swiftsteel.model.playground._
 import org.swiftsteel.engine._
-
-import com.jme.app.SimplePassGame
-import com.jme.app.AbstractGame._
-import com.jmex.terrain._
-import com.jmex.terrain.util._
-import com.jme.math._
-import com.jmex.effects.water.WaterRenderPass
-import com.jme.scene.shape.Quad
-import com.jme.renderer.pass.RenderPass
-import com.jme.renderer._
-import com.jme.scene._
-import com.jme.scene.state._
-import com.jme.util.TextureManager
-import com.jme.image.Texture
-import com.jme.scene.Spatial.TextureCombineMode
-
 import java.nio.FloatBuffer
 import java.net.URL
 import java.io.File
 import javax.swing.ImageIcon
-
 import org.swiftsteel.engine.HeightBasedTexture._
 
-class SwiftSteel extends SimplePassGame {
+import com.jme3.app.SimpleApplication
+
+class SwiftSteel extends SimpleApplication {
   private var waterEffect: WaterEffect = _
-  private var skybox: Skybox = _
   val FAR_PLANE = 2500f
   
-  
-  setConfigShowMode(ConfigShowMode.AlwaysShow)
-  
-  override def simpleInitGame = {
-    display.setTitle("Swift Steel")
-    cam.setFrustumPerspective(45.0f, display.getWidth.asInstanceOf[Float]
-            / display.getHeight.asInstanceOf[Float], 2f, FAR_PLANE)
-    cam.setLocation(new Vector3f(100, 50, 100))
-    cam.lookAt(new Vector3f(0, 0, 0), Vector3f.UNIT_Y)
-    cam.update()
-    
-    display.getRenderer.setBackgroundColor(ColorRGBA.cyan.clone)
-    
-    val reflectedNode = new Node("reflectNode")
-    
+  override def simpleInitApp = {
     val jmeMap = RandomTerrain.generateHill()
     
-    val terrainPage = new TerrainPage("terrain", 33, 513, Vector(5, 0.7f, 5),
-        jmeMap.getHeightMap)
-    
-    BoundingBox placeAround terrainPage
-    
     val textureGenerator = HeightBasedTexture.createFor(jmeMap)
       .withLevels(-64, 0, 127, 255, 384)
       .withTexture("res/sand.jpg")
       .withTexture("res/rocksand.jpg")
       .renderAt(1024 x 1024)
       
-    val ts = display.getRenderer.createTextureState
-    val texture = TextureManager.loadTexture(textureGenerator.getImageIcon.getImage,
-        Texture.MinificationFilter.Trilinear, Texture.MagnificationFilter.Bilinear, true)
-        
-    ts.setTexture(texture, 0)
-    
-    val detailTexture = TextureFactory.load("res/detail2.png")
-    ts.setTexture(detailTexture, 1)
-    detailTexture.setWrap(Texture.WrapMode.Repeat)
-    TextureBlending.setupForColorTexture(texture)
-    TextureBlending.setupForDetailTexture(detailTexture)
-
-    terrainPage.setRenderState(ts)
-    
-    terrainPage.setDetailTexture(1, 128)
-    terrainPage.setRenderQueueMode(Renderer.QUEUE_OPAQUE)
-    
-    BackfaceCulling.enableFor(terrainPage, display)
-    
     buildSkyBox()
-    reflectedNode.attachChild(skybox)
-    reflectedNode.attachChild(terrainPage)
-    rootNode.attachChild(reflectedNode)
-    
-    waterEffect = WaterEffect.asSeenBy(cam)
-      .reachingUpTo(FAR_PLANE)
-      .underTheSky(skybox)
-      .reflecting(reflectedNode)
-      .beingAChildrenOf(rootNode)
-      .managedBy(pManager)
-      
-    //waterEffect.applyStyle(WaterStyle.BLUE)
-      
-    val rootPass = new RenderPass()
-    rootPass.add(rootNode)
-    pManager.add(rootPass)
     
     waterEffect.setWaterHeight(4)
     setupFog()
-    
-    rootNode.setRenderQueueMode(Renderer.QUEUE_OPAQUE)
-  }
-  
-  protected override def simpleUpdate = {
-    val tpf = timer.getTimePerFrame
-
-    skybox.getLocalTranslation.set(cam.getLocation)
-    skybox.updateGeometricState(0.0f, true)
-    
-    waterEffect.update()
   }
   
   private def setupFog() = {
-    val fogState = display.getRenderer.createFogState
-    fogState.setDensity(1.0f)
-    fogState.setEnabled(true)
-    fogState.setColor(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f))
-    fogState.setEnd(FAR_PLANE)
-    fogState.setStart(FAR_PLANE / 10.0f)
-    fogState.setDensityFunction(FogState.DensityFunction.Linear)
-    fogState.setQuality(FogState.Quality.PerVertex)
-    rootNode.setRenderState(fogState)
+    
   }
   
   private def buildSkyBox() = {
-    skybox = new Skybox("skybox", 10, 10, 10)
-    
-    skybox.setTexture(Skybox.Face.Up, skyboxTexture(3))
-    skybox.setTexture(Skybox.Face.North, skyboxTexture(1))
-    skybox.setTexture(Skybox.Face.West, skyboxTexture(5))
-    skybox.setTexture(Skybox.Face.East, skyboxTexture(2))
-    skybox.setTexture(Skybox.Face.South, skyboxTexture(4))
-    skybox.preloadTextures()
-    
-    skybox.getFace(Skybox.Face.Down).setDefaultColor(Color.fromBytes(214, 203, 173))
-        
-    val cullState = display.getRenderer.createCullState
-    cullState.setCullFace(CullState.Face.None)
-    cullState.setEnabled(true)
-    skybox.setRenderState(cullState)
-
-    val zState = display.getRenderer.createZBufferState
-    zState.setEnabled(false)
-    skybox.setRenderState(zState)
-
-    val fs = display.getRenderer.createFogState
-    fs.setEnabled(false)
-    skybox.setRenderState(fs)
-
-    skybox.setLightCombineMode(Spatial.LightCombineMode.Off)
-    skybox.setCullHint(Spatial.CullHint.Never)
-    skybox.setTextureCombineMode(TextureCombineMode.Replace)
-    skybox.updateRenderState()
-
-    skybox.lockBounds()
-    skybox.lockMeshes()
   }
   
   private def skyboxTexture(i: Int) = {
-    TextureManager.loadTexture(new File("res/skybox%s.png".format(i)).toURI.toURL,
-        Texture.MinificationFilter.BilinearNearestMipMap,
-        Texture.MagnificationFilter.Bilinear)
   }
 }