PDA

View Full Version : Clone Hierarchy & Save Hierarchy As Scene



CROUTON213
10-20-2003, 11:55 AM
It would be very useful to have the ability to clone hierarchies (groups of parented elements) in Layout, just as we have the ability to clone single elements. As it is, for different groups I have to clear everything else out of the scene, save that group as a scene file, reload the original scene, and use the Load From Scene function to get the group loaded. If in the Scene Editor, when right clicking on an element (Object/Null, Light, Bone, etc.), it came with with Clone Group/Hierarchy as well as Clone, that would be very productive. Also to have the option to Save As Group or Save As Hierarchy and it would create a scene file with just those elements in the selected group/hierarchy.

papou
10-20-2003, 04:53 PM
there is a Lscript for that in your Lscript/utility directory. Don't remember if it come with lw7.5, maybe 7. It works but with a little anoying error message. I'm sure it can be corrected easily...
If it doesn't come with lw native, take it here:


//cloneHierarchy.ls
@version 2.3
@script generic
@name Clone Hierarchy

itemList;
maxRoots = 0;
curScene;

generic
{
curScene = Scene();
(curItem) = curScene.getSelect();

if(curItem == nil)
{
error("<br>You must select something before performing this operation.");
return;
}

memorizeHierarchy(curItem);
duplicateHierarchy(itemList[1][1],nil);
}

memorizeHierarchy: rootObj
{
childObj = rootObj.firstChild();
if(childObj)
{
itemList[++maxRoots][1] = rootObj;
itemList[maxRoots][2][1] = nil;

y = 0;
me = maxRoots;

while(childObj)
{
itemList[me][2][++y] = childObj;
childObj = rootObj.nextChild();
}

for(x = 1;x <= y;x++)
memorizeHierarchy(itemList[me][2][x]);
}
}

duplicateHierarchy: rootObj, cloneObj
{
for(x = 1;x <= maxRoots;x++)
last if itemList[x][1].id == rootObj.id;

return if x > maxRoots;

parentObj = itemList[x][1];

if(!cloneObj)
{
SelectItem(parentObj.id);
Clone(1);
(cloneObj) = curScene.getSelect();
}

if(itemList[x][2][1])
{
childSize = itemList[x][2].size();

for(y = 1;y <= childSize;y++)
{
SelectItem(itemList[x][2][y].id);
Clone(1);
ParentItem(cloneObj.id);

(newChild) = curScene.getSelect();
duplicateHierarchy(itemList[x][2][y],newChild);
}
}
}

CROUTON213
10-21-2003, 11:44 AM
This is exactly what I was wishing for! Thank you very much for showing me the CloneHierarchy Lscript. What a time & effort saver.