WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #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
  #2  
Old 01-22-2015, 04:39 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
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)
Reply With Quote
  #3  
Old 01-22-2015, 01:01 PM
Ryvan Ryvan is offline
Member
 
Join Date: Jan 2015
Posts: 3
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!
Reply With Quote
Reply

Tags
mainview, movement, newb

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
How to get real time position of a object which is connected to a haptic device Melody Vizard 4 09-15-2014 02:35 PM
Create object with position relative to user head, but cannot be obstructed by others Notch Vizard 2 03-03-2014 07:16 AM
Object + InteriaCube + Viewport problem Gekitatsu Vizard 1 02-22-2012 10:55 AM
Can you link the position of a tracker to the orientation of an object? michaelrepucci Vizard 1 09-19-2008 10:23 AM
picking problem... k_iwan Vizard 2 07-27-2007 07:57 PM


All times are GMT -7. The time now is 10:17 AM.


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