WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   How to make my scenes follow my ball? (https://forum.worldviz.com/showthread.php?t=6110)

saravanan.balak 02-14-2018 11:20 PM

How to make my scenes follow my ball?
 
I want my scenes to change when the ball moves from one position to another.

import viz
import vizinfo
import vizdlg
import vizinput
import time
import viztask
import vizact
data = viz.Data()

#viz.mouse(viz.OFF)
viz.go()
light1 = viz.addLight()
light1.setPosition(12.5,0,4)
light1.setEuler(0,20,0)
main=viz.MainView.setPosition(0,0,0)
env = viz.addChild('I:\Vi\File20171.dae')

env.setPosition(12.5,-1,3)
pos = env.getPosition()
orientation = env.setEuler(0,0,0)

ball = viz.addChild('volleyball.osgb')
ball.setScale([0.5,0.5,0.5])
path = viz.addAnimationPath()

points = [ [12.5,-1,3],[-13.999999237060547, 1.399999976158142, 13.5],[-35.59999923706055, 2.399999976158142, 12.5], [-47.979998779296875, 1.2999999523162842, 16.0], [-38.29999923706055, 1.399999976158142, 16.0], [12.5,-1,3] ]

for x,pos in enumerate(points):
path.addControlPoint(0.5*x,pos=pos)

path.setLoopMode(viz.LOOP)

path.play()


link = viz.link(path,ball)
link2 = viz.link(link1,env)

rajnishv 02-15-2018 08:14 AM

Pls find the below code and use it to integrate with your program code.

Code:


import vizcam
camera = vizcam.PivotNavigate()
camera.setDistance(5)

def moveCamera():
        while True:
              # Get the handle of the 3D Model as taken below
                lookAtPos = avatar.getBone('Bip01 Pelvis').getPosition(viz.ABS_GLOBAL)
                lookAtPos[1] = lookAtPos[1] + .5
                camera.setCenter(lookAtPos)
                camera.updateCenter()
                yield None       

viztask.schedule(moveCamera())

Thanx & Regards

Mr.Rajnish Vishwakarma


All times are GMT -7. The time now is 10:39 PM.

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