WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 04-28-2012, 01:56 PM
vrmdl vrmdl is offline
Member
 
Join Date: Mar 2012
Posts: 14
Hi,

Thanks for your reply. I found a strange thing in my codes. I ran exactly the same code as in the following. I found the image is correct every other run. In other words, the first time run gives a correct image. While in the second run, I got a wrong image. If I have a third run, I got a correct image again. Can anyone help me with it? Thanks.

The following codes simply draw a straight line and link to a my fly stick.


import viz
import vizact
import vizcam
import vizcave
import viztracker


# Declare constants defining the CAVE dimensions
W = 3.410 # 10 feet wide
H = 2.140 #7.5 feet tall
D = 2.200 # 7.5 feet deep

offset_bottom_wall=0.0

C0 = -W/2,H/2,-D/2 # Front Wall: C1,C2,C5,C6
C1 = -W/2,H/2-offset_bottom_wall,D/2 # Left Wall: C0,C1,C4,C5
C2 = W/2,H/2-offset_bottom_wall,D/2 # Right Wall: C2,C3,C6,C7
C3 = W/2,H/2,-D/2 # Bottom Wall: C5,C6,C4,C7

C4 = -W/2,-H/2-offset_bottom_wall,-D/2
C5 = -W/2,-H/2-offset_bottom_wall,D/2
C6 = W/2,-H/2-offset_bottom_wall,D/2
C7 = W/2,-H/2-offset_bottom_wall,-D/2

#Create front wall
FrontWall = vizcave.Wall( upperLeft=C1, # 0, 2.286, 3.048
upperRight=C2, # 3.048, 2.286, 3.048
lowerLeft=C5, # 0, 0, 3.048
lowerRight=C6, # 3.048, 0, 3.048
name='Front Wall' )

#Create bottom wall
BottomWall = vizcave.Wall( upperLeft=C5,
upperRight=C6,
lowerLeft=C4,
lowerRight=C7,
name='Bottom Wall' )

#Create cave object
cave = vizcave.Cave()

frontWindow=viz.MainWindow
frontWindow.setSize(1,.5)
frontWindow.setPosition([0,1])
cave.addWall(FrontWall, window = frontWindow)

bottomWindow = viz.addWindow()
bottomWindow.setSize(1,.5)
bottomWindow.setPosition([0,0.5])
cave.addWall(BottomWall, window = bottomWindow)

frontWindow.stereo(viz.QUAD_BUFFER)
bottomWindow.stereo(viz.QUAD_BUFFER)

#Create tracker object using the keyboard (WASD keys control the viewpoint, the user's eye location)
#Make the starting location for the user's eye above origin
viewtracker = viztracker.KeyboardPos()
viewtracker.setPosition([0.0,0,0.0])

#Pass the viewpoint tracker into the cave object so it can be automatically updated
cave.setTracker(pos=viewtracker,ori=viewtracker)

#Create CaveView object for manipulating the entire cave environment
#The caveorigin is a node that can be adjusted to move the entire cave around the virtual environment
caveorigin = vizcave.CaveView(viewtracker)

#Create another tracker using the keyboard and mouse (arrow keys adjust position, mouse changes orientation)
origintracker = viztracker.KeyboardMouse6DOF()
origintracker.setPosition(0,0.5,0)

#Link the keyboard/mouse so that it moves the cave and user around the virtual environment
originlink = viz.link (origintracker, caveorigin)


vrpn = viz.add('vrpn7.dle') # can be vrpn6.dle or vrpn7.dle depending on vrpn version
headTrkr = vrpn.addTracker('DTrack@localhost',0)
flyTrkr = vrpn.addTracker('DTrack@localhost',2)
flyStick_button = vrpn.addButton('DTrack@localhost')
joystick = vrpn.addAnalog('DTrack@localhost')

#Negate Z value of position
flyTrkr.swapPos([1,2,-3])
#Negate X,Y value of quaternion
flyTrkr.swapQuat([-1,-2,3,4])


#Create line of length 1
length=10
viz.startlayer(viz.LINES)
viz.vertexColor(viz.GREEN)
viz.lineWidth(4)
viz.vertex(0,0,0)
viz.vertex(0,0,length)
pointer_line = viz.endlayer()
pointer_line.dynamic()

link_pointer = viz.link( flyTrkr, pointer_line )

viz.go(viz.FULLSCREEN|viz.QUAD_BUFFER)
Reply With Quote
 

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


All times are GMT -7. The time now is 08:13 PM.


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