WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #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
  #2  
Old 09-14-2009, 01:51 AM
jaylocco jaylocco is offline
Member
 
Join Date: Jun 2009
Posts: 19
Also how do we animate view to fly like a bird? How do we set the view, if I want to animate a rollercoaster, how to make the camera view follows him on top of the head..

Thanks

Last edited by jaylocco; 09-14-2009 at 01:56 AM.
Reply With Quote
  #3  
Old 09-15-2009, 02:00 AM
jaylocco jaylocco is offline
Member
 
Join Date: Jun 2009
Posts: 19
Got the roller coaster viewpoint

Just wana share

I have just discovered the way to make the viewpoint move like roller coaster.
First we need to animate the path using control points then set the move mode as Cubic Bezier. in order to get the view moves as well, link pos the view with the car

link = viz.link(car, viz.MainView)
link.setMask(viz.LINK_POS)

for reference check the animatepath.py in the Help section

BUT does anyone have any idea how to do the Tank turret problem I sent earlier?
Reply With Quote
  #4  
Old 09-17-2009, 11:10 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
<viewpoint>.reset will not animate the view spinning back to its original orientation.

You could use <viewpoint>.spinto and give the orientation to spin to and the speed or time it will take.
Reply With Quote
  #5  
Old 09-22-2009, 06:35 PM
jaylocco jaylocco is offline
Member
 
Join Date: Jun 2009
Posts: 19
Thanks for the tip..never thought of it... good one
Reply With Quote
  #6  
Old 09-22-2009, 08:20 PM
jaylocco jaylocco is offline
Member
 
Join Date: Jun 2009
Posts: 19
Question but how?

ahah...just encounter this...by using the spinto, how do I determine the degree of angle for it to animate back to the original position? because the amount of degree depends on how long I press the Right or Left button. Which mean, it is not fix to an amount of degree.Or, is there anyway that I can calculate the angle based on how long I press the button? so that I could assign the value to a variable which later to be applied in spinto

Degree = 'amount of degree'

<viewpoint>.spinto([x,y,z,Degree],value)
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 05:12 AM.


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