Sebastian Kreisel 3 years ago
parent
commit
9e9cc0bc29

+ 6 - 4
run_compile.sh

@@ -3,11 +3,13 @@ if [ "$1" == "join" ]
 then
     coffee -j js/wilt.js -w -c \
 	   src/*.coffee \
-	   src/test/*.coffee \
-	   src/test/grow/*.coffee
+	   src/test/old/*.coffee \
+	   src/test/old/grow/*.coffee \
+	   src/test/sad/*.coffee
 else
     coffee -w -c -o js \
 	   src/*.coffee \
-	   src/test/*.coffee \
-	   src/test/grow/*.coffee
+	   src/test/old/*.coffee \
+	   src/test/old/grow/*.coffee \
+	   src/test/sad/*.coffee
 fi

src/test/curly.coffee → src/test/old/curly.coffee


src/test/grow/testgrowing.coffee → src/test/old/grow/testgrowing.coffee


src/test/growing.coffee → src/test/old/growing.coffee


src/test/simpletest.coffee → src/test/old/simpletest.coffee


src/test/spiky.coffee → src/test/old/spiky.coffee


src/test/spikyfloor.coffee → src/test/old/spikyfloor.coffee


+ 3 - 3
src/test/spikyscene.coffee

@@ -1,9 +1,9 @@
 class window.SpikyScene
 
   constructor: ->
-    console.log("spiky")
+    #console.log("spiky")
     @debugName = "Spiky"
-    window.camera.cameraPos.setData [0, -10, -40]
+    #window.camera.cameraPos.setData [0, -10, -40]
 
     @lineGeom = new Geom [4, 3]
     @lineGeom.initGL()
@@ -13,7 +13,7 @@ class window.SpikyScene
     @lineshader = window.shaders["lineShader"]
     @fillshader = window.shaders["fillShader"]
 
-    a = 0.4
+    a = 0.2
     intens = new Vec([35])
     lcol = new Vec([1.0, 1.0, 1.0])
     d = 12

src/test/testbasic.coffee → src/test/old/testbasic.coffee


src/test/testplatform.coffee → src/test/old/testplatform.coffee


+ 1 - 1
src/test/testscene.coffee

@@ -1,7 +1,7 @@
 class window.TestScene
 
   constructor: ->
-    console.log("test")
+    #console.log("test")
     @debugName = "Test"
     @accTime = 0
 

src/test/testspiky.coffee → src/test/old/testspiky.coffee


+ 48 - 0
src/test/sad/pillar.coffee

@@ -0,0 +1,48 @@
+class window.Pillar
+
+  constructor: (scene) ->
+    @uid = window.getuid()
+    @color = new Vec([1, 0, 0])
+    @position = new Vec([0, 0.01, 0])
+
+    @initGeom()
+    @initShader scene
+    @initGfx scene
+
+  initGeom: ->
+    @line = new Line(@position.copy(), new Vec([0, 1, 0]))
+    @comps = []
+    for i in [0..4]
+      @comps.push new PillarComponent(@line, 0.01 + i * 2, 5 - i, 2)
+    console.log @comps
+    return
+
+  initShader: (scene) ->
+    window.camera.addToProgram scene.fillShader, @uid
+    scene.attenuLight.addToProgram scene.fillShader, @uid
+    scene.fillShader.addUniformGL @uid, "num_lights", new Vec([2])
+    scene.attenuLight.addToProgram scene.fillShader, @uid
+    pL.addToProgram scene.fillShader, @uid for pL in scene.pointLights
+    return
+
+  initGfx: (scene) ->
+    @prims = []
+    for comp in @comps
+      @prims = @prims.concat comp.bot.gfxAddFill(@color)
+      @prims = @prims.concat comp.top.gfxAddFill(@color)
+      @prims = @prims.concat c.gfxAddFill(@color) for c in comp.conn
+
+    @dataSet = new GeomData @uid, scene.fillShader, @prims, GL.TRIANGLES
+    scene.fillGeom.addData @dataSet
+    return
+
+  doLogic: (delta) ->
+    return
+
+class window.PillarComponent
+
+  constructor: (@line, @y, @w, @h) ->
+    @bot = Polygon.regularFromLine @line.shiftBaseC(@y), @w, 5
+    @top = Polygon.regularFromLine @line.shiftBaseC(@y + @h), @w, 5, -1.0
+    @conn = Polygon.connectPolygons @bot, @top
+    return

+ 33 - 0
src/test/sad/sadfloor.coffee

@@ -0,0 +1,33 @@
+class window.SadFloor
+
+  constructor: (scene) ->
+    @uid = window.getuid()
+    @color = new Vec([0.5, 0.5, 0.7])
+    @size = 100
+
+    @initGeom()
+    @initShader scene
+    @initGfx scene
+
+  initGeom: ->
+    baseLine = new Line(new Vec([0, 0, 0]), new Vec([0, 1, 0]))
+    @polyFloor = Polygon.regularFromLine baseLine, @size, 4, -1.0
+    return
+
+  initShader: (scene) ->
+    window.camera.addToProgram scene.fillShader, @uid
+    attenuLight0 = new AttenuationLight new Vec([0, 0, 0])
+    attenuLight0.addToProgram scene.fillShader, @uid
+    scene.fillShader.addUniformGL @uid, "num_lights", new Vec([2])
+    pL.addToProgram scene.fillShader, @uid for pL in scene.pointLights
+    return
+
+  initGfx: (scene) ->
+    prims = []
+    prims = prims.concat @polyFloor.gfxAddFill(@color)
+    @dataSet = new GeomData @uid, scene.fillShader, prims, GL.TRIANGLES
+    scene.fillGeom.addData @dataSet
+    return
+
+  doLogic: (delta) ->
+    return

+ 49 - 0
src/test/sad/sadscene.coffee

@@ -0,0 +1,49 @@
+class window.SadScene
+
+  constructor: ->
+    @debugName = "Sad"
+
+    @fillGeom = new Geom [4, 3, 3]
+    @fillGeom.initGL()
+    @fillShader = window.shaders["fillShader"]
+    window.camera.cameraPos.setData [0, -5, -10]
+
+    a = 0.1
+    intens = new Vec [70]
+    lcol = new Vec [1, 1, 1]
+    d = 12
+    h = 25
+    @attenuLight = new AttenuationLight new Vec([a, a, a])
+    @pointLights = [
+      new PointLight(new Vec([d, h, 0]), intens, 0, lcol),
+      new PointLight(new Vec([-d, h, 0]), intens, 1, lcol),
+    ]
+
+    @entities = [
+      new SadFloor(this),
+      new Pillar(this)]
+
+    uid = window.getuid()
+    lightPrims = []
+    lightPrims = lightPrims.concat pL.dbgAddCube 1 for pL in @pointLights
+    @fillShader.addUniformGL uid, "num_lights", new Vec([@pointLights.length])
+    dataSet = new GeomData uid, @fillShader, lightPrims, GL.TRIANGLES
+    @fillGeom.addData dataSet
+
+  delegateDrawGL: ->
+    @fillGeom.dbgReset()
+    @fillGeom.updateGL()
+    @fillGeom.drawGL()
+    return
+
+  delegateDoLogic: (delta) ->
+    e.doLogic for e in @entities
+    return
+
+  dbgGeomInfo: ->
+    geomInfo = [0, 0, 0, 0]
+    geomInfo[0] += @fillGeom.size
+    geomInfo[1] += @fillGeom.dbgNumDraw
+    geomInfo[2] += @fillGeom.dbgNumUpdates
+    geomInfo[3] += @fillGeom.dbgNumUploads
+    return geomInfo

+ 2 - 1
src/whyiliketrees.coffee

@@ -31,7 +31,7 @@ class window.Display
     @deltaAvg = 0
 
     @scenes = []
-    @currentScene = 1
+    @currentScene = 0
 
   initGL: (canvas) ->
     canvas.setAttribute("width", @width)
@@ -57,6 +57,7 @@ class window.Display
     window.input = new Input canvas
     window.camera = new Camera
     window.initShadersGL()
+    @scenes.push new SadScene
     @scenes.push new TestScene
     @scenes.push new SpikyScene
     window.dbgSetInfo 1, "Current Scene: [" + @currentScene + ", " +