WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 08-16-2007, 02:30 PM
Vinicius Lima Vinicius Lima is offline
Member
 
Join Date: Jul 2007
Posts: 40
PHP Code:
import viz
viz
.go()

#Changing the background color to SKYBLUE
viz.clearcolor(0.5,0.5,1)

#Defining the move and the turn speeds
MOVE_SPEED 5
TURN_SPEED 
60

#Adding the objects to the world
ground viz.add('ground.osg')
car viz.add('car.osg')

#Getting main viewpoint object
view viz.get(viz.MAIN_VIEWPOINT)

def mytimer(num):
    
    if 
viz.iskeydown(viz.KEY_UP):
        
view.move(0,0,MOVE_SPEED*viz.elapsed(),viz.BODY_ORI)
    
elif viz.iskeydown(viz.KEY_DOWN):
        
view.move(0,0,-MOVE_SPEED*viz.elapsed(),viz.BODY_ORI)
        
    if 
viz.iskeydown(viz.KEY_RIGHT):
        
view.rotate(0,1,0,TURN_SPEED*viz.elapsed(),viz.BODY_ORI,viz.RELATIVE_WORLD)
    
elif viz.iskeydown(viz.KEY_LEFT):
        
view.rotate(0,1,0,-TURN_SPEED*viz.elapsed(),viz.BODY_ORI,viz.RELATIVE_WORLD)

    
updatecar()
    
def updatecar():
  
car.translate(view.get(viz.HEAD_POS))
  
car.rotate(view.get(viz.BODY_AXISANGLE))
  
car.translate(0.35,-1.2,0.2,viz.RELATIVE_LOCAL)
#def updatecar():
#    car.translate(view.get())
#    car.rotate(view.getAxisAngle(viz.BODY_ORI))
#    car.translate(0.35,-1.2,0.2,viz.RELATIVE_LOCAL)
    
def mousemove(e):
    
#euler = view.getEuler(viz.HEAD_ORI)
    
euler view.get(viz.HEAD_EULER)
    
euler[0] += x*0.1
    euler
[1] += -y*0.1
    euler
[1] = viz.clamp(euler[1],-90.0,90.0)
    
view.rotate(euler,viz.HEAD_ORI)

def mousedown(button):
    if 
button == viz.MOUSEBUTTON_LEFT:
        
view.reset(viz.HEAD_ORI)
    
elif button == viz.MOUSEBUTTON_RIGHT:
        
view.reset(viz.BODY_ORI|viz.HEAD_POS)
        
updatecar()


viz.callback(viz.TIMER_EVENT,mytimer)
viz.starttimer(0,0.01,viz.FOREVER)

viz.callback(viz.MOUSEMOVE_EVENT,mousemove)
viz.mousedata(viz.RELATIVE,viz.RELATIVE)
viz.setMouseOverride()
viz.cursor(viz.OFF)

viz.callback(viz.MOUSEBUTTON_EVENT,mousedown)

viz.mouse(viz.OFF)
viz.restrictmouse(viz.ON
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 04:50 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC