WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 02-22-2012, 07:39 AM
Gekitatsu Gekitatsu is offline
Member
 
Join Date: Feb 2012
Posts: 3
Object + InteriaCube + Viewport problem

Here is the scenario. We have an object (lets say default male avatar) we have to randomly rotate in all x,y,z coords. After the object is rotated we want to enable our InteriaCube to then augment the avatars current euler, but only based on the viewport. For example if the avatar is facing right (after our random rotate) when we enabled the link, and we rotate our cube down and forward the avatar will rotate on it's side while still facing right. We don't want the cube to rotate the avatar based on it's coord system we want all the rotation of the avatar to be based off of the viewport (when using the interia cube).


Few Notes

-When link is enabled between avatar & cube it must not change the direction of the avatar. The Cube is only suppose to augment the current euler of the avatar.

-The viewport will never move

-I've tried both manually augmenting the avatar's euler with input from the cube & using linking.


I've tried quite a few different approaches to get this to work, but with no real success. Anybody happen to know how to set this up?

-Random Rotation is already set avatar.setEuler(random.randint(0,360),random.randi nt(0,360),random.randint(0,360));


Any help would be great.
Reply With Quote
  #2  
Old 02-22-2012, 10:55 AM
Gekitatsu Gekitatsu is offline
Member
 
Join Date: Feb 2012
Posts: 3
Figured it out. I did find one problem with my solution. It turns out if you keep toggling the link (avatar with cube) it'll move the avatar a little bit, but that only happens if you keep toggling it without moving anything. If you can make any improvements to my solutions feel free.

Instructions: Click apply random rotation first, then click toggle link. Now that the link is enabled (text in upper right hand corner) you can rotate your object around using your cube. To set another random rotation you must first disable the link by clicking the toggle button again.

-Note each time you enable the link your cube will reset it's coord to make that it's origin (0,0,0);


Code:
import viz
import random;

viz.go();

#--------Create SkyBox-----------#
env = viz.add(viz.ENVIRONMENT_MAP, 'sky.jpg')
sky = viz.add('skydome.dlc')
sky.texture(env)
viz.clearcolor(0,0,1) # sky


#--------Create Tracker-----------#
isense = viz.add('intersense.dle')
tracker = isense.addTracker()
tracker.reset(); #Reset tracker to make it's current position it's origin 0,0,0

#--------Create Logo Model-----------#
logo = viz.add( 'logo.ive', pos =(0,1,5),euler = (-180,0,0) )
logo.setCenter(0,1,0);

#--------Create Initial Link-----------#
objectLink = viz.link(tracker,logo); # Create new link
objectLink.disable(); #Disable link until toggle enables it


#--------Create Labels-----------#
rotationLabel = viz.addButtonLabel('Apply Random Rotation')
rotationLabel.setPosition(.2,.9)

toggleLabel = viz.addButtonLabel('Toggle Link')
toggleLabel.setPosition(.2,.85)

toggleStatusLabel = viz.addText("Disabled",viz.SCREEN)
toggleStatusLabel.setPosition(.83,.95)
toggleStatusLabel.setScale(.5,.5);

def toggleLink(buttonState):
	if(buttonState == viz.DOWN): #If button is being pressed down
			global objectLink; # Gain access to global variable
			
			if(toggleStatusLabel.getMessage() == "Disabled"):
				
				tracker.reset(); # reset tracker ori matrix
				
				objectLink.remove(); # Remove old link (Prevent accumulation from preEuler)
				objectLink = viz.link(tracker,logo); # Create new link
				objectLink.preEuler(logo.getEuler()); # Rotate link to logo's orginal Euler
				
				toggleStatusLabel.message("Enabled");
				
			elif(toggleStatusLabel.getMessage() == "Enabled"):
				
				objectLink.disable();
				toggleStatusLabel.message("Disabled");
	
def onButton(obj,state):
	if obj == rotationLabel:
		if(state == viz.DOWN): #If button is being pressed down
			
			#Apply random rotation
			logo.setEuler(random.randint(-180,180),
						  random.randint(-180,180),
						  random.randint(-180,180));
			
	elif obj == toggleLabel:
		toggleLink(state);
	
viz.callback(viz.BUTTON_EVENT,onButton) #Simply call to function when any button is pressed
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
retrieve Object names Geoffrey Vizard 11 12-11-2009 04:26 AM
The problem of tracker using via VRPN _kj_ Vizard 2 08-13-2009 12:03 AM
Freeform view on an animated object problem jaylocco Vizard 2 06-08-2009 08:09 PM
picking problem... k_iwan Vizard 2 07-27-2007 07:57 PM
Center Viewport on Object (5DT Glove) bjgold Vizard 3 07-25-2006 03:22 PM


All times are GMT -7. The time now is 08:54 AM.


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