PDA

View Full Version : Positioning objects: center


johannes2
01-20-2008, 02:30 PM
I'm also having a hard time, positioning objects. Rotating and translating them with sinus and cosinus never leads to a perfect result. What to do?
Maybe it has to do with the center of the objects, but I do not seem to be able to fix it.

Tried the following:

1) Printing the center of the object.
print 'Center of Airtrack:'
print airtrack.get(viz.CenterCenter)
print 'Center of Glider:'
print gliderObj.get(viz.CenterCenter)

2) Changing the center:
gliderObj.center(0,airtrack.get(viz.CenterCenter)[1]-gliderObj.get(viz.CenterCenter)[1],0.08)

Surprisingly, printing the center after this still shows the sam center for gliderObj...

3) Trying it stupid / manually helped a bit but is no solution in the long run:
if key == 'b':
print 'air + gliderCenter'+ str(airtrack.get(viz.CenterCenter)[1]) + ' ' + str(gliderObj.get(viz.CenterCenter)[1])
offsetGliderCenterY=offsetGliderCenterY+0.01
gliderObj.center(0,-offsetGliderCenterY,-offsetGliderCenterZ)



How would you translate a glider on a slope that could be inclinded to different angles? Why does printing CenterCenter not show the new = different center. Did not find much help about this in the help-file.

Best,
Johannes

farshizzo
01-23-2008, 12:30 PM
You have to use the following code to retrieve the center of a node:obj.getCenter()Also, the center is only used to control the pivot point for rotations of a node.

If you want to translate a glider, then simply use the node.translate() command to position it. I'm not exactly clear on what the problem is. You might need to explain it more clearly or provide some sample code.

johannes2
02-12-2008, 02:56 AM
Thank you, this prints me the center and shows that both objects have the same center. Although I did not find (my) mistake yet this allows me to get more info. Thank's.