WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rate Thread Display Modes
Old 08-20-2009, 08:11 AM
ptjt255 ptjt255 is offline
Join Date: Oct 2008
Posts: 24
Start_position on animation path


Currently, I have the start position set at [2.0, 1.0, 0.0], but what I really want is for the start position to be wherever the avatar happens to be on the animation path, any help would be really appreciated.

# Creates and animation path for the avatar
path = viz.addAnimationPath()

points = [[2.0,1.5,0.0],[2.0,1.0,0],[2.0,0.0,0]]

for move in range(len(points)):
	global move
	cp = viz.add(viz.CONTROL_POINT)
	print move


# Link the avatar to the joystick and track position and elapsed time
# Defines collision parameters and avatar action on collision

import time

# Variables
result = 0 
tinc = 1/100
# from avatar to target the distance is 3.5m
joyscale_x = 1.40 # scale max x joystick velocity to 1.125 m/s maximum (roughly the time it takes to cross a single lane of a road) - 4 seconds to cross 4.5 meters which is 1.5 seconds per meter
joyscale_y = -1.40 # scale max y joystick velocity to 1.125 m/s maximum (roughly the time it takes to cross a single lane of a road)
start_position = [2.0, 1.0,0]

def position_loop():
	global start_position, result, x_prev, y_prev, x_velocity, y_velocity, ctime, ij, cframe, y_pos, x_pos, x, y, joy_position, i, select, p, ctime, pos_inc, start_position,elapsed_time,tinc
	x_velocity = 0.0
	y_velocity = 0.0
	x_prev = start_position[0]
	y_prev = start_position[1]
	#print 'y previous:', y_prev, 'x previous', x_prev
	Start_tick = time.time()
	cframe = 0

	def mytimer(tinc): 
		global result, x_prev, y_prev, ctime, ij, cframe, y_pos, x_pos, x, y, joy_position, i, select, p, ctime, x_velocity, y_velocity, elapsed_time
		# Set up joystick as velocity control
		ctime = time.time() - Start_tick
		cframe = cframe+1
		x = x_prev + x_velocity/60; y = y_prev + y_velocity/60
		joy_position = joystick.getPosition()
		x_prev = x; y_prev = y;
		x_velocity = joyscale_x*joy_position[0]; y_velocity = joyscale_y*joy_position[1]
		elapsed_time = time.time() - Start_tick
Reply With Quote
Old 08-24-2009, 11:40 AM
Jeff Jeff is offline
WorldViz Team Member
Join Date: Aug 2008
Posts: 2,471
How many different starting points are there? If there are just a few you could create several different paths using the same points. The points would just be in a different order. Then you could link the avatar to the path with matching starting point and play that one.
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 01:51 AM.

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