Page 1 of 1

How to connect a scatter node with an Orbx instance

PostPosted: Tue Jul 21, 2015 7:47 am
by xhm2855
I created an Octane file with lua script. And I need to import a orbx file into current graph as 'node graph', and then use a scatter node to link it.
But the error is happened in the scatter node connected to the orbx node graph. and the error info is 'bad argument #2 to 'connectTo' (octane.node expected, got nil)'
And my question is how to fix this script and make it work?

Thanks.

Below is the scripts:
---import the orbx file into current graph.
mm=octane.nodegraph.createRootGraph("BLDG")
octane.nodegraph.importFromFile(mm, "z:\\lib\\Model_orbx\\BLDG\\BLDG_5400_4500_LR.orbx")
octane.project.getSceneGraph():copyFromGraph(mm,{})
octane.nodegraph.destroy(mm)
---create a scatter node and connect to the orbx-imported node graph.
BLDGScatterNode=octane.node.create{
name="BLDG";
type=octane.NT_GEO_SCATTER;
position={-1019.26,28};
}
BLDGScatterNode:connectTo(octane.P_GEOMETRY,BLDG);
BLDGScatterNode:setAttribute("scaleUnitType",4);
transforms =
{
{
{ 1,0,-0,0 },
{ 0,1,-0,0 },
{-0,-0,1,-0 }
},
}
BLDGScatterNode:setAttribute(octane.A_TRANSFORMS,transforms);
BLDGScatterNode:setAttribute("inherit",true);

Re: How to connect a scatter node with an Orbx instance

PostPosted: Wed Aug 05, 2015 10:31 am
by zc0_0
You should do it as below:
1. Don't group your nodes in the orbx file. and use a 'Geomstry Group' node as the last one. And named this geomstry group node by a id value.
2. import this orbx file into current scene.
3. use 'octane.project.getSceneGraph():findNodes(octane.NT_GEO_GROUP)' method to find all geomstry group node in current scene. Notice: only the geomestry group node of orbx file can be found in this scene by this way.
4. use for loop to find the group node you want to connect and connect it.

Below is some clauses of a sample.

fireplace_ScatterNode=octane.node.create{
name="fireplace";
type=octane.NT_GEO_SCATTER;
position={-19.26,28};
}
--缺fireplace_ScatterNode连接到fireplace节点
--fireplace_ScatterNode:connectTo(octane.P_GEOMETRY,Molding_MeshNode);
fireplace_ScatterNode:setAttribute("scaleUnitType",4);
transforms =
{
{
{0,0,1,0},
{0,1,-0,5.65371e-016},
{-1,-0,0,-2.70794}
},
}
fireplace_ScatterNode:setAttribute(octane.A_TRANSFORMS,transforms);
fireplace_ScatterNode:setAttribute("inherit",true);
mm=octane.nodegraph.createRootGraph("fireplace_ScatterNode")
octane.nodegraph.importFromFile(mm, "c:\\Kamin_fireplace_2284_707_3000.orbx")
octane.project.getSceneGraph():copyFromGraph(mm,{})
octane.nodegraph.destroy(mm)

for i,v in ipairs(octane.project.getSceneGraph():findNodes(octane.NT_GEO_GROUP)) do
if v.name=="test2" then
fireplace_ScatterNode:connectTo(octane.P_GEOMETRY,v)
print(v.name);
break;
end
--print(v.name);
end