WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rate Thread Display Modes
Old 03-15-2009, 06:47 PM
nlfrnassimi nlfrnassimi is offline
Join Date: Feb 2009
Posts: 37
animation path

Hi every one,

I'm doing an application to teach children cross road. I'm trying to get the codes that I need. I have imported a character and placed a camera beside the character to act as first point of view, then I have assigned mouse movement to look around and arrow keys to move the character. I want to press a certain key and animate my character(moving from a point to another), can anyone please tell me how to do it. I have done it before but now combining it with this code it doesn't work.

Here is the code :

import viz


MOVE_SPEED = 5 # how fast the viewpoint move
TURN_SPEED = 60 # how fast the view point rotate

char = viz.add('vcc_male.cfg') 

view = viz.MainView
car = viz.add('mini.osgx')

def mytimer(num):
	if viz.iskeydown(viz.KEY_DOWN):
	elif viz.iskeydown(viz.KEY_UP):
	elif viz.iskeydown(viz.KEY_RIGHT):
	elif viz.iskeydown(viz.KEY_LEFT):


def updatechar():

#translate the character to the position of the viewpoint
#  char.translate(view.get(viz.HEAD_POS)) 
#rotate the character to the same orientation as the BODY_ORI.
#move the character beside the view.
  char.translate(1,0,0,viz.REL_LOCAL) #viz.REL_LOCAL. This tells vizard to translate the car relative to its local coordinate system (i.e. relative to the direction the car is facing).

def mousemove(e):
	#gets the Euler angle rotation of the HEAD_ORI
	euler = view.get(viz.HEAD_EULER)
	#adding the x movement of the mouse to the current yaw(we multiply the x movement by 0.1.  This is to decrease the sensitivity of the movement)
	euler[0] += e.dx*0.1
	#adds the y movement of the mouse to the current pitch. We need to negate the value since a positive pitch value means rotating down, but moving the mouse down means having a negative y movement. 
	euler[1] += -e.dy*0.1
	#clamping the pitch value between -90 and 90, since we don't want to let the user look down or up so much that they end up upside down.
	euler[1] = viz.clamp(euler[1],-90.0,90.0)
	#rotating the HEAD_ORI of the viewpoint by the new euler angle rotation
#Turn off built in  mouse
#Hide cursor

def mousedown(button):
	if button == viz.MOUSEBUTTON_LEFT:

	elif button == viz.MOUSEBUTTON_RIGHT:

Reply With Quote
Old 03-16-2009, 11:13 AM
Jeff Jeff is offline
WorldViz Team Member
Join Date: Aug 2008
Posts: 2,467
This will start an avatar walking when the spacebar is pressed.

import viz

male = viz.add('vcc_male.cfg')
walk = vizact.walkTo([0,0,5])
vizact.onkeydown(' ', male.addAction, walk)
Reply With Quote
Old 03-16-2009, 10:51 PM
nlfrnassimi nlfrnassimi is offline
Join Date: Feb 2009
Posts: 37
Thanks but this is not what I want. I want the same character (char) that I have attached a camera to it to be animated. The above code doesn't work.
Reply With Quote

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
Problems with interaction of vizact.turn and animation path Enlil Vizard 3 11-24-2008 04:23 PM
speed on animation path whj Vizard 8 11-17-2008 07:41 PM
real time collision on animation path whj Vizard 10 10-06-2008 04:38 PM
Animation Path djdesmangles Vizard 2 06-11-2007 03:37 PM
Animation Path djdesmangles Vizard 0 06-06-2007 11:03 AM

All times are GMT -7. The time now is 02:52 AM.

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