WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Problem with object position (https://forum.worldviz.com/showthread.php?t=5264)

Ryvan 01-21-2015 03:09 PM

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))

Jeff 01-22-2015 04:39 AM

I don't understand the issue. An action is applied to both the ground object and the viewpoint. Is that what you want? The shape is not being moved. You can check the shape position by adding the following code:

Code:

def printShapePosition():
        print h.getPosition(viz.ABS_GLOBAL)
       
vizact.ontimer(1,printShapePosition)


Ryvan 01-22-2015 01:01 PM

Hi! Thanks for your reply.

I'm trying to create a program where a person sees a shape and they toggle it off. Then they move in a certain direction and have to point to the remembered location of the shape, which is then toggled on to see if they are correct.

Currently when I run the program the shape stays centered in the view instead of remaining in a fixed location on the plane. I was hoping that as I moved in any direction that I could move past the shape.

I hope that helps to clarify what I mean.

Thanks for your help!


All times are GMT -7. The time now is 08:26 AM.

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