View Single Post
  #1  
Old 02-09-2009, 11:57 AM
hosier hosier is offline
Member
 
Join Date: Feb 2007
Posts: 31
Lightwave objects rotation problem

Hello. I have a Lightwave model made up of 50+ objects. All of the objects in this model have a center point of [0,0,0] even though that isn't what I would consider their center of mass. As such, the objects aren't rotating around what would be their visible center.

The creator of the model doesn't know how to change this in his model, and has instead given me the coordinates for each object. Right now I've written a simple Vizard program to load the model and then use getChild to create a node variable for one of the objects. I've tried using the <node3d>.center function to change the pivit point for the object, but it still doesn't rotate around it.

Here's my program:
Code:
# import the required system functions
import viz


# start vizard
viz.go()

# Load the complete bovine model
bovine = viz.add('all_centered.lwo')

# Move our viewpoint
viz.MainView.setPosition(4,0,0)
viz.MainView.setEuler(-90,0,0)

# get a node for one muscle in the model
muscle = bovine.getChild('005')

#make the rest of the carcass transparent
bovine.alpha(0)
muscle.alpha(1)

# Marker to show new rotation point
MARKER = viz.add('ball.wrl')
MARKER.setScale(.25,.25,.25)
MARKER.setPosition(.0695,.0346,.7674)


print 'My Position: ',muscle.getPosition(viz.ABS_GLOBAL)
print 'My Orientation: ',muscle.getEuler(viz.ABS_GLOBAL)
print 'Muscle Center: ',muscle.getCenter()
print 'Marker Center: ',MARKER.getCenter()

muscle.center(.0695,.0346,.7674)

print 'My Position: ',muscle.getPosition(viz.ABS_GLOBAL)
print 'My Orientation: ',muscle.getEuler(viz.ABS_GLOBAL)
print 'Muscle Center: ',muscle.getCenter()
print 'Marker Center: ',MARKER.getCenter()



##############################################
## This function deals with keyboard events ##
##############################################
def mykeyboard(key):

	global muscle
	global MARKER
	
# rotate left
	if key == 'j':
		muscle.setEuler(5,0,0,viz.REL_GLOBAL)
		print "Muscle Center: ",muscle.getCenter()
		print "Muscle Position: ",muscle.getPosition()
		
# rotate right
	if key == 'k':
		muscle.setEuler(-5,0,0,viz.REL_GLOBAL)
		print "Muscle Center: ",muscle.getCenter()
		print "Muscle Position: ",muscle.getPosition()

# rotate up
	if key == 'i':
		muscle.setEuler(0,0,5,viz.REL_GLOBAL)
		print "Muscle Center: ",muscle.getCenter()
		print "Muscle Position: ",muscle.getPosition()

# rotate down
	if key == 'm':
		muscle.setEuler(0,0,-5,viz.REL_GLOBAL)
		print "Muscle Center: ",muscle.getCenter()
		print "Muscle Position: ",muscle.getPosition()



#######################################################################
viz.callback(viz.KEYBOARD_EVENT,mykeyboard)
Am I missing something, or could it be because of the model? I can upload that if need be.

Thanks in advance for any help I can get.

Aaron
Reply With Quote