#1
|
|||
|
|||
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) |
#2
|
|||
|
|||
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. |
#3
|
|||
|
|||
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? |
#4
|
|||
|
|||
<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. |
#5
|
|||
|
|||
Thanks for the tip..never thought of it... good one
|
#6
|
|||
|
|||
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) |
|
|
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 |