#1
|
|||
|
|||
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() |
#2
|
|||
|
|||
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) |
#3
|
|||
|
|||
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)? |
#4
|
|||
|
|||
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) |
Thread Tools | |
Display Modes | Rate This Thread |
|
|