View Single Post
  #1  
Old 01-21-2015, 03:09 PM
Ryvan Ryvan is offline
Member
 
Join Date: Jan 2015
Posts: 3
Problem with object position

Hi everyone,

I'm pretty new to vizard so I'm hoping this will be an easy problem to solve!
My code generates the classroom floor found in the demo and when you push the wsda keys it moves you 4 spaces for 5 seconds. I also have a red shape.

The problem is the shape moves with the screen position and I want it to remain fixed! I know that it does this because of this line of code:
panel.addAction(forward)
#panel is the floor

Does any one know how to solve this problem?
Any comments or tips would be very appreciated!

My code:

"""
This script will demonstrate how to manually animate an object using timers.
"""
import viz
import vizact
import math

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

import vizinfo
vizinfo.InfoPanel()



#Add a ground plane
panel=viz.addChild('ground.osgb')
panel.setPosition([0.5,-1,1])

viz.clearcolor(viz.SLATE)


#add shape
h=viz.addChild('tut_hedra.wrl')
#Place the model in front of the viewer
h.setPosition([0,0,13], viz.ABS_GLOBAL)
h.setScale([1,1,1])
h.color( viz.RED )
h.transform = None

#hit h and it toggles it away
vizact.onkeydown('h', h.visible, viz.TOGGLE)


def AnimateView(pos):
action = vizact.move(pos,5)
forward=vizact.sequence(action)
panel.addAction(forward)
viz.MainView.runAction(action)



#Setup keyboard events
#move Left
vizact.onkeydown('d',AnimateView,(-4,0,0))
#move Right
vizact.onkeydown('a',AnimateView,(4,0,0))
#move Forwards
vizact.onkeydown('w',AnimateView,(0,0,-4))
#move Backwards
vizact.onkeydown('s',AnimateView,(0,0,4))
#STOP
vizact.onkeydown(' ',AnimateView,(0,0,0))
Reply With Quote