WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   problems nagivating around (https://forum.worldviz.com/showthread.php?t=2739)

ruby21 05-18-2010 02:12 AM

problems nagivating around
 
hi..im very new to vizard and i just want to simply nagivate around a building.ive managed move forward and backwards..but having problems moving right and left by keyboard.

heres the code that im using..could anyone tel me if the code is right or am i missing something out.i'd appreciate the help..thanks...



import viz

viz.go()

myView

myView = viz.get(viz.MAIN_VIEWPOINT)



def moveTimer(num):

if viz.iskeydown('a'):


myView.move (0,0,1)


if viz.iskeydown('z'):


myView.move (0,0,-1)

viz.callback(viz.TIMER_EVENT,moveTimer)
viz.starttimer(1,0.05,viz.FOREVER)


TURN = 25


def mytimer():

if viz.iskeydown(viz.KEY_RIGHT):

view.rotate(0,1,0,TURN*viz.elapsed(),viz.BODY_ORI, viz.REL_PARENT)



if viz.iskeydown(viz.KEY_LEFT):

view.rotate(0,1,0,-TURN*viz.elapsed(),viz.BODY_ORI,viz.REL_PARENT)



vizact.ontimer(0,0,1, mytimer)

Darkmax 05-18-2010 06:36 AM

please use the code tags when your are going to post code, because indentation is very important in python.
And for your navigation problem try this code:

Code:

import viz

viz.go()

viz.add("lab.ive")

myView = viz.MainView

TURN = 25
SPEED = 0.1
def moveView():
        if viz.iskeydown('a'):
                myView.move (0,0,SPEED)

        if viz.iskeydown('z'):
                myView.move (0,0,-SPEED)
       
        if viz.iskeydown(viz.KEY_RIGHT):
                myView.rotate(0,1,0,TURN*viz.elapsed(),viz.BODY_ORI, viz.REL_PARENT)

        if viz.iskeydown(viz.KEY_LEFT):
                myView.rotate(0,1,0,-TURN*viz.elapsed(),viz.BODY_ORI,viz.REL_PARENT)

vizact.ontimer(0,moveView)


ruby21 05-18-2010 03:22 PM

thanks mater..really appreciated that..it works..once again thank you and sorry that wont happen again i will make sure i use the code tags


All times are GMT -7. The time now is 11:27 PM.

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