Question 7:
Do nodes always have unique names? And are they always recorded after their parents in the mdl file?
node trimesh Cylinder
parent 1test
I am working on my importer script, and decided to perform operations (creation and modification of actual objects in Cheetah3d) according to each line of the file as I read it in.
As you can see I'm currently dealing with setting the parent of a node. Given the mdl data above when I reach the "parent" declaration, I look through all existing objects named "1test" that I've created in my Cheetah3d scene. The first match I find gets returned and becomes the proud new parent of the node I last created.
If the answer to either of my questions above is "no", I will need to put some serious thought into how I handle this (perhaps read the entire mdl file in all at once, and use various string parsing functions on that data rather than execute the code of the mdl immediately).
___
My find Node by name code
function getNodeByName(name,mdl_base)
{
// create a check list of nodes to check
// start with the mdl_base
var check_list = [mdl_base];
while(check_list.length>0)
{
// start with the last index of the array of nodes to check
var node = check_list.pop();
// check its name
if(node.getParameter('name')==name)
return node;
// add its children to the array of nodes to check
for(i=0;i<node.childCount();i++)
check_list.push(node.childAtIndex(i));
}
return null;
}