View Single Post
  #3  
Old 06-09-2014, 02:37 AM
befl0 befl0 is offline
Member
 
Join Date: Jun 2014
Posts: 13
import viz
import vizact
import vizcam
import time
from StopWatch import StopWatch
from Start import Start
from Line import Line
from Square180 import Square180
from CircledCylinder import CircledCylinder
from EightFigure import EightFigure
from Square360 import Square360
from ReverseGate import ReverseGate

viz.setMultiSample(4)
viz.fov(60)
viz.go(viz.FULLSCREEN)

#This code adds a ground for them to stand on.
env = viz.addChild('ground_grass.osgb')
env.collidePlane()

Light = viz.add(viz.LIGHT)
Light.position(0,1,0,0)
Light.intensity(1)
Light.spread(180)

view=viz.MainView

viz.phys.enable()
male = viz.addAvatar('vcc_male2.cfg')
male.state(6)

view.setPosition(0,0.3,0)

link = viz.link(view, male)
link.preTrans([0,-0.8,0.45])
link.setEuler([None,-20,None])
#link.preTrans([0,-0.12,0.35])

MOVE_SPEED = 5
TURN_SPEED = 60
viz.phys.enable()


def updateMove():
if viz.key.isDown(viz.KEY_UP):
view.move([0,0,+MOVE_SPEED*viz.elapsed()],viz.BODY_ORI)
elif viz.key.isDown(viz.KEY_DOWN):
view.move([0,0,-MOVE_SPEED*viz.elapsed()],viz.BODY_ORI)
elif viz.key.isDown(viz.KEY_RIGHT):
view.setEuler([TURN_SPEED*viz.elapsed(),0,0],viz.BODY_ORI,viz.REL_PARENT)
elif viz.key.isDown(viz.KEY_LEFT):
view.setEuler([-TURN_SPEED*viz.elapsed(),0,0],viz.BODY_ORI,viz.REL_PARENT)

pass


vizact.ontimer(0,updateMove)

rampe=viz.addChild('rampe.wrl')
rampe.setPosition(0,0,1)
rampe.setEuler(0,90,0)
rampe.collideBox()
rampe.disable(viz.DYNAMICS)

rFootBox = viz.add('box.wrl',scale=[0.1,0.1,0.1])
rFootBox.collideBox()
rFootBox.disable(viz.DYNAMICS)
rFootBox.enable(viz.COLLIDE_NOTIFY)
rFoot = male.getBone('Bip01 R Foot')
rFoot.lock()
rFootLink = viz.link( rFoot , rFootBox )
rFootLink.preTrans([0.05,0.15,0.18])
rFootBox.disable(viz.RENDERING)


lFootBox = viz.add('box.wrl',scale=[0.1,0.1,0.1])
lFootBox.collideBox()
lFootBox.disable(viz.DYNAMICS)
lFootBox.enable(viz.COLLIDE_NOTIFY)
lFoot = male.getBone('Bip01 L Foot')
lFoot.lock()
lFootLink = viz.link( lFoot , lFootBox )
lFootLink.preTrans([0,0.15,0.18])
lFootBox.disable(viz.RENDERING)


def collidBox(e):
global poleArray
if (e.obj1 == rFootBox) or (e.obj1 == lFootBox):
if(e.obj2==rampe):
view.collision(viz.ON)
view.gravity(9.8)


viz.collision(viz.OFF)

viz.callback(viz.COLLIDE_BEGIN_EVENT,collidBox)



This is my code. I put the ramp I create with sketchup in a zip folder.

Thanks
Attached Files
File Type: zip ramp.zip (903 Bytes, 773 views)
Reply With Quote