WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rating: Thread Rating: 10 votes, 5.00 average. Display Modes
  #1  
Old 09-29-2009, 07:48 AM
sircedric4 sircedric4 is offline
Member
 
Join Date: Aug 2009
Posts: 22
avatar scale and link.setpos conflict?

I am currently trying to link my Dtrack system to the vcc_male so that I have an avatar for myself when I am using WorldViz as a virtual reality tool.

I have successfully done this when the avatar scale is set to 1. My hand moves correctly and is linked correctly with what my motion capture sensor is doing. I am running into a problem when the code I used to get the avatar to track properly at a scale of 1 is then bumped to a higher scale.

Here is the code I use in order to make my left hand track correctly. I am only pasting the code specific to this issue:

Code:
#Setup Code:
	#Left Hand
	lhand = vrpn.addTracker('DTrack@vrsim1',1) #1 Left hand
	#Dtrack uses different axis than WorldViz, convert them
	lhand.swapPos([-2,3,1])		
	lhand.swapQuat([2,-3,-1,4])
	lhand.reset(viz.RESET_Y)

	avatar = viz.add('vcc_male.cfg') # Add the man avatar
#	avatar.setScale(1 * SCALE ,1 * SCALE ,1 * SCALE)

	lhandmodel = avatar.getBone('Bip01 L Hand')
	lhandmodel.lock()
	lhandlink = viz.link(lhand, lhandmodel, srcFlag = viz.LINK_ABSOLUTE, dstFlag=viz.LINK_ABSOLUTE)
	lhandlink.preEuler([90,0,90])
	lhandlink.setMask(viz.LINK_POS | viz.LINK_ORI)

#Time Based Code:
	pos = lhand.getPosition()
	euler = lhand.getEuler()
	newX = (pos[0] * SCALE + ORIGIN[0])
	newY = (pos[1]* SCALE + ORIGIN[1])
	newZ = (pos[2] * SCALE + ORIGIN[2])

	#Set avatar left hand
	print '0: ',SCALE, ORIGIN, pos
	debugmodel.setPosition([newX,newY,newZ])
	lhandlink.setPos([newX,newY,newZ],target = viz.LINK_POS_OP)
	lhandlink.update()
	print '1: ',newX, newY, newZ, lhandlink.getPosition()
Regardless of what scale I use in the above code, the hand is located in the right spot. Granted the scale of the actual hand is wrong but it is placed where it should be. I use a small coordinate model called debugmodel to show where my hand should be and the hand falls right on it.

When the "# avatar.setScale(1 * SCALE ,1 * SCALE ,1 * SCALE)" line is uncommented and allowed to run in the program, the hand is thrown way out in space. It still tracks and behaves as it should but is just way out there. I am thinking that the avatar scale is somehow multiplying with my setpos statement to put my avatar's hand in the wrong location.

Does somebody see what I am doing wrong with my link statement or how I am not applying a correct mask or something? If you need more information, I can post screenshots to help you understand my issue. (I have tried to divide my newX,newY,newZ equations by the scale in the setpos statement but that doesn't work either)

Thanks
Reply With Quote
Reply

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 10:18 AM.


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