bot
This commit is contained in:
parent
5c7bb87014
commit
6b977041d0
|
@ -25,9 +25,11 @@ class Bot extends Pushable
|
||||||
@climb_orientation = new Quaternion
|
@climb_orientation = new Quaternion
|
||||||
@rest_orientation = new Quaternion
|
@rest_orientation = new Quaternion
|
||||||
|
|
||||||
|
tireRadius = 0.18
|
||||||
|
|
||||||
geom = new THREE.SphereGeometry 0.5, 32, 32
|
geom = new THREE.SphereGeometry 0.5, 32, 32
|
||||||
mat = new THREE.MeshPhongMaterial
|
mat = new THREE.MeshPhongMaterial
|
||||||
color: 0x0000ff
|
color: 0x222288
|
||||||
side: THREE.FrontSide
|
side: THREE.FrontSide
|
||||||
shading: THREE.SmoothShading
|
shading: THREE.SmoothShading
|
||||||
transparent: true
|
transparent: true
|
||||||
|
@ -36,30 +38,23 @@ class Bot extends Pushable
|
||||||
@mesh = new THREE.Mesh geom, mat
|
@mesh = new THREE.Mesh geom, mat
|
||||||
world.scene.add @mesh
|
world.scene.add @mesh
|
||||||
|
|
||||||
geom = new THREE.TorusGeometry 0.5, 0.2, 16, 64
|
geom = new THREE.TorusGeometry 0.5, tireRadius, 16, 16
|
||||||
mat = new THREE.MeshPhongMaterial
|
mat = new THREE.MeshPhongMaterial
|
||||||
color: 0x0000ff
|
color: 0x000044
|
||||||
side: THREE.FrontSide
|
side: THREE.FrontSide
|
||||||
shading: THREE.SmoothShading
|
shading: THREE.SmoothShading
|
||||||
transparent: true
|
transparent: true
|
||||||
opacity: 0.9
|
opacity: 0.9
|
||||||
shininess: 0.99
|
shininess: 0.99
|
||||||
|
|
||||||
@leftTire = new THREE.Mesh geom, mat
|
@leftTire = new THREE.Mesh geom, mat
|
||||||
@leftTire.position.set -0.5,0,0
|
@leftTire.position.set -0.5,0,0
|
||||||
@leftTire.rotation.set 0, Vector.DEG2RAD(90), 0
|
@leftTire.rotation.set 0, Vector.DEG2RAD(90), 0
|
||||||
@mesh.add @leftTire
|
@mesh.add @leftTire
|
||||||
|
|
||||||
geom = new THREE.TorusGeometry 0.5, 0.2, 16, 64
|
|
||||||
mat = new THREE.MeshPhongMaterial
|
|
||||||
color: 0x0000ff
|
|
||||||
side: THREE.FrontSide
|
|
||||||
shading: THREE.SmoothShading
|
|
||||||
transparent: true
|
|
||||||
opacity: 0.9
|
|
||||||
shininess: 0.99
|
|
||||||
@rightTire = new THREE.Mesh geom, mat
|
@rightTire = new THREE.Mesh geom, mat
|
||||||
@rightTire.position.set 0.5,0,0
|
@rightTire.position.set 0.5,0,0
|
||||||
@leftTire.rotation.set 0, Vector.DEG2RAD(-90), 0
|
@rightTire.rotation.set 0, Vector.DEG2RAD(-90), 0
|
||||||
@mesh.add @rightTire
|
@mesh.add @rightTire
|
||||||
|
|
||||||
@left_tire_rot = 0.0
|
@left_tire_rot = 0.0
|
||||||
|
@ -107,6 +102,13 @@ class Bot extends Pushable
|
||||||
addMoves: (m) -> @moves += m
|
addMoves: (m) -> @moves += m
|
||||||
addHealth: (h) -> @health = Math.max @health+h
|
addHealth: (h) -> @health = Math.max @health+h
|
||||||
|
|
||||||
|
|
||||||
|
# 0000000 000 00000000
|
||||||
|
# 000 000 000 000
|
||||||
|
# 000 000 000 0000000
|
||||||
|
# 000 000 000 000
|
||||||
|
# 0000000 000 00000000
|
||||||
|
|
||||||
die: () ->
|
die: () ->
|
||||||
Timer.removeActionsOfObject @
|
Timer.removeActionsOfObject @
|
||||||
|
|
||||||
|
@ -118,6 +120,12 @@ class Bot extends Pushable
|
||||||
@getEventWithName("died").triggerActions()
|
@getEventWithName("died").triggerActions()
|
||||||
@died = true
|
@died = true
|
||||||
|
|
||||||
|
# 00000000 00000000 0000000 00000000 000000000
|
||||||
|
# 000 000 000 000 000 000
|
||||||
|
# 0000000 0000000 0000000 0000000 000
|
||||||
|
# 000 000 000 000 000 000
|
||||||
|
# 000 000 00000000 0000000 00000000 000
|
||||||
|
|
||||||
reset: () ->
|
reset: () ->
|
||||||
|
|
||||||
@left_tire_rot = 0.0
|
@left_tire_rot = 0.0
|
||||||
|
@ -142,6 +150,12 @@ class Bot extends Pushable
|
||||||
|
|
||||||
isFalling: -> @move_action and @move_action.id == Action.FALL
|
isFalling: -> @move_action and @move_action.id == Action.FALL
|
||||||
|
|
||||||
|
# 0000000 0000000 000000000 000 0000000 000 000
|
||||||
|
# 000 000 000 000 000 000 000 0000 000
|
||||||
|
# 000000000 000 000 000 000 000 000 0 000
|
||||||
|
# 000 000 000 000 000 000 000 000 0000
|
||||||
|
# 000 000 0000000 000 000 0000000 000 000
|
||||||
|
|
||||||
initAction: (action) ->
|
initAction: (action) ->
|
||||||
log "initAction #{action.name}"
|
log "initAction #{action.name}"
|
||||||
newPos = new Pos @position
|
newPos = new Pos @position
|
||||||
|
@ -168,13 +182,19 @@ class Bot extends Pushable
|
||||||
log 'bot.initAction', newPos
|
log 'bot.initAction', newPos
|
||||||
world.objectWillMoveToPos @, newPos, action.getDuration()
|
world.objectWillMoveToPos @, newPos, action.getDuration()
|
||||||
|
|
||||||
|
# 00000000 00000000 00000000 00000000 0000000 00000000 00 00
|
||||||
|
# 000 000 000 000 000 000 000 000 000 000 000 000
|
||||||
|
# 00000000 0000000 0000000 000000 000 000 0000000 000000000
|
||||||
|
# 000 000 000 000 000 000 000 000 000 000 0 000
|
||||||
|
# 000 00000000 000 000 000 0000000 000 000 000 000
|
||||||
|
|
||||||
performAction: (action) ->
|
performAction: (action) ->
|
||||||
actionId = action.id
|
actionId = action.id
|
||||||
relTime = action.getRelativeTime()
|
relTime = action.getRelativeTime()
|
||||||
dltTime = action.getRelativeDelta()
|
dltTime = action.getRelativeDelta()
|
||||||
|
|
||||||
# log "Bot.performAction #{action.name} #{action.current} #{action.last} #{action.duration} id #{actionId}"
|
# log "Bot.performAction #{action.name} #{action.current} #{action.last} #{action.duration} id #{actionId}"
|
||||||
log "Bot.performAction #{action.name} #{relTime} #{dltTime} id #{actionId}"
|
# log "Bot.performAction #{action.name} #{relTime} #{dltTime} id #{actionId}"
|
||||||
|
|
||||||
switch actionId
|
switch actionId
|
||||||
when Action.SHOOT
|
when Action.SHOOT
|
||||||
|
@ -266,6 +286,12 @@ class Bot extends Pushable
|
||||||
|
|
||||||
@current_orientation = @orientation.mul @climb_orientation.mul @rotate_orientation.mul @rest_orientation
|
@current_orientation = @orientation.mul @climb_orientation.mul @rotate_orientation.mul @rest_orientation
|
||||||
|
|
||||||
|
# 00000000 000 000 000 000 0000000 000 000
|
||||||
|
# 000 000 0000 000 000 000 000 000
|
||||||
|
# 000000 000 000 0 000 000 0000000 000000000
|
||||||
|
# 000 000 000 0000 000 000 000 000
|
||||||
|
# 000 000 000 000 000 0000000 000 000
|
||||||
|
|
||||||
finishAction: (action) ->
|
finishAction: (action) ->
|
||||||
actionId = action.id
|
actionId = action.id
|
||||||
|
|
||||||
|
@ -310,6 +336,12 @@ class Bot extends Pushable
|
||||||
@orientation = @orientation.mul @rest_orientation # update rotation @orientation
|
@orientation = @orientation.mul @rest_orientation # update rotation @orientation
|
||||||
@rest_orientation.reset()
|
@rest_orientation.reset()
|
||||||
|
|
||||||
|
# 00000000 000 000 000 000 0000000 000 000 00000000 0000000
|
||||||
|
# 000 000 0000 000 000 000 000 000 000 000 000
|
||||||
|
# 000000 000 000 0 000 000 0000000 000000000 0000000 000 000
|
||||||
|
# 000 000 000 0000 000 000 000 000 000 000 000
|
||||||
|
# 000 000 000 000 000 0000000 000 000 00000000 0000000
|
||||||
|
|
||||||
actionFinished: (action) ->
|
actionFinished: (action) ->
|
||||||
actionId = action.id
|
actionId = action.id
|
||||||
log "bot.actionFinished #{action.name} #{actionId}"
|
log "bot.actionFinished #{action.name} #{actionId}"
|
||||||
|
@ -396,6 +428,12 @@ class Bot extends Pushable
|
||||||
# keep action chain flowinwg in order to detect environment changes
|
# keep action chain flowinwg in order to detect environment changes
|
||||||
# @startTimedAction @getActionWithId(Action.NOOP), 0
|
# @startTimedAction @getActionWithId(Action.NOOP), 0
|
||||||
|
|
||||||
|
# 00 00 0000000 000 000 00000000
|
||||||
|
# 000 000 000 000 000 000 000
|
||||||
|
# 000000000 000 000 000 000 0000000
|
||||||
|
# 000 0 000 000 000 000 000
|
||||||
|
# 000 000 0000000 0 00000000
|
||||||
|
|
||||||
moveBot: () ->
|
moveBot: () ->
|
||||||
@move_action = null
|
@move_action = null
|
||||||
log "bot.moveBot @position", @position
|
log "bot.moveBot @position", @position
|
||||||
|
@ -437,7 +475,6 @@ class Bot extends Pushable
|
||||||
@move_action.keepRest() # try to make subsequent actions smooth
|
@move_action.keepRest() # try to make subsequent actions smooth
|
||||||
Timer.addAction @move_action
|
Timer.addAction @move_action
|
||||||
|
|
||||||
|
|
||||||
# 0000000 000000000 00000000 00000000
|
# 0000000 000000000 00000000 00000000
|
||||||
# 000 000 000 000 000
|
# 000 000 000 000 000
|
||||||
# 0000000 000 0000000 00000000
|
# 0000000 000 0000000 00000000
|
||||||
|
@ -445,41 +482,10 @@ class Bot extends Pushable
|
||||||
# 0000000 000 00000000 000
|
# 0000000 000 00000000 000
|
||||||
|
|
||||||
step: (step) ->
|
step: (step) ->
|
||||||
# log 'Bot.step', step
|
|
||||||
radius = 0.5
|
|
||||||
tireRadius = 0.15
|
|
||||||
# log 'Bot.step', @current_position
|
|
||||||
@mesh.position.copy @current_position
|
@mesh.position.copy @current_position
|
||||||
@mesh.quaternion.copy @current_orientation
|
@mesh.quaternion.copy @current_orientation
|
||||||
|
@leftTire.rotation.set Vector.DEG2RAD(180*@left_tire_rot), Vector.DEG2RAD(90), 0
|
||||||
# @leftTire.rotation.copy @left_tire_rot
|
@rightTire.rotation.set Vector.DEG2RAD(180*@right_tire_rot), Vector.DEG2RAD(-90), 0
|
||||||
# @leftTire.rotation.copy @right_tire_rot
|
|
||||||
|
|
||||||
# if (@died) @getDeadColor().glColor()
|
|
||||||
# else @getTireColor().glColor()
|
|
||||||
|
|
||||||
# KMatrix(current_orientation).glMultMatrix()
|
|
||||||
# glPushMatrix() # tires
|
|
||||||
# glRotated(90.0, 0.0, 1.0, 0.0)
|
|
||||||
# glTranslated(0.0, 0.0, radius-tireRadius)
|
|
||||||
# glRotated(@left_tire_rot * 180.0, 0.0, 0.0, 1.0)
|
|
||||||
#
|
|
||||||
# render_tire
|
|
||||||
#
|
|
||||||
# glPopMatrix()
|
|
||||||
# glPushMatrix()
|
|
||||||
# glRotated(90.0, 0.0, 1.0, 0.0)
|
|
||||||
# glTranslated(0.0, 0.0, -(radius-tireRadius))
|
|
||||||
# glRotated(@right_tire_rot * 180.0, 0.0, 0.0, 1.0)
|
|
||||||
#
|
|
||||||
# render_tire
|
|
||||||
#
|
|
||||||
# glPopMatrix()
|
|
||||||
|
|
||||||
# if not @died then @getBodyColor().glColor()
|
|
||||||
|
|
||||||
# @render_body()
|
|
||||||
|
|
||||||
# if (@move_action or @rotate_action) and not @died
|
# if (@move_action or @rotate_action) and not @died
|
||||||
# unsigned now = getTime()
|
# unsigned now = getTime()
|
||||||
# if ((int)(now - last_fume) > mapMsTime (40))
|
# if ((int)(now - last_fume) > mapMsTime (40))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user