WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-13-2009, 10:08 PM
jaylocco jaylocco is offline
Member
 
Join Date: Jun 2009
Posts: 19
Red face manipulating viewpoint

Hi,

I wish to create a simulation of tank movement. as it move forward, the turret will be able to turn right and left when the correspondent key is being pressed.
But how do I make the turret to slowly return back to body_ori (facing in front back again) when I release the key? what I have here in the code, makes the turret to reappear to original position in a flash. also, why my turret does not turn smoothly like in TIME_EVENT? Is it normal in KEYDOWN_EVENT and KEYUP_EVENT?

Code:
def onkeydown(key):
 if key == viz.KEY_RIGHT:
    view.rotate(0,1,0,turn_speed*viz.elapsed(),viz.BODY_ORI,viz.REL_PARENT)
 elif key == viz.KEY_LEFT:
  view.rotate(0,1,0,-turn_speed*viz.elapsed(),viz.BODY_ORI,viz.REL_PARENT)

viz.callback(viz.KEYDOWN_EVENT,onkeydown)

def onKeyUp(key):
    if key == viz.KEY_RIGHT:
     view.reset(viz.HEAD_ORI | viz.BODY_ORI) 
    elif key == viz.KEY_LEFT:
     view.reset(viz.HEAD_ORI | viz.BODY_ORI)

viz.callback(viz.KEYUP_EVENT,onKeyUp)
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to track the actual viewpoint Jerry Vizard 3 05-25-2016 09:44 AM
Draw Vector in viewpoint lookat direction Chrissy2009 Vizard 2 05-30-2009 12:50 AM
Avatar w/ hat cannot look at viewpoint TrashcanPatrol Vizard 5 08-19-2008 08:26 AM
3d viewpoint movement spacefarer Vizard 9 07-25-2006 03:37 PM
VRML Viewpoint error bstankie Vizard 1 03-11-2003 02:10 PM


All times are GMT -7. The time now is 01:05 PM.


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