WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 11-11-2015, 07:38 AM
vserchi vserchi is offline
Member
 
Join Date: Sep 2013
Posts: 7
Sorry my bad. Here is the simplest example I could think about. Even if I am interested only in the motion of the quads, I added also balls to show that my elements superimpose. When I attach a texture to the quads and they superimpose, the resulting effect is a flashing of the overlaid part. Do you have any suggestion?

Code:
import viz
import vizinfo
import vizact

viz.setMultiSample(4)
viz.fov(60)
viz.go()

#Add the ground plane
ground = viz.addChild('ground.osgb')

#Move the viewpoint back
viz.MainView.move([ 0, 0, -4])

#Initialize an array of control points
positions = [[ 2, 0, 0], [ 1, 0, 0], [ 0, 0, 0], [ -1, 0, 0], [ -2, 0, 0], [ -3, 0, 0], [ -4, 0, 0]]

#Define a variable to store the animation paths relative to each element
PATH = []

for i in range(0, len(positions)):	
	viz.startlayer(viz.QUADS) 
	viz.texCoord( 0, 1)
	viz.vertex(  -0.5, .005, -0.5)
	viz.texCoord( 1, 1)
	viz.vertex(  -0.5, .005, 0.5)
	viz.texCoord( 1, 0)
	viz.vertex(  0.5, .005, 0.5)
	viz.texCoord( 0, 0)
	viz.vertex(0.5, .005, -0.5)
	
	quad = viz.endLayer()
	ball= viz.addChild("beachball.osgb")
	
	exec('path' + str(i) + ' = viz.addAnimationPath()')
	PATH.append(eval('path' + str(i)))
	
	for x, pos in enumerate(positions):
		#Add a ball at each control point and make it
		#semi-transparent, so the user can see where the
		#control points are
		b = viz.addChild('beachball.osgb',cache=viz.CACHE_CLONE)
		b.setPosition(pos)
		b.alpha(0.2)
		
		PATH[i].addControlPoint( x + 1, pos = pos)
	
	#Set the initial loop mode to circular
	PATH[i].setLoopMode(viz.ON)
	
	# Add a control point at the second control point of path-i
	PATH[i].addEventAtControlPoint("positions", 1)
	
	# Link the ball  and the quad to the path
	viz.link( PATH[i], ball)
	viz.link( PATH[i], quad)
	
index = 1
def onPointReached1():
	# Trigger the start of the following animation path
	global index
	
	if index < len(PATH):
		PATH[index].play()

	index += 1
	
# Setup callbacks for each animation path
for i in range( 0, len(PATH) - 1):
	vizact.onPathEvent( PATH[i], "positions", onPointReached1)

#Play the first animation path
PATH[0].play()

#Setup path control panel
controlPanel = vizinfo.InfoPanel(text = None, title = 'Settings', icon = False)
slider_speed = controlPanel.addLabelItem('Speed', viz.addSlider())
slider_speed.set(0.1)

def changeSpeed(pos):
	#Adjust the speed of the animation path
	for i in range(0, len(PATH)):
		PATH[i].setSpeed( pos * 10 )

#Setup callbacks for slider events
vizact.onslider(slider_speed, changeSpeed)
Reply With Quote
Reply

Tags
animation, events, path, road, speed

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
Clarification on CAL3D Avatar Animation in Vizard shivanangel Vizard 2 11-22-2010 07:16 AM
positions on animation path whj Vizard 3 10-27-2009 01:21 PM
Start_position on animation path ptjt255 Vizard 1 08-24-2009 11:40 AM
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


All times are GMT -7. The time now is 08:24 PM.


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