View Full Version : newbie rotation woes

02 February 2005, 03:39 PM
Ok I'm writing a script (v7) to assemble a playground from a set of component files. These components have one or multiple objects in them in varying materials, and each object has its pivot point located at the origin. The script reads in a comma-delimited txt that lists a block name, x,y,z insertion coordinates, and a rotation value. It then cycles through, inserting a component, relocating it, and rotating it to proper orientation.

What happens is that the components are merged and relocated correctly, but rotations for grouped objects are not set correctly. Is this a limitation of the approach i'm using here?:

rotComponent = eulerangles 0 0 (rotationArray[b] as float)
rotate s rotComponent

Like I said, it works fine for single objects, and grouped objects do rotate, just not correctly. tia for any info. Here's the full script for reference:

blockArray = #()
xValArray = #()
yValArray = #()
zValArray = #()
rotationArray = #()

in_name = ("C:\TEMP\PS5-19109.TXT")
in_file = openFile in_name
if in_file != undefined then
a = 1
while not eof in_file do
blockArray[a] = readDelimitedString in_file ","
xValArray[a] = readDelimitedString in_file ","
yValArray[a] = readDelimitedString in_file ","
zValArray[a] = readDelimitedString in_file ","
rotationArray[a] = readDelimitedString in_file ","
a += 1

b = 1

while b <= blockArray.count do
mergeMAXFile (nativeSourcePath + "/" + blockArray[b] + ".max") #mergeDups #select
s = getCurrentSelection()
setCoordCenter #local
s.pos = [(xValArray[b] as float),(yValArray[b] as float),(zValArray[b] as float)]
rotComponent = eulerangles 0 0 (rotationArray[b] as float)
rotate s rotComponent
b += 1

02 February 2005, 06:38 AM
You're probably going through each object in the group and rotating them instead of just rotating the group head (usually a dummy object). You can check if the object is part of a group by doing a isGroupMember() check and you can check if it ais a group head by doing a isGroupHead() check.

Check the MaxScript reference for more info on accessing groups.

CGTalk Moderation
02 February 2006, 07:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.