WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 07-21-2006, 03:04 PM
bjgold bjgold is offline
Member
 
Join Date: Jul 2006
Posts: 19
Center Viewport on Object (5DT Glove)

All:

Some time ago, you wrote us some code to display and capture data from a 5DT DataGlove 5 Ultra. I am now experimenting with the code, and would like to be able to center the viewport around the glove initially (the glove and viewport will not move subsequent to the initial centering), but cannot figure out how to accomplish this. Attached is some sample code.

Thanks,
Brian
Code:
#	MAIN Start
#				
viz.go()
viz.fov(65,1.3)
#viz.fov(114,1.3)
#viz.get(viz.MAIN_VIEWPOINT).translate( STARTING_VIEWPOINT_POS )
#viz.get(viz.MAIN_VIEWPOINT).lookat(0,.3,0)

phase = SHOULDER_CALIBRATION

#Setup instructions
instructions = viz.add( viz.TEXT3D, SHOULDER_CALIBRATION_INSTRUCT, viz.SCREEN )
instructions.translate( .5, .5 )
instructions.scale( INSTRUCTION_SIZE, INSTRUCTION_SIZE )
instructions.alignment( viz.TEXT_CENTER_CENTER )

#Setup videoObject
#Create a texture quad to display video texture
videoQuad = viz.add( viz.TEXQUAD, viz.SCREEN )
videoQuad.translate( .5, .5 )
videoQuad.scale( VIDEO_SCREEN_SIZE, VIDEO_SCREEN_SIZE )
#Create a transform to scale coordinates to size of video
xform = viz.Transform()
xform.setScale(640,480,1)
#Apply texture matrix to quad
videoQuad.texmat(xform)
videoQuad.visible( viz.OFF )

view = viz.get(viz.MAIN_VIEWPOINT)

#Add sensors
handSensor = viz.add('patriot.dls')
armSensor = viz.add('patriot.dls')

#Add 5DT glove
PORT_5DT_USB = 0
gloveSensor = viz.add('5dt.dls')
#viz.gloveSensor()
#gloveSensor.reset()
print gloveSensor.get()
Reply With Quote
  #2  
Old 07-25-2006, 03:46 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You have the following in your sample code:
Code:
#viz.get(viz.MAIN_VIEWPOINT).translate( STARTING_VIEWPOINT_POS )
#viz.get(viz.MAIN_VIEWPOINT).lookat(0,.3,0)
This should do what you wish, assuming that the glove is centered around [0,0.3,0]. Does this not work for you?
Reply With Quote
  #3  
Old 07-25-2006, 04:19 PM
bjgold bjgold is offline
Member
 
Join Date: Jul 2006
Posts: 19
I guess the question would be how do we find the initial position of the glove (or shoulder), regardless of where the glove is in relation to the transmitter cube, since we don't necessarily know that it's at (0, .3, 0)?

To extend this, how would we center the viewport around the glove so that the glove is always centered in the viewport regardless of where the arm moves (this time allowing the arm and glove to move subsequent to the initial centering)?
Reply With Quote
  #4  
Old 07-25-2006, 04:22 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Just get the absolute position of the glove model and use the lookat command. I'm assuming you have some sort of 3d model representation of the glove:
Code:
glovePos = gloveModel.get(viz.POSITION,viz.ABSOLUTE_WORLD)
view.lookat(glovePos)
Reply With Quote
Reply


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 12:14 PM.


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