gears
This commit is contained in:
parent
3404190618
commit
b9cb4c7759
|
@ -29,6 +29,7 @@ class Action
|
|||
@LOOK_UP = 17
|
||||
@LOOK_DOWN = 18
|
||||
@LOOK_RESET = 19
|
||||
@TUCKER = 20
|
||||
|
||||
@ONCE = 0
|
||||
@CONTINUOUS = 1
|
||||
|
|
|
@ -26,4 +26,11 @@ class Face
|
|||
when 2 then return new Vector 0, 0, o
|
||||
new Vector
|
||||
|
||||
@X = 0
|
||||
@Y = 1
|
||||
@Z = 2
|
||||
@NX = 3
|
||||
@NY = 4
|
||||
@NZ = 5
|
||||
|
||||
module.exports = Face
|
||||
|
|
|
@ -4,26 +4,36 @@
|
|||
# 000 000 000 000 000 000 000
|
||||
# 0000000 00000000 000 000 000 000
|
||||
|
||||
Valve = require './valve'
|
||||
Valve = require './valve'
|
||||
Action = require './action'
|
||||
Pos = require './lib/pos'
|
||||
Cage = require './cage'
|
||||
Geom = require './geom'
|
||||
|
||||
class Gear extends Valve
|
||||
|
||||
constructor: (face) -> super face
|
||||
constructor: (face) ->
|
||||
|
||||
geom = Geom.gear()
|
||||
@mesh = new THREE.Mesh geom, Cage.cageMat
|
||||
@mesh.receiveShadow = true
|
||||
|
||||
super face
|
||||
|
||||
getNeighborDirections: (face) ->
|
||||
neighbors = [
|
||||
[0,1,0], [0,-1,0], [0,0,1], [0,0,-1]
|
||||
[1,0,0], [-1,0,0], [0,0,1], [0,0,-1]
|
||||
[1,0,0], [-1,0,0], [0,1,0], [0,-1,0]
|
||||
[[0,1,0], [0,-1,0], [0,0,1], [0,0,-1]]
|
||||
[[1,0,0], [-1,0,0], [0,0,1], [0,0,-1]]
|
||||
[[1,0,0], [-1,0,0], [0,1,0], [0,-1,0]]
|
||||
]
|
||||
neighbors[face % 3]
|
||||
|
||||
getNeighborGears: ->
|
||||
neighbor_dirs = @getNeighborDirections()
|
||||
dirs = @getNeighborDirections @face
|
||||
pos = @getPos()
|
||||
gears = []
|
||||
for i in [0...4]
|
||||
neighbor = world.getOccupantAtPos pos.plus neighbor_dirs[i]
|
||||
neighbor = world.getOccupantAtPos pos.plus new Pos dirs[i]
|
||||
if neighbor? and neighbor instanceof Gear
|
||||
if neighbor.face == face
|
||||
gears.push neighbor
|
||||
|
|
385
coffee/geom.coffee
Normal file
385
coffee/geom.coffee
Normal file
|
@ -0,0 +1,385 @@
|
|||
|
||||
class Geom
|
||||
|
||||
@gear: ->
|
||||
# glInterleavedArrays (GL_N3F_V3F, 0, gearInterleavedQuads)
|
||||
# glDrawArrays (GL_QUADS, 0, gearNumQuads*4)
|
||||
# glInterleavedArrays (GL_N3F_V3F, 0, gearInterleavedQuadStrips)
|
||||
# for (int i = 0; i < gearNumQuadStrips; i++)
|
||||
# glDrawArrays (GL_QUAD_STRIP, gearQuadStripIndices[i]/6
|
||||
# (gearQuadStripIndices[i+1] - gearQuadStripIndices[i])/6)
|
||||
|
||||
quads = @gearInterleavedQuads
|
||||
numQuads = quads.length/24
|
||||
|
||||
triangles = numQuads * 2
|
||||
positions = new Float32Array triangles * 3 * 3
|
||||
normals = new Float32Array triangles * 3 * 3
|
||||
|
||||
pi = -1
|
||||
for q in [0...numQuads]
|
||||
qi = q * 24
|
||||
for j in [0,1,2,0,2,3]
|
||||
jj = j * 6
|
||||
for i in [0...3]
|
||||
positions[pi+=1] = quads[qi+jj+i+3]; normals[pi] = quads[qi+jj+i]
|
||||
|
||||
geom = new THREE.BufferGeometry
|
||||
geom.addAttribute 'position', new THREE.BufferAttribute positions, 3
|
||||
geom.addAttribute 'normal', new THREE.BufferAttribute normals, 3
|
||||
geom
|
||||
|
||||
@gearInterleavedQuads = [ # 1152 = 48 * 24
|
||||
0.981, 0.195, -0.000, 0.375, 0.155, 0.087,
|
||||
0.981, 0.195, -0.000, 0.406, -0.000, 0.087,
|
||||
0.981, 0.195, -0.000, 0.406, -0.000, -0.087,
|
||||
0.981, 0.195, -0.000, 0.375, 0.155, -0.087,
|
||||
|
||||
0.556, 0.831, -0.000, 0.155, 0.375, 0.087,
|
||||
0.556, 0.831, -0.000, 0.287, 0.287, 0.087,
|
||||
0.556, 0.831, -0.000, 0.287, 0.287, -0.087,
|
||||
0.556, 0.831, -0.000, 0.155, 0.375, -0.087,
|
||||
|
||||
-0.195, 0.981, -0.000,-0.155, 0.375, 0.087,
|
||||
-0.195, 0.981, -0.000, 0.000, 0.406, 0.087,
|
||||
-0.195, 0.981, -0.000, 0.000, 0.406, -0.087,
|
||||
-0.195, 0.981, -0.000,-0.155, 0.375, -0.087,
|
||||
|
||||
-0.831, 0.556, -0.000,-0.375, 0.155, 0.087,
|
||||
-0.831, 0.556, -0.000,-0.287, 0.287, 0.087,
|
||||
-0.831, 0.556, -0.000,-0.287, 0.287, -0.087,
|
||||
-0.831, 0.556, -0.000,-0.375, 0.155, -0.087,
|
||||
|
||||
-0.981, -0.195, 0.000,-0.375, -0.155, 0.087,
|
||||
-0.981, -0.195, 0.000,-0.406, 0.000, 0.087,
|
||||
-0.981, -0.195, 0.000,-0.406, 0.000, -0.087,
|
||||
-0.981, -0.195, 0.000,-0.375, -0.155, -0.087,
|
||||
|
||||
-0.556, -0.831, 0.000,-0.155, -0.375, 0.087,
|
||||
-0.556, -0.831, 0.000,-0.287, -0.287, 0.087,
|
||||
-0.556, -0.831, 0.000,-0.287, -0.287, -0.087,
|
||||
-0.556, -0.831, 0.000,-0.155, -0.375, -0.087,
|
||||
|
||||
0.195, -0.981, 0.000, 0.155, -0.375, 0.087,
|
||||
0.195, -0.981, 0.000,-0.000, -0.406, 0.087,
|
||||
0.195, -0.981, 0.000,-0.000, -0.406, -0.087,
|
||||
0.195, -0.981, 0.000, 0.155, -0.375, -0.087,
|
||||
|
||||
0.831, -0.556, 0.000, 0.375, -0.155, 0.087,
|
||||
0.831, -0.556, 0.000, 0.287, -0.287, 0.087,
|
||||
0.831, -0.556, 0.000, 0.287, -0.287, -0.087,
|
||||
0.831, -0.556, 0.000, 0.375, -0.155, -0.087,
|
||||
|
||||
-0.021, -1.000, 0.000, 0.534, -0.159, -0.056,
|
||||
-0.021, -1.000, 0.000, 0.534, -0.159, 0.056,
|
||||
-0.021, -1.000, 0.000, 0.375, -0.155, 0.087,
|
||||
-0.021, -1.000, 0.000, 0.375, -0.155, -0.087,
|
||||
|
||||
0.187, -0.037, -0.982, 0.554, -0.058, -0.056,
|
||||
0.187, -0.037, -0.982, 0.534, -0.159, -0.056,
|
||||
0.143, -0.046, -0.989, 0.375, -0.155, -0.087,
|
||||
0.149, -0.012, -0.989, 0.406, -0.000, -0.087,
|
||||
|
||||
0.363, 0.932, -0.000, 0.554, -0.058, 0.056,
|
||||
0.363, 0.932, -0.000, 0.554, -0.058, -0.056,
|
||||
0.363, 0.932, -0.000, 0.406, -0.000, -0.087,
|
||||
0.363, 0.932, -0.000, 0.406, -0.000, 0.087,
|
||||
|
||||
0.981, -0.195, 0.000, 0.554, -0.058, 0.056,
|
||||
0.981, -0.195, 0.000, 0.534, -0.159, 0.056,
|
||||
0.981, -0.195, 0.000, 0.534, -0.159, -0.056,
|
||||
0.981, -0.195, 0.000, 0.554, -0.058, -0.056,
|
||||
|
||||
0.187, -0.037, 0.982, 0.534, -0.159, 0.056,
|
||||
0.187, -0.037, 0.982, 0.554, -0.058, 0.056,
|
||||
0.149, -0.012, 0.989, 0.406, -0.000, 0.087,
|
||||
0.143, -0.046, 0.989, 0.375, -0.155, 0.087,
|
||||
|
||||
-0.722, -0.692, 0.000, 0.266, -0.490, -0.056,
|
||||
-0.722, -0.692, 0.000, 0.266, -0.490, 0.056,
|
||||
-0.722, -0.692, 0.000, 0.155, -0.375, 0.087,
|
||||
-0.722, -0.692, 0.000, 0.155, -0.375, -0.087,
|
||||
|
||||
0.106, -0.159, -0.982, 0.351, -0.433, -0.056,
|
||||
0.106, -0.159, -0.982, 0.266, -0.490, -0.056,
|
||||
0.069, -0.133, -0.989, 0.155, -0.375, -0.087,
|
||||
0.097, -0.114, -0.989, 0.287, -0.287, -0.087,
|
||||
|
||||
0.916, 0.402, -0.000, 0.351, -0.433, 0.056,
|
||||
0.916, 0.402, -0.000, 0.351, -0.433, -0.056,
|
||||
0.916, 0.402, -0.000, 0.287, -0.287, -0.087,
|
||||
0.916, 0.402, -0.000, 0.287, -0.287, 0.087,
|
||||
|
||||
0.556, -0.831, 0.000, 0.351, -0.433, 0.056,
|
||||
0.556, -0.831, 0.000, 0.266, -0.490, 0.056,
|
||||
0.556, -0.831, 0.000, 0.266, -0.490, -0.056,
|
||||
0.556, -0.831, 0.000, 0.351, -0.433, -0.056,
|
||||
|
||||
0.106, -0.159, 0.982, 0.266, -0.490, 0.056,
|
||||
0.106, -0.159, 0.982, 0.351, -0.433, 0.056,
|
||||
0.097, -0.114, 0.989, 0.287, -0.287, 0.087,
|
||||
0.069, -0.133, 0.989, 0.155, -0.375, 0.087,
|
||||
|
||||
-1.000, 0.021, -0.000,-0.159, -0.534, -0.056,
|
||||
-1.000, 0.021, -0.000,-0.159, -0.534, 0.056,
|
||||
-1.000, 0.021, -0.000,-0.155, -0.375, 0.087,
|
||||
-1.000, 0.021, -0.000,-0.155, -0.375, -0.087,
|
||||
|
||||
-0.037, -0.187, -0.982,-0.058, -0.554, -0.056,
|
||||
-0.037, -0.187, -0.982,-0.159, -0.534, -0.056,
|
||||
-0.046, -0.143, -0.989,-0.155, -0.375, -0.087,
|
||||
-0.012, -0.149, -0.989,-0.000, -0.406, -0.087,
|
||||
|
||||
0.932, -0.363, 0.000,-0.058, -0.554, 0.056,
|
||||
0.932, -0.363, 0.000,-0.058, -0.554, -0.056,
|
||||
0.932, -0.363, 0.000,-0.000, -0.406, -0.087,
|
||||
0.932, -0.363, 0.000,-0.000, -0.406, 0.087,
|
||||
|
||||
-0.195, -0.981, 0.000,-0.058, -0.554, 0.056,
|
||||
-0.195, -0.981, 0.000,-0.159, -0.534, 0.056,
|
||||
-0.195, -0.981, 0.000,-0.159, -0.534, -0.056,
|
||||
-0.195, -0.981, 0.000,-0.058, -0.554, -0.056,
|
||||
|
||||
-0.037, -0.187, 0.982,-0.159, -0.534, 0.056,
|
||||
-0.037, -0.187, 0.982,-0.058, -0.554, 0.056,
|
||||
-0.012, -0.149, 0.989,-0.000, -0.406, 0.087,
|
||||
-0.046, -0.143, 0.989,-0.155, -0.375, 0.087,
|
||||
|
||||
-0.692, 0.722, -0.000,-0.490, -0.266, -0.056,
|
||||
-0.692, 0.722, -0.000,-0.490, -0.266, 0.056,
|
||||
-0.692, 0.722, -0.000,-0.375, -0.155, 0.087,
|
||||
-0.692, 0.722, -0.000,-0.375, -0.155, -0.087,
|
||||
|
||||
-0.159, -0.106, -0.982,-0.433, -0.351, -0.056,
|
||||
-0.159, -0.106, -0.982,-0.490, -0.266, -0.056,
|
||||
-0.133, -0.069, -0.989,-0.375, -0.155, -0.087,
|
||||
-0.114, -0.097, -0.989,-0.287, -0.287, -0.087,
|
||||
|
||||
0.402, -0.916, 0.000,-0.433, -0.351, 0.056,
|
||||
0.402, -0.916, 0.000,-0.433, -0.351, -0.056,
|
||||
0.402, -0.916, 0.000,-0.287, -0.287, -0.087,
|
||||
0.402, -0.916, 0.000,-0.287, -0.287, 0.087,
|
||||
|
||||
-0.831, -0.556, 0.000,-0.433, -0.351, 0.056,
|
||||
-0.831, -0.556, 0.000,-0.490, -0.266, 0.056,
|
||||
-0.831, -0.556, 0.000,-0.490, -0.266, -0.056,
|
||||
-0.831, -0.556, 0.000,-0.433, -0.351, -0.056,
|
||||
|
||||
-0.159, -0.106, 0.982,-0.490, -0.266, 0.056,
|
||||
-0.159, -0.106, 0.982,-0.433, -0.351, 0.056,
|
||||
-0.114, -0.097, 0.989,-0.287, -0.287, 0.087,
|
||||
-0.133, -0.069, 0.989,-0.375, -0.155, 0.087,
|
||||
|
||||
0.021, 1.000, -0.000,-0.534, 0.159, -0.056,
|
||||
0.021, 1.000, -0.000,-0.534, 0.159, 0.056,
|
||||
0.021, 1.000, -0.000,-0.375, 0.155, 0.087,
|
||||
0.021, 1.000, -0.000,-0.375, 0.155, -0.087,
|
||||
|
||||
-0.187, 0.037, -0.982,-0.554, 0.058, -0.056,
|
||||
-0.187, 0.037, -0.982,-0.534, 0.159, -0.056,
|
||||
-0.143, 0.046, -0.989,-0.375, 0.155, -0.087,
|
||||
-0.149, 0.012, -0.989,-0.406, 0.000, -0.087,
|
||||
|
||||
-0.363, -0.932, 0.000,-0.554, 0.058, 0.056,
|
||||
-0.363, -0.932, 0.000,-0.554, 0.058, -0.056,
|
||||
-0.363, -0.932, 0.000,-0.406, 0.000, -0.087,
|
||||
-0.363, -0.932, 0.000,-0.406, 0.000, 0.087,
|
||||
|
||||
-0.981, 0.195, -0.000,-0.554, 0.058, 0.056,
|
||||
-0.981, 0.195, -0.000,-0.534, 0.159, 0.056,
|
||||
-0.981, 0.195, -0.000,-0.534, 0.159, -0.056,
|
||||
-0.981, 0.195, -0.000,-0.554, 0.058, -0.056,
|
||||
|
||||
-0.187, 0.037, 0.982,-0.534, 0.159, 0.056,
|
||||
-0.187, 0.037, 0.982,-0.554, 0.058, 0.056,
|
||||
-0.149, 0.012, 0.989,-0.406, 0.000, 0.087,
|
||||
-0.143, 0.046, 0.989,-0.375, 0.155, 0.087,
|
||||
|
||||
0.722, 0.692, -0.000,-0.266, 0.490, -0.056,
|
||||
0.722, 0.692, -0.000,-0.266, 0.490, 0.056,
|
||||
0.722, 0.692, -0.000,-0.155, 0.375, 0.087,
|
||||
0.722, 0.692, -0.000,-0.155, 0.375, -0.087,
|
||||
|
||||
-0.106, 0.159, -0.982,-0.351, 0.433, -0.056,
|
||||
-0.106, 0.159, -0.982,-0.266, 0.490, -0.056,
|
||||
-0.069, 0.133, -0.989,-0.155, 0.375, -0.087,
|
||||
-0.097, 0.114, -0.989,-0.287, 0.287, -0.087,
|
||||
|
||||
-0.916, -0.402, 0.000,-0.351, 0.433, 0.056,
|
||||
-0.916, -0.402, 0.000,-0.351, 0.433, -0.056,
|
||||
-0.916, -0.402, 0.000,-0.287, 0.287, -0.087,
|
||||
-0.916, -0.402, 0.000,-0.287, 0.287, 0.087,
|
||||
|
||||
-0.556, 0.831, -0.000,-0.351, 0.433, 0.056,
|
||||
-0.556, 0.831, -0.000,-0.266, 0.490, 0.056,
|
||||
-0.556, 0.831, -0.000,-0.266, 0.490, -0.056,
|
||||
-0.556, 0.831, -0.000,-0.351, 0.433, -0.056,
|
||||
|
||||
-0.106, 0.159, 0.982,-0.266, 0.490, 0.056,
|
||||
-0.106, 0.159, 0.982,-0.351, 0.433, 0.056,
|
||||
-0.097, 0.114, 0.989,-0.287, 0.287, 0.087,
|
||||
-0.069, 0.133, 0.989,-0.155, 0.375, 0.087,
|
||||
|
||||
1.000, -0.021, 0.000, 0.159, 0.534, -0.056,
|
||||
1.000, -0.021, 0.000, 0.159, 0.534, 0.056,
|
||||
1.000, -0.021, 0.000, 0.155, 0.375, 0.087,
|
||||
1.000, -0.021, 0.000, 0.155, 0.375, -0.087,
|
||||
|
||||
0.037, 0.187, -0.982, 0.058, 0.554, -0.056,
|
||||
0.037, 0.187, -0.982, 0.159, 0.534, -0.056,
|
||||
0.046, 0.143, -0.989, 0.155, 0.375, -0.087,
|
||||
0.012, 0.149, -0.989, 0.000, 0.406, -0.087,
|
||||
|
||||
-0.932, 0.363, -0.000, 0.058, 0.554, 0.056,
|
||||
-0.932, 0.363, -0.000, 0.058, 0.554, -0.056,
|
||||
-0.932, 0.363, -0.000, 0.000, 0.406, -0.087,
|
||||
-0.932, 0.363, -0.000, 0.000, 0.406, 0.087,
|
||||
|
||||
0.195, 0.981, -0.000, 0.058, 0.554, 0.056,
|
||||
0.195, 0.981, -0.000, 0.159, 0.534, 0.056,
|
||||
0.195, 0.981, -0.000, 0.159, 0.534, -0.056,
|
||||
0.195, 0.981, -0.000, 0.058, 0.554, -0.056,
|
||||
|
||||
0.037, 0.187, 0.982, 0.159, 0.534, 0.056,
|
||||
0.037, 0.187, 0.982, 0.058, 0.554, 0.056,
|
||||
0.012, 0.149, 0.989, 0.000, 0.406, 0.087,
|
||||
0.046, 0.143, 0.989, 0.155, 0.375, 0.087,
|
||||
|
||||
0.692, -0.722, 0.000, 0.490, 0.266, -0.056,
|
||||
0.692, -0.722, 0.000, 0.490, 0.266, 0.056,
|
||||
0.692, -0.722, 0.000, 0.375, 0.155, 0.087,
|
||||
0.692, -0.722, 0.000, 0.375, 0.155, -0.087,
|
||||
|
||||
0.159, 0.106, -0.982, 0.433, 0.351, -0.056,
|
||||
0.159, 0.106, -0.982, 0.490, 0.266, -0.056,
|
||||
0.133, 0.069, -0.989, 0.375, 0.155, -0.087,
|
||||
0.114, 0.097, -0.989, 0.287, 0.287, -0.087,
|
||||
|
||||
-0.402, 0.916, -0.000, 0.433, 0.351, 0.056,
|
||||
-0.402, 0.916, -0.000, 0.433, 0.351, -0.056,
|
||||
-0.402, 0.916, -0.000, 0.287, 0.287, -0.087,
|
||||
-0.402, 0.916, -0.000, 0.287, 0.287, 0.087,
|
||||
|
||||
0.831, 0.556, -0.000, 0.433, 0.351, 0.056,
|
||||
0.831, 0.556, -0.000, 0.490, 0.266, 0.056,
|
||||
0.831, 0.556, -0.000, 0.490, 0.266, -0.056,
|
||||
0.831, 0.556, -0.000, 0.433, 0.351, -0.056,
|
||||
|
||||
0.159, 0.106, 0.982, 0.490, 0.266, 0.056,
|
||||
0.159, 0.106, 0.982, 0.433, 0.351, 0.056,
|
||||
0.114, 0.097, 0.989, 0.287, 0.287, 0.087,
|
||||
0.133, 0.069, 0.989, 0.375, 0.155, 0.087]
|
||||
|
||||
@gearNumQuadStrips = 3
|
||||
@gearQuadStripIndices = [ 0, 216, 432, 648 ]
|
||||
@gearInterleavedQuadStrips = [ # 648
|
||||
0.120, -0.050, 0.991, 0.208, -0.086, 0.111,
|
||||
0.143, -0.046, 0.989, 0.375, -0.155, 0.087,
|
||||
0.130, 0.000, 0.991, 0.226, 0.000, 0.111,
|
||||
0.149, -0.012, 0.989, 0.406, -0.000, 0.087,
|
||||
0.120, 0.050, 0.991, 0.208, 0.086, 0.111,
|
||||
0.133, 0.069, 0.989, 0.375, 0.155, 0.087,
|
||||
0.092, 0.092, 0.991, 0.160, 0.160, 0.111,
|
||||
0.114, 0.097, 0.989, 0.287, 0.287, 0.087,
|
||||
0.050, 0.120, 0.991, 0.086, 0.208, 0.111,
|
||||
0.046, 0.143, 0.989, 0.155, 0.375, 0.087,
|
||||
-0.000, 0.130, 0.991, -0.000, 0.226, 0.111,
|
||||
0.012, 0.149, 0.989, 0.000, 0.406, 0.087,
|
||||
-0.050, 0.120, 0.991, -0.086, 0.208, 0.111,
|
||||
-0.069, 0.133, 0.989, -0.155, 0.375, 0.087,
|
||||
-0.092, 0.092, 0.991, -0.160, 0.160, 0.111,
|
||||
-0.097, 0.114, 0.989, -0.287, 0.287, 0.087,
|
||||
-0.120, 0.050, 0.991, -0.208, 0.086, 0.111,
|
||||
-0.143, 0.046, 0.989, -0.375, 0.155, 0.087,
|
||||
-0.130, 0.000, 0.991, -0.226, 0.000, 0.111,
|
||||
-0.149, 0.012, 0.989, -0.406, 0.000, 0.087,
|
||||
-0.120, -0.050, 0.991, -0.208, -0.086, 0.111,
|
||||
-0.133, -0.069, 0.989, -0.375, -0.155, 0.087,
|
||||
-0.092, -0.092, 0.991, -0.160, -0.160, 0.111,
|
||||
-0.114, -0.097, 0.989, -0.287, -0.287, 0.087,
|
||||
-0.050, -0.120, 0.991, -0.086, -0.208, 0.111,
|
||||
-0.046, -0.143, 0.989, -0.155, -0.375, 0.087,
|
||||
0.000, -0.130, 0.991, 0.000, -0.226, 0.111,
|
||||
-0.012, -0.149, 0.989, -0.000, -0.406, 0.087,
|
||||
0.050, -0.120, 0.991, 0.086, -0.208, 0.111,
|
||||
0.069, -0.133, 0.989, 0.155, -0.375, 0.087,
|
||||
0.092, -0.092, 0.991, 0.160, -0.160, 0.111,
|
||||
0.097, -0.114, 0.989, 0.287, -0.287, 0.087,
|
||||
0.120, -0.050, 0.991, 0.208, -0.086, 0.111,
|
||||
0.143, -0.046, 0.989, 0.375, -0.155, 0.087,
|
||||
0.130, 0.000, 0.991, 0.226, 0.000, 0.111,
|
||||
0.149, -0.012, 0.989, 0.406, -0.000, 0.087,
|
||||
-1.000, -0.000, -0.000, 0.226, -0.000, -0.111,
|
||||
-1.000, -0.000, -0.000, 0.226, 0.000, 0.111,
|
||||
-0.924, -0.383, 0.000, 0.208, 0.086, -0.111,
|
||||
-0.924, -0.383, 0.000, 0.208, 0.086, 0.111,
|
||||
-0.707, -0.707, 0.000, 0.160, 0.160, -0.111,
|
||||
-0.707, -0.707, 0.000, 0.160, 0.160, 0.111,
|
||||
-0.383, -0.924, 0.000, 0.086, 0.208, -0.111,
|
||||
-0.383, -0.924, 0.000, 0.086, 0.208, 0.111,
|
||||
0.000, -1.000, 0.000, -0.000, 0.226, -0.111,
|
||||
0.000, -1.000, 0.000, -0.000, 0.226, 0.111,
|
||||
0.383, -0.924, 0.000, -0.086, 0.208, -0.111,
|
||||
0.383, -0.924, 0.000, -0.086, 0.208, 0.111,
|
||||
0.707, -0.707, 0.000, -0.160, 0.160, -0.111,
|
||||
0.707, -0.707, 0.000, -0.160, 0.160, 0.111,
|
||||
0.924, -0.383, 0.000, -0.208, 0.086, -0.111,
|
||||
0.924, -0.383, 0.000, -0.208, 0.086, 0.111,
|
||||
1.000, 0.000, 0.000, -0.226, -0.000, -0.111,
|
||||
1.000, 0.000, 0.000, -0.226, 0.000, 0.111,
|
||||
0.924, 0.383, -0.000, -0.208, -0.086, -0.111,
|
||||
0.924, 0.383, -0.000, -0.208, -0.086, 0.111,
|
||||
0.707, 0.707, -0.000, -0.160, -0.160, -0.111,
|
||||
0.707, 0.707, -0.000, -0.160, -0.160, 0.111,
|
||||
0.383, 0.924, -0.000, -0.086, -0.208, -0.111,
|
||||
0.383, 0.924, -0.000, -0.086, -0.208, 0.111,
|
||||
-0.000, 1.000, -0.000, 0.000, -0.226, -0.111,
|
||||
-0.000, 1.000, -0.000, 0.000, -0.226, 0.111,
|
||||
-0.383, 0.924, -0.000, 0.086, -0.208, -0.111,
|
||||
-0.383, 0.924, -0.000, 0.086, -0.208, 0.111,
|
||||
-0.707, 0.707, -0.000, 0.160, -0.160, -0.111,
|
||||
-0.707, 0.707, -0.000, 0.160, -0.160, 0.111,
|
||||
-0.924, 0.383, -0.000, 0.208, -0.086, -0.111,
|
||||
-0.924, 0.383, -0.000, 0.208, -0.086, 0.111,
|
||||
-1.000, -0.000, -0.000, 0.226, -0.000, -0.111,
|
||||
-1.000, -0.000, -0.000, 0.226, 0.000, 0.111,
|
||||
-0.924, -0.383, 0.000, 0.208, 0.086, -0.111,
|
||||
-0.924, -0.383, 0.000, 0.208, 0.086, 0.111,
|
||||
0.149, -0.012, -0.989, 0.406, -0.000, -0.087,
|
||||
0.130, -0.000, -0.991, 0.226, -0.000, -0.111,
|
||||
0.133, 0.069, -0.989, 0.375, 0.155, -0.087,
|
||||
0.120, 0.050, -0.991, 0.208, 0.086, -0.111,
|
||||
0.114, 0.097, -0.989, 0.287, 0.287, -0.087,
|
||||
0.092, 0.092, -0.991, 0.160, 0.160, -0.111,
|
||||
0.046, 0.143, -0.989, 0.155, 0.375, -0.087,
|
||||
0.050, 0.120, -0.991, 0.086, 0.208, -0.111,
|
||||
0.012, 0.149, -0.989, 0.000, 0.406, -0.087,
|
||||
-0.000, 0.130, -0.991, -0.000, 0.226, -0.111,
|
||||
-0.069, 0.133, -0.989, -0.155, 0.375, -0.087,
|
||||
-0.050, 0.120, -0.991, -0.086, 0.208, -0.111,
|
||||
-0.097, 0.114, -0.989, -0.287, 0.287, -0.087,
|
||||
-0.092, 0.092, -0.991, -0.160, 0.160, -0.111,
|
||||
-0.143, 0.046, -0.989, -0.375, 0.155, -0.087,
|
||||
-0.120, 0.050, -0.991, -0.208, 0.086, -0.111,
|
||||
-0.149, 0.012, -0.989, -0.406, 0.000, -0.087,
|
||||
-0.130, -0.000, -0.991, -0.226, -0.000, -0.111,
|
||||
-0.133, -0.069, -0.989, -0.375, -0.155, -0.087,
|
||||
-0.120, -0.050, -0.991, -0.208, -0.086, -0.111,
|
||||
-0.114, -0.097, -0.989, -0.287, -0.287, -0.087,
|
||||
-0.092, -0.092, -0.991, -0.160, -0.160, -0.111,
|
||||
-0.046, -0.143, -0.989, -0.155, -0.375, -0.087,
|
||||
-0.050, -0.120, -0.991, -0.086, -0.208, -0.111,
|
||||
-0.012, -0.149, -0.989, -0.000, -0.406, -0.087,
|
||||
0.000, -0.130, -0.991, 0.000, -0.226, -0.111,
|
||||
0.069, -0.133, -0.989, 0.155, -0.375, -0.087,
|
||||
0.050, -0.120, -0.991, 0.086, -0.208, -0.111,
|
||||
0.097, -0.114, -0.989, 0.287, -0.287, -0.087,
|
||||
0.092, -0.092, -0.991, 0.160, -0.160, -0.111,
|
||||
0.143, -0.046, -0.989, 0.375, -0.155, -0.087,
|
||||
0.120, -0.050, -0.991, 0.208, -0.086, -0.111,
|
||||
0.149, -0.012, -0.989, 0.406, -0.000, -0.087,
|
||||
0.130, -0.000, -0.991, 0.226, -0.000, -0.111,
|
||||
0.133, 0.069, -0.989, 0.375, 0.155, -0.087,
|
||||
0.120, 0.050, -0.991, 0.208, 0.086, -0.111]
|
||||
|
||||
module.exports = Geom
|
16
coffee/items.coffee
Normal file
16
coffee/items.coffee
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
# 000 000000000 00000000 00 00 0000000
|
||||
# 000 000 000 000 000 000
|
||||
# 000 000 0000000 000000000 0000000
|
||||
# 000 000 000 000 0 000 000
|
||||
# 000 000 00000000 000 000 0000000
|
||||
|
||||
module.exports =
|
||||
Gear: require './gear'
|
||||
Stone: require './stone'
|
||||
Wall: require './wall'
|
||||
MotorGear: require './motorgear'
|
||||
MotorCylinder: require './motorcylinder'
|
||||
Generator: require './generator'
|
||||
Face: require './face'
|
||||
|
|
@ -23,6 +23,7 @@ module.exports =
|
|||
create: ->
|
||||
|
||||
s = world.size
|
||||
{Gear,Generator,MotorCylinder,MotorGear,Face} = require '../items'
|
||||
|
||||
for y in [ -7, -3, 1, 5]
|
||||
x = 1
|
||||
|
@ -36,14 +37,12 @@ module.exports =
|
|||
x = 2
|
||||
world.addObjectPoly 'WireStone', [world.decenter(-x, y, -x), world.decenter(-x, y, x), world.decenter(x, y, x), world.decenter(x, y, -x)]
|
||||
|
||||
# KEY GEAR
|
||||
world.addObjectAtPos 'KikiGear(KikiFace.NY)', world.decenter 0, -10, 0
|
||||
# LOCK MECHANISM
|
||||
world.addObjectAtPos 'Generator(KikiFace.NY)', world.decenter -1, 12, 0
|
||||
world.addObjectAtPos 'Generator(KikiFace.NY)', world.decenter -1, 11, 0
|
||||
world.addObjectAtPos new Gear(Face.NY), world.decenter 0, -10, 0
|
||||
world.addObjectAtPos new Generator(Face.NY), world.decenter -1, 12, 0
|
||||
world.addObjectAtPos new Generator(Face.NY), world.decenter -1, 11, 0
|
||||
|
||||
world.addObjectAtPos 'MotorCylinder(KikiFace.NY)', world.decenter 1, 11, 0
|
||||
world.addObjectAtPos 'MotorGear(KikiFace.NY)', world.decenter 1, 12, 0
|
||||
world.addObjectAtPos new MotorCylinder(Face.NY), world.decenter 1, 11, 0
|
||||
world.addObjectAtPos new MotorGear(Face.NY), world.decenter 1, 12, 0
|
||||
|
||||
world.addObjectAtPos 'WireStone', world.decenter 0, 11, 1
|
||||
world.addObjectAtPos 'WireStone', world.decenter 0, 12, 1
|
||||
|
|
55
coffee/motorcylinder.coffee
Normal file
55
coffee/motorcylinder.coffee
Normal file
|
@ -0,0 +1,55 @@
|
|||
# 00 00 0000000 000000000 0000000 00000000 0000000 000 000 000 000 000 000 0000000 00000000 00000000
|
||||
# 000 000 000 000 000 000 000 000 000 000 000 000 000 000 0000 000 000 000 000 000 000
|
||||
# 000000000 000 000 000 000 000 0000000 000 00000 000 000 000 0 000 000 000 0000000 0000000
|
||||
# 000 0 000 000 000 000 000 000 000 000 000 000 000 000 000 0000 000 000 000 000 000
|
||||
# 000 000 0000000 000 0000000 000 000 0000000 000 0000000 000 000 000 0000000 00000000 000 000
|
||||
|
||||
Item = require './item'
|
||||
Action = require './action'
|
||||
Face = require './face'
|
||||
|
||||
class MotorCylinder extends Item
|
||||
|
||||
constructor: (face) ->
|
||||
super
|
||||
@value = 0.0
|
||||
@active = false
|
||||
@orientation = Face.orientationForFace @face
|
||||
@addAction new Action @, Action.TUCKER, "tucker", 500, Action.REPEAT
|
||||
@setActive true
|
||||
|
||||
setActive: (active) ->
|
||||
if @active != active
|
||||
@active = active
|
||||
|
||||
if @active
|
||||
@startTimedAction @getActionWithId Action.TUCKER
|
||||
else
|
||||
@stopAction @getActionWithId Action.TUCKER
|
||||
|
||||
performAction: (action) ->
|
||||
|
||||
if action.id == Action.TUCKER
|
||||
relTime = action.getRelativeTime()
|
||||
@value = (relTime < 0.5) and relTime or 1.0 - relTime
|
||||
@value *= 2
|
||||
|
||||
finishAction: (action) ->
|
||||
|
||||
if action.id == Action.TUCKER
|
||||
world.playSound 'MOTOR', @getPos()
|
||||
|
||||
render: () ->
|
||||
# colors[0].glColor();
|
||||
#
|
||||
# KMatrix (orientation).glMultMatrix();
|
||||
#
|
||||
# render_cylinder;
|
||||
#
|
||||
# glTranslatef (0.0, 0.0, -0.5 * sin(value));
|
||||
#
|
||||
# KikiGear::getObjectColor(0).glColor();
|
||||
#
|
||||
# render_kolben;
|
||||
|
||||
module.exports = MotorCylinder
|
31
coffee/motorgear.coffee
Normal file
31
coffee/motorgear.coffee
Normal file
|
@ -0,0 +1,31 @@
|
|||
# 00 00 0000000 000000000 0000000 00000000 0000000 00000000 0000000 00000000
|
||||
# 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000
|
||||
# 000000000 000 000 000 000 000 0000000 000 0000 0000000 000000000 0000000
|
||||
# 000 0 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000
|
||||
# 000 000 0000000 000 0000000 000 000 0000000 00000000 000 000 000 000
|
||||
|
||||
Gear = require './gear'
|
||||
|
||||
class MotorGear extends Gear
|
||||
|
||||
constructor: (face) ->
|
||||
super face
|
||||
@setActive true
|
||||
|
||||
render: ->
|
||||
# colors[0].glColor();
|
||||
#
|
||||
# render_motor;
|
||||
#
|
||||
# if (active)
|
||||
# {
|
||||
# glRotatef (clockwise ? angle : -angle, 0.0, 0.0, 1.0);
|
||||
# }
|
||||
#
|
||||
# KikiGear::getObjectColor(0).glColor();
|
||||
#
|
||||
# glTranslatef (0.0, 0.0, 0.4);
|
||||
#
|
||||
# render_gear;
|
||||
|
||||
module.exports = MotorGear
|
|
@ -6,10 +6,12 @@
|
|||
|
||||
Pushable = require './pushable'
|
||||
Action = require './action'
|
||||
Face = require './face'
|
||||
|
||||
class Valve extends Pushable
|
||||
|
||||
constructor: (face) ->
|
||||
super
|
||||
@face = face
|
||||
@angle = 0.0
|
||||
@active = false
|
||||
|
|
|
@ -10,6 +10,7 @@ class Wire extends Item
|
|||
|
||||
constructor: (@face, @connections) ->
|
||||
|
||||
super
|
||||
@active = false
|
||||
@value = 1.0
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
Stone = require './stone'
|
||||
Wall = require './wall'
|
||||
Face = require './face'
|
||||
Wire = require './wire'
|
||||
Generator = require './generator'
|
||||
|
||||
class WireStone extends Stone
|
||||
|
@ -26,17 +27,17 @@ class WireStone extends Stone
|
|||
@wires[i].setActive false
|
||||
|
||||
for generator in world.getObjectsOfType Generator
|
||||
if generator.isActive()
|
||||
if generator.active
|
||||
generator.activateWires()
|
||||
|
||||
super action
|
||||
|
||||
setPosition: (pos) ->
|
||||
for i in [0...6]
|
||||
newPos = pos - Face.normalVectorForFace (i);
|
||||
newPos = pos.minus Face.normalVectorForFace i
|
||||
if @isFreePos newPos
|
||||
if not @wires[i]?
|
||||
@wires[i] = new KikiWire i
|
||||
@wires[i] = new Wire i
|
||||
world.addObjectAtPos @wires[i], newPos
|
||||
else
|
||||
world.setObjectAtPos @wires[i], newPos
|
||||
|
@ -46,7 +47,7 @@ class WireStone extends Stone
|
|||
@wires[i] = null
|
||||
|
||||
for generator in world.getObjectsOfType Generator
|
||||
if generator.isActive()
|
||||
if generator.active
|
||||
generator.activateWires()
|
||||
|
||||
super pos
|
||||
|
|
Loading…
Reference in New Issue
Block a user