CStatus VDB_Node_VolumeToMesh::Register(PluginRegistrar& reg) { ICENodeDef nodeDef; Factory factory = Application().GetFactory(); nodeDef = factory.CreateICENodeDef(L"VDB_Node_VolumeToMesh", L"Volume To Mesh"); CStatus st; st = nodeDef.PutColor(110, 110, 110); st.AssertSucceeded(); st = nodeDef.PutThreadingModel(siICENodeSingleThreading); st.AssertSucceeded(); // Add custom types definition st = nodeDef.DefineCustomType(L"vdb_prim" ,L"VDB Grid", L"openvdb grid type", 155, 21, 10); st.AssertSucceeded(); // Add input ports and groups. st = nodeDef.AddPortGroup(kGroup1); st.AssertSucceeded(); // Add custom type names. CStringArray customTypes(1); customTypes[0] = L"vdb_prim"; // stupid default arguments wont work have to add ULONG_MAX st = nodeDef.AddInputPort(kVDBGrid, kGroup1, customTypes, siICENodeStructureSingle, siICENodeContextSingleton, L"VDB Grid", L"inVDBGrid",ULONG_MAX,ULONG_MAX,ULONG_MAX); st.AssertSucceeded(); st = nodeDef.AddInputPort(kIsoValue, kGroup1, siICENodeDataFloat, siICENodeStructureSingle, siICENodeContextSingleton, L"Iso Value", L"isoValue", 0.0); st.AssertSucceeded(); st = nodeDef.AddInputPort(kAdaptivity, kGroup1, siICENodeDataFloat, siICENodeStructureSingle, siICENodeContextSingleton, L"Adaptivity", L"adaptivity", 0.0); st.AssertSucceeded(); // Add output ports. st = nodeDef.AddOutputPort(kPointArray, siICENodeDataVector3, siICENodeStructureArray, siICENodeContextSingleton, L"Point Array", L"pointList"); st.AssertSucceeded(); st = nodeDef.AddOutputPort(kPolygonArray, siICENodeDataLong, siICENodeStructureArray, siICENodeContextSingleton, L"Polygon Array", L"polygonPoolList"); st.AssertSucceeded(); PluginItem nodeItem = reg.RegisterICENode(nodeDef); nodeItem.PutCategories(L"OpenVDB"); return CStatus::OK; }
CStatus VDB_Node_FBM::Register(PluginRegistrar& reg) { ICENodeDef nodeDef; Factory factory = Application().GetFactory(); nodeDef = factory.CreateICENodeDef(L"VDB_Node_FBM", L"VDB FBM"); CStatus st; st = nodeDef.PutColor(110, 110, 110); st.AssertSucceeded(); st = nodeDef.PutThreadingModel(siICENodeSingleThreading); st.AssertSucceeded(); // Add custom types definition st = nodeDef.DefineCustomType(L"vdb_prim" ,L"VDB Grid", L"openvdb grid type", 155, 21, 10); st.AssertSucceeded(); // Add input ports and groups. st = nodeDef.AddPortGroup(kGroup1); st.AssertSucceeded(); // Add custom type names. CStringArray customTypes(1); customTypes[0] = L"vdb_prim"; st = nodeDef.AddInputPort(kInVDBGrid, kGroup1, customTypes, siICENodeStructureSingle, siICENodeContextSingleton, L"In", L"inVDBGrid",ULONG_MAX,ULONG_MAX,ULONG_MAX); st.AssertSucceeded(); st = nodeDef.AddInputPort(kOctaves, kGroup1, siICENodeDataLong, siICENodeStructureSingle, siICENodeContextSingleton, L"Octaves", L"octaves", CValue(6)); st.AssertSucceeded(); st = nodeDef.AddInputPort(kLacunarity, kGroup1, siICENodeDataFloat, siICENodeStructureSingle, siICENodeContextSingleton, L"Lacunarity", L"lacunarity", CValue(2.0)); st.AssertSucceeded(); st = nodeDef.AddInputPort(kGain, kGroup1, siICENodeDataFloat, siICENodeStructureSingle, siICENodeContextSingleton, L"Gain", L"gain", CValue(0.5)); st.AssertSucceeded(); st = nodeDef.AddOutputPort(kOutVDBGrid, customTypes, siICENodeStructureSingle, siICENodeContextSingleton, L"Out", L"outVDBGrid"); st.AssertSucceeded(); PluginItem nodeItem = reg.RegisterICENode(nodeDef); nodeItem.PutCategories(L"OpenVDB"); return CStatus::OK; }
/* * === FUNCTION ====================================================================== * Name: GetMessage * Description: 以阻塞的方式从消息队列中取出一条消息 * ===================================================================================== */ CMessage * CUsrDefMsgQueue::GetMessage() { CStatus s = m_Event.Wait(); if( !s.IsSuccess() ) { throw s; } return Pop(); }
CThreadForMsgLoop:: ~CThreadForMsgLoop() { if(m_bWaitForDeath && m_pThread != 0) { CStatus s = m_pThread->WaitForDeath(); if(!s.IsSuccess()) { throw s; } } }
CStatus Register_MOM_AddToCluster( PluginRegistrar& in_reg ) { ICENodeDef nodeDef; nodeDef = Application().GetFactory().CreateICENodeDef(L"MOM_AddToCluster",L"MOM_AddToCluster"); CStatus st; st = nodeDef.PutColor(255,188,102); st.AssertSucceeded( ) ; st = nodeDef.PutThreadingModel(XSI::siICENodeSingleThreading); st.AssertSucceeded( ) ; // Add input ports and groups. st = nodeDef.AddPortGroup(ID_G_100); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(ID_IN_base,ID_G_100,siICENodeDataLong,siICENodeStructureSingle,siICENodeContextComponent0D,L"base",L"base",0,0,1000000,ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(ID_IN_id,ID_G_100,siICENodeDataLong,siICENodeStructureSingle,siICENodeContextComponent0D,L"id",L"id",0,0,1000000,ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(ID_IN_cluster,ID_G_100,siICENodeDataLong,siICENodeStructureSingle,siICENodeContextComponent0D,L"cluster",L"cluster",0,0,1000000,ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; // Add output ports. st = nodeDef.AddOutputPort(ID_OUT_base,siICENodeDataLong,siICENodeStructureSingle,siICENodeContextComponent0D,L"outbase",L"outbase",ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; PluginItem nodeItem = in_reg.RegisterICENode(nodeDef); nodeItem.PutCategories(L"Custom ICENode"); return CStatus::OK; }
/* * === FUNCTION ====================================================================== * Name: Push * Description: 以互斥的方式向消息队列中插入一条消息 * ===================================================================================== */ CStatus CUsrDefMsgQueue::Push(CMessage * pMsg) { CEnterCriticalSection ecs(&m_Mutex); if( IsFull() ) { CStatus s = EnlargeQueue(); if(!s.IsSuccess()) return CStatus(-1,0,"failed to Enlarge the queue!"); } m_pQueueSpace[m_iQueueTail] = pMsg; m_iQueueTail = (m_iQueueTail + 1) % m_iTotalRoom; return CStatus(0,0); }
CStatus Register_MOM_GetContactPoints( PluginRegistrar& in_reg ) { ICENodeDef nodeDef; nodeDef = Application().GetFactory().CreateICENodeDef(L"MOM_GetContactPoints",L"MOM_GetContactPoints"); CStatus st; st = nodeDef.PutColor(255,188,102); st.AssertSucceeded( ) ; st = nodeDef.PutThreadingModel(XSI::siICENodeSingleThreading); st.AssertSucceeded( ) ; // Add input ports and groups. st = nodeDef.AddPortGroup(ID_G_100); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(ID_IN_mode,ID_G_100,siICENodeDataLong,siICENodeStructureSingle,siICENodeContextSingleton,L"mode",L"mode",0,0,2,ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(ID_IN_minImpulse_id,ID_G_100,siICENodeDataFloat,siICENodeStructureSingle,siICENodeContextSingleton,L"minImpulse",L"minImpulse",1,0,1000,ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; // Add output ports. st = nodeDef.AddOutputPort(ID_OUT_Contacts,siICENodeDataMatrix33,siICENodeStructureArray,siICENodeContextSingleton,L"Contacts",L"Contacts",ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; PluginItem nodeItem = in_reg.RegisterICENode(nodeDef); nodeItem.PutCategories(L"Custom ICENode"); return CStatus::OK; }
CStatus RegisterToonixMesher( PluginRegistrar& in_reg ) { ICENodeDef nodeDef; nodeDef = Application().GetFactory().CreateICENodeDef(L"ToonixMesher",L"ToonixMesher"); CStatus st; st = nodeDef.PutColor(ToonixNodeR,ToonixNodeG,ToonixNodeB); st.AssertSucceeded( ) ; st = nodeDef.PutThreadingModel(siICENodeSingleThreading); st.AssertSucceeded( ) ; // Add custom types definition. st = nodeDef.DefineCustomType(L"ToonixLine",L"ToonixLine",L"ToonixLine",ToonixLineR,ToonixLineG,ToonixLineB); st.AssertSucceeded( ) ; // Add input ports and groups. st = nodeDef.AddPortGroup(ID_G_100); st.AssertSucceeded( ) ; CStringArray ToonixLineCustomType(1); ToonixLineCustomType[0] = L"ToonixLine"; st = nodeDef.AddInputPort(ID_IN_ToonixLine,ID_G_100,ToonixLineCustomType,siICENodeStructureSingle,siICENodeContextSingleton,L"ToonixLine",L"ToonixLine",ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(ID_IN_Subdiv,ID_G_100,siICENodeDataLong,siICENodeStructureSingle,siICENodeContextSingleton,L"Subdivisions",L"Subdivisions",6); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(ID_IN_ViewPosition,ID_G_100,siICENodeDataVector3,siICENodeStructureSingle,siICENodeContextSingleton,L"ViewPosition",L"ViewPosition"); st.AssertSucceeded( ) ; // Add output ports. st = nodeDef.AddOutputPort(ID_OUT_Vertices,siICENodeDataVector3,siICENodeStructureArray,siICENodeContextSingleton,L"Vertices",L"Vertices",ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; st = nodeDef.AddOutputPort(ID_OUT_Polygons,siICENodeDataLong,siICENodeStructureArray,siICENodeContextSingleton,L"Polygons",L"Polygons",ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; PluginItem nodeItem = in_reg.RegisterICENode(nodeDef); nodeItem.PutCategories(L"Toonix"); return CStatus::OK; }
void OutputVertices( std::ofstream& in_mfw, CGeometryAccessor& in_ga, X3DObject& xobj) { bar.PutStatusText( L"Vertices..." ); // polygon vertex positions CDoubleArray vtxPosArray; CStatus st = in_ga.GetVertexPositions(vtxPosArray); st.AssertSucceeded( L"GetVertexPositions" ); MATH::CTransformation localTransformation = xobj.GetKinematics().GetLocal().GetTransform(); CString string = L"#begin " + CString(in_ga.GetVertexCount()) + L" vertices\n"; in_mfw << string.GetAsciiString(); OutputArrayPositions( in_mfw, vtxPosArray, localTransformation ); string = L"#end " + CString(in_ga.GetVertexCount()) + L" vertices\n"; in_mfw << string.GetAsciiString(); in_mfw << "\n"; if(Get3DCoatParam(L"bExpUV").GetValue()) { // uv props: siClusterPropertyUVType CRefArray uvProps = in_ga.GetUVs(); if(uvProps.GetCount() > 0) { OutputClusterPropertyValues( in_mfw, in_ga, uvProps ); } } if(Get3DCoatParam(L"bExpNorm").GetValue()) { // polygon node normals CFloatArray nodeArray; st = in_ga.GetNodeNormals(nodeArray); st.AssertSucceeded( L"GetNodeNormals" ); //app.LogMessage(L"NormalArray: " + nodeArray.GetAsText()); string = L"#begin " + CString(in_ga.GetNodeCount()) + L" normals\n"; in_mfw << string.GetAsciiString(); OutputArray( in_mfw, nodeArray, 3, L"vn " ); string = L"#end " + CString(in_ga.GetNodeCount()) + L" normals\n"; in_mfw << string.GetAsciiString(); in_mfw << "\n"; } }
CStatus Register_nest_ArrayNode( PluginRegistrar& in_reg ) { ICENodeDef nodeDef; nodeDef = Application().GetFactory().CreateICENodeDef(L"nest_GetPositionArray"); CStatus st; st = nodeDef.PutThreadingModel(XSI::siICENodeSingleThreading); st.AssertSucceeded( ) ; // Add input ports and groups. st = nodeDef.AddPortGroup(Array_ID_G_100); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(Array_ID_IN_Vector,Array_ID_G_100,siICENodeDataVector3,siICENodeStructureSingle,siICENodeContextAny,L"Vector",L"Vector",CVector3f(0,0,0),Array_ID_UNDEF,Array_ID_UNDEF,Array_ID_CTXT_CNS); st.AssertSucceeded( ) ; // Add output ports and groups. st = nodeDef.AddPortGroup(Array_ID_G_300); st.AssertSucceeded( ) ; st = nodeDef.AddOutputPort(Array_ID_OUT_Result,Array_ID_G_300,siICENodeDataVector3,siICENodeStructureArray,siICENodeContextSingleton,L"Array",L"Array",Array_ID_UNDEF,Array_ID_UNDEF,Array_ID_UNDEF); st.AssertSucceeded( ) ; PluginItem nodeItem = in_reg.RegisterICENode(nodeDef); nodeItem.PutCategories(L"Array"); return CStatus::OK; }
CStatus Register_nest_LatticeNode( PluginRegistrar& in_reg ) { ICENodeDef nodeDef; nodeDef = Application().GetFactory().CreateICENodeDef(L"nest_LatticeDeform"); CStatus st; st = nodeDef.PutThreadingModel(XSI::siICENodeMultiThreading); st.AssertSucceeded( ) ; // Add input ports and groups. st = nodeDef.AddPortGroup(Lattice_ID_G_100); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(Lattice_ID_IN_Point,Lattice_ID_G_100,siICENodeDataVector3,siICENodeStructureAny,siICENodeContextAny,L"Point",L"Point",CVector3f(0,0,0),Lattice_ID_UNDEF,Lattice_ID_STRUCT_CNS,Lattice_ID_CTXT_CNS); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(Lattice_ID_IN_Subdivision,Lattice_ID_G_100,siICENodeDataVector3,siICENodeStructureSingle,siICENodeContextSingleton,L"Subdivision",L"Subdivision",CVector3f(1,1,1),Lattice_ID_UNDEF,Lattice_ID_UNDEF,Lattice_ID_UNDEF); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(Lattice_ID_IN_Step,Lattice_ID_G_100,siICENodeDataVector3,siICENodeStructureSingle,siICENodeContextSingleton,L"Step",L"Step",CVector3f(1,1,1),Lattice_ID_UNDEF,Lattice_ID_UNDEF,Lattice_ID_UNDEF); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(Lattice_ID_IN_Reference,Lattice_ID_G_100,siICENodeDataVector3,siICENodeStructureArray,siICENodeContextSingleton,L"References",L"References",CVector3f(1,1,1),Lattice_ID_UNDEF,Lattice_ID_UNDEF,Lattice_ID_UNDEF); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(Lattice_ID_IN_Current,Lattice_ID_G_100,siICENodeDataVector3,siICENodeStructureArray,siICENodeContextSingleton,L"Currents",L"Currents",CVector3f(1,1,1),Lattice_ID_UNDEF,Lattice_ID_UNDEF,Lattice_ID_UNDEF); st.AssertSucceeded( ) ; // Add output ports and groups. st = nodeDef.AddPortGroup(Lattice_ID_G_300); st.AssertSucceeded( ) ; st = nodeDef.AddOutputPort(Lattice_ID_OUT_Result,Lattice_ID_G_300,siICENodeDataVector3,siICENodeStructureAny,siICENodeContextAny,L"Deform",L"Deform",Lattice_ID_UNDEF,Lattice_ID_STRUCT_CNS,Lattice_ID_CTXT_CNS); st.AssertSucceeded( ) ; PluginItem nodeItem = in_reg.RegisterICENode(nodeDef); nodeItem.PutCategories(L"Custom ICENode"); return CStatus::OK; }
CStatus Register_MOM_GetAttributes( PluginRegistrar& in_reg ) { ICENodeDef nodeDef; nodeDef = Application().GetFactory().CreateICENodeDef(L"MOM_GetAttributes",L"MOM_GetAttributes"); CStatus st; st = nodeDef.PutColor(255,188,102); st.AssertSucceeded( ) ; st = nodeDef.PutThreadingModel(XSI::siICENodeSingleThreading); st.AssertSucceeded( ) ; // Add input ports and groups. st = nodeDef.AddPortGroup(ID_G_100); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(ID_IN_base,ID_G_100,siICENodeDataLong,siICENodeStructureSingle,siICENodeContextComponent0D,L"base",L"base",0,0,1000000,ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(ID_IN_id,ID_G_100,siICENodeDataLong,siICENodeStructureSingle,siICENodeContextComponent0D,L"id",L"id",0,0,1000000,ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; // Add output ports. st = nodeDef.AddOutputPort(ID_OUT_position,siICENodeDataVector3,siICENodeStructureSingle,siICENodeContextComponent0D,L"position",L"position",ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; st = nodeDef.AddOutputPort(ID_OUT_orientation,siICENodeDataVector3,siICENodeStructureSingle,siICENodeContextComponent0D,L"orientation",L"orientation",ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; st = nodeDef.AddOutputPort(ID_OUT_linvelocity,siICENodeDataVector3,siICENodeStructureSingle,siICENodeContextComponent0D,L"linvelocity",L"linvelocity",ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; st = nodeDef.AddOutputPort(ID_OUT_angvelocity,siICENodeDataVector3,siICENodeStructureSingle,siICENodeContextComponent0D,L"angvelocity",L"angvelocity",ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; st = nodeDef.AddOutputPort(ID_OUT_state,siICENodeDataLong,siICENodeStructureSingle,siICENodeContextComponent0D,L"state",L"state",ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; st = nodeDef.AddOutputPort(ID_OUT_mass,siICENodeDataFloat,siICENodeStructureSingle,siICENodeContextComponent0D,L"mass",L"mass",ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; st = nodeDef.AddOutputPort(ID_OUT_bounce,siICENodeDataFloat,siICENodeStructureSingle,siICENodeContextComponent0D,L"bounce",L"bounce",ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; st = nodeDef.AddOutputPort(ID_OUT_friction,siICENodeDataFloat,siICENodeStructureSingle,siICENodeContextComponent0D,L"friction",L"friction",ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; st = nodeDef.AddOutputPort(ID_OUT_lindamping,siICENodeDataFloat,siICENodeStructureSingle,siICENodeContextComponent0D,L"lindamping",L"lindamping",ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; st = nodeDef.AddOutputPort(ID_OUT_angdamping,siICENodeDataFloat,siICENodeStructureSingle,siICENodeContextComponent0D,L"angdamping",L"angdamping",ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; st = nodeDef.AddOutputPort(ID_OUT_lintreshold,siICENodeDataFloat,siICENodeStructureSingle,siICENodeContextComponent0D,L"lintreshold",L"lintreshold",ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; st = nodeDef.AddOutputPort(ID_OUT_angtreshold,siICENodeDataFloat,siICENodeStructureSingle,siICENodeContextComponent0D,L"angtreshold",L"angtreshold",ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; PluginItem nodeItem = in_reg.RegisterICENode(nodeDef); nodeItem.PutCategories(L"Custom ICENode"); return CStatus::OK; }
CStatus RegisterToonixGetData( PluginRegistrar& in_reg ) { ICENodeDef nodeDef; nodeDef = Application().GetFactory().CreateICENodeDef(L"ToonixGetData",L"ToonixGetData"); CStatus st; st = nodeDef.PutColor(ToonixNodeR,ToonixNodeG,ToonixNodeB); st.AssertSucceeded( ) ; st = nodeDef.PutThreadingModel(siICENodeSingleThreading); st.AssertSucceeded( ) ; // Add custom types definition. st = nodeDef.DefineCustomType(L"ToonixData",L"ToonixData",L"ToonixData",ToonixDataR,ToonixDataG,ToonixDataB); st.AssertSucceeded( ) ; // Add input ports and groups. st = nodeDef.AddPortGroup(ID_G_100); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(ID_IN_Geometry,ID_G_100,siICENodeDataGeometry,siICENodeStructureSingle,siICENodeContextSingleton,L"Geometry",L"Geometry"); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(ID_IN_CameraCulling,ID_G_100,siICENodeDataBool,siICENodeStructureSingle,siICENodeContextSingleton,L"CameraCulling",L"CameraCulling",false); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(ID_IN_CameraGlobal,ID_G_100,siICENodeDataMatrix44,siICENodeStructureSingle,siICENodeContextSingleton,L"CameraGlobal",L"CameraGlobal"); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(ID_IN_CameraFov,ID_G_100,siICENodeDataFloat,siICENodeStructureSingle,siICENodeContextSingleton,L"CameraFov",L"CameraFov"); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(ID_IN_CameraAspect,ID_G_100,siICENodeDataFloat,siICENodeStructureSingle,siICENodeContextSingleton,L"CameraAspect",L"CameraAspect"); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(ID_IN_CameraNear,ID_G_100,siICENodeDataFloat,siICENodeStructureSingle,siICENodeContextSingleton,L"CameraNear",L"CameraNear",0.0); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(ID_IN_CameraFar,ID_G_100,siICENodeDataFloat,siICENodeStructureSingle,siICENodeContextSingleton,L"CameraFar",L"CameraFar",1000.0); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(ID_IN_UseOctree,ID_G_100,siICENodeDataBool,siICENodeStructureSingle,siICENodeContextSingleton,L"UseOctree",L"UseOctree",false); st.AssertSucceeded( ) ; // Add output ports. CStringArray ToonixDataCustomType(1); ToonixDataCustomType[0] = L"ToonixData"; st = nodeDef.AddOutputPort(ID_OUT_ToonixData,ToonixDataCustomType,siICENodeStructureSingle,siICENodeContextSingleton,L"ToonixData",L"ToonixData",ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; PluginItem nodeItem = in_reg.RegisterICENode(nodeDef); nodeItem.PutCategories(L"Toonix"); return CStatus::OK; }
void OutputPolygonComponents( std::ofstream& in_mfw, CGeometryAccessor& in_ga) { // polygon node indices CLongArray polyNodeIdxArray; CStatus st = in_ga.GetNodeIndices(polyNodeIdxArray); st.AssertSucceeded( L"GetNodeIndices"); //app.LogMessage(L"NodeIdx: " + polyNodeIdxArray.GetAsText()); CLongArray polySizeArray; st = in_ga.GetPolygonVerticesCount(polySizeArray); st.AssertSucceeded( L"GetPolygonVerticesCount" ); //app.LogMessage(L"GetPolygonVerticesCount: " + polySizeArray.GetAsText()); // polygon vertex indices CLongArray polyVtxIdxArray; st = in_ga.GetVertexIndices(polyVtxIdxArray); st.AssertSucceeded( L"GetVertexIndices" ); CString string = L"#begin " + CString(in_ga.GetPolygonCount()) + L" faces\n"; in_mfw << string.GetAsciiString(); // get the material objects used by the mesh CRefArray materials = in_ga.GetMaterials(); CRefArray uvProps = in_ga.GetUVs(); // get the material indices used by each polygon CLongArray pmIndices; in_ga.GetPolygonMaterialIndices(pmIndices); CString prevMat = L""; CString curMat = L""; bar.PutMinimum(0); bar.PutMaximum(polySizeArray.GetCount()); bar.PutStatusText(L"Faces..."); bool bUV = (bool)Get3DCoatParam(L"bExpUV").GetValue(); bool bNrm = (bool)Get3DCoatParam(L"bExpNorm").GetValue(); bool bMtl = (bool)Get3DCoatParam(L"bExpMat").GetValue(); bool bUVCnt = (uvProps.GetCount() > 0)?true:false; CString strVertices; for (LONG i=0, offset=0; i < polySizeArray.GetCount(); i++) { bar.PutValue(i); strVertices = ""; strVertices += CString(polyVtxIdxArray[offset] + 1 + gVprev);// vertices idx[0] if(bUV && bUVCnt) { strVertices += L"/"; //strVertices += CString(polyNodeIdxArray[offset] + 1 + gVtPrev);// texture nodes idx[0] strVertices += CString(g_aNodeIsland[offset] + 1 + gVtPrev);// texture nodes idx[0] if(bNrm) { strVertices += L"/"; strVertices += CString(polyNodeIdxArray[offset] + 1 + gVnPrev);// normal vertices idx[0] } } else if(bNrm) { strVertices += L"//"; strVertices += CString(polyNodeIdxArray[offset] + 1 + gVnPrev);// normal vertices idx[0] } for (LONG j=1; j<polySizeArray[i]; j++) { strVertices += L" "; strVertices += CString(polyVtxIdxArray[offset+j] + 1 + gVprev);// vertices idx[12] if(bUV && bUVCnt) { strVertices += L"/"; //strVertices += CString(polyNodeIdxArray[offset+j] + 1 + gVtPrev);// texture nodes idx[12] strVertices += CString(g_aNodeIsland[offset+j] + 1 + gVtPrev);// texture nodes idx[0] if(bNrm) { strVertices += L"/"; strVertices += CString(polyNodeIdxArray[offset+j] + 1 + gVnPrev);// normal vertices idx[12] } } else if(bNrm) { strVertices += L"//"; strVertices += CString(polyNodeIdxArray[offset+j] + 1 + gVnPrev);// normal vertices idx[12] } } if(bMtl) { Material mat(materials[ pmIndices[i] ]); curMat = mat.GetName(); if(curMat != prevMat) { in_mfw << "usemtl "; in_mfw << curMat.GetAsciiString(); in_mfw << "\n"; prevMat = curMat; } } in_mfw << "f "; in_mfw << strVertices.GetAsciiString(); in_mfw << "\n"; offset += polySizeArray[i]; //bar.Increment(); } string = L"#end " + CString(in_ga.GetPolygonCount()) + L" faces\n"; in_mfw << string.GetAsciiString(); in_mfw << "\n"; }
void OutputClusterPropertyValues( std::ofstream& in_mfw, CGeometryAccessor& in_ga, CRefArray& in_array) { LONG nVals = in_array.GetCount(); double s; ClusterProperty cp(in_array[0]); CFloatArray valueArray; CBitArray flags; cp.GetValues( valueArray, flags ); LONG nValueSize = cp.GetValueSize(); bar.PutValue(0); bar.PutStatusText(L"Optimize UV..."); // polygon node indices CLongArray polyNodeIdxArray; CStatus st = in_ga.GetNodeIndices(polyNodeIdxArray); st.AssertSucceeded( L"GetNodeIndices"); //app.LogMessage(L"polyNodeIdxArray: " + polyNodeIdxArray.GetAsText()); g_aNodeIsland = polyNodeIdxArray; std::vector<float> newValueArray; newValueArray.clear(); for ( LONG j=0; j < polyNodeIdxArray.GetCount(); j++) { float u = valueArray[polyNodeIdxArray[j]*3]; float v = valueArray[polyNodeIdxArray[j]*3+1]; //app.LogMessage(L"u = " + CString(u)+ "; v = "+ CString(v)); LONG nmb = 0; bool bIs = false; for ( ULONG k = 0; k < newValueArray.size(); k += 3 ) { if(fabs(newValueArray.at(k) - u) < 0.000002 && fabs(newValueArray.at(k+1) - v) < 0.000002) { nmb = k/3; bIs = true; break; //app.LogMessage(L"Yarr!: g_aNodeIsland["+ CString(j)+"] = "+ CString(k/3)); } } if(bIs) { g_aNodeIsland[j] = nmb; //app.LogMessage(L"Yarr!: g_aNodeIsland["+ CString(j)+"] = "+ CString(nmb)); } else { newValueArray.push_back(u); newValueArray.push_back(v); newValueArray.push_back(0.0f); g_aNodeIsland[j] = (LONG)(newValueArray.size()/3-1); //app.LogMessage(L"g_aNodeIsland["+ CString(j)+"] = "+ CString(newValueArray.size()/3-1)); } } in_mfw << "#begin "; in_mfw << CString((ULONG)newValueArray.size()/nValueSize).GetAsciiString(); in_mfw << "\n"; bar.PutStatusText(L"Clusters..."); bar.PutMinimum(0); bar.PutMaximum((LONG)newValueArray.size()/nValueSize); for ( ULONG j=0; j < newValueArray.size(); j += nValueSize) { //bar.PutValue(j); s = newValueArray.at(j); CString strValues = FormatNumber(s); for ( LONG k=1; k<nValueSize; k++ ) { s = newValueArray.at(j+k); strValues += L" " + FormatNumber(s); } in_mfw << "vt "; in_mfw << strValues.GetAsciiString(); in_mfw << "\n"; gVt++; bar.Increment(); } CString string = L"#end " + CString((ULONG)newValueArray.size()/nValueSize) + L"\n"; in_mfw << string.GetAsciiString(); in_mfw << "\n"; }
CStatus RegisterToonixLighter( PluginRegistrar& in_reg ) { ICENodeDef nodeDef; nodeDef = Application().GetFactory().CreateICENodeDef(L"ToonixLighter",L"ToonixLighter"); CStatus st; st = nodeDef.PutColor(ToonixNodeR,ToonixNodeG,ToonixNodeB); st.AssertSucceeded( ) ; // Add custom types definition. st = nodeDef.DefineCustomType(L"ToonixData",L"ToonixData",L"ToonixData",ToonixLineR,ToonixLineG,ToonixLineB); st.AssertSucceeded( ) ; // Add input ports and groups. st = nodeDef.AddPortGroup(ID_G_100); st.AssertSucceeded( ) ; CStringArray ToonixLineCustomType(1); ToonixLineCustomType[0] = L"ToonixData"; st = nodeDef.AddInputPort(ID_IN_ToonixData,ID_G_100,ToonixLineCustomType,siICENodeStructureSingle,siICENodeContextSingleton,L"ToonixData",L"ToonixData",ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(ID_IN_ViewPosition,ID_G_100,siICENodeDataVector3,siICENodeStructureSingle,siICENodeContextSingleton,L"ViewPosition",L"ViewPosition"); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(ID_IN_LightPosition,ID_G_100,siICENodeDataVector3,siICENodeStructureAny,siICENodeContextSingleton,L"LightPosition",L"LightPosition"); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(ID_IN_LightBias,ID_G_100,siICENodeDataFloat,siICENodeStructureAny,siICENodeContextSingleton,L"LightBias",L"LightBias",0.0); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(ID_IN_LightDistance,ID_G_100,siICENodeDataFloat,siICENodeStructureAny,siICENodeContextSingleton,L"LightDistance",L"LightDistance",100.0); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(ID_IN_Revert,ID_G_100,siICENodeDataBool,siICENodeStructureSingle,siICENodeContextSingleton,L"Revert",L"Revert",false); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(ID_IN_Push,ID_G_100,siICENodeDataFloat,siICENodeStructureSingle,siICENodeContextSingleton,L"Push",L"Push",0.0); st.AssertSucceeded( ) ; st = nodeDef.AddInputPort(ID_IN_ByTriangle,ID_G_100,siICENodeDataBool,siICENodeStructureSingle,siICENodeContextSingleton,L"ByTriangle",L"ByTriangle",true); st.AssertSucceeded( ) ; // Add output ports. st = nodeDef.AddOutputPort(ID_OUT_Vertices,siICENodeDataVector3,siICENodeStructureArray,siICENodeContextSingleton,L"Vertices",L"Vertices",ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; st = nodeDef.AddOutputPort(ID_OUT_Polygons,siICENodeDataLong,siICENodeStructureArray,siICENodeContextSingleton,L"Polygons",L"Polygons",ID_UNDEF,ID_UNDEF,ID_CTXT_CNS); st.AssertSucceeded( ) ; PluginItem nodeItem = in_reg.RegisterICENode(nodeDef); nodeItem.PutCategories(L"Toonix"); return CStatus::OK; }
CStatus RegisterToonixCurve(PluginRegistrar& in_reg) { ICENodeDef nodeDef; nodeDef = Application().GetFactory().CreateICENodeDef(L"ToonixCurve", L"ToonixCurve"); CStatus st; st = nodeDef.PutColor(ToonixNodeR, ToonixNodeG, ToonixNodeB); st.AssertSucceeded(); st = nodeDef.PutThreadingModel(siICENodeSingleThreading); st.AssertSucceeded(); // Add custom types definition. st = nodeDef.DefineCustomType(L"ToonixLine", L"ToonixLine", L"ToonixLine", ToonixLineR, ToonixLineG, ToonixLineB); st.AssertSucceeded(); // Add input ports and groups. st = nodeDef.AddPortGroup(ID_G_100); st.AssertSucceeded(); st = nodeDef.AddInputPort(ID_IN_Curves, ID_G_100, siICENodeDataGeometry, siICENodeStructureSingle, siICENodeContextSingleton, L"Curves", L"Curves"); st.AssertSucceeded(); st = nodeDef.AddInputPort(ID_IN_ViewPosition, ID_G_100, siICENodeDataVector3, siICENodeStructureAny, siICENodeContextSingleton, L"ViewPoint", L"ViewPoint"); st.AssertSucceeded(); st = nodeDef.AddInputPort(ID_IN_Width, ID_G_100, siICENodeDataFloat, siICENodeStructureSingle, siICENodeContextSingleton, L"Width", L"Width", 0.1); st.AssertSucceeded(); st = nodeDef.AddInputPort(ID_IN_BreakAngle, ID_G_100, siICENodeDataFloat, siICENodeStructureSingle, siICENodeContextSingleton, L"BreakAngle", L"BreakAngle", 90.0); st.AssertSucceeded(); st = nodeDef.AddInputPort(ID_IN_Extend, ID_G_100, siICENodeDataFloat, siICENodeStructureSingle, siICENodeContextSingleton, L"Extend", L"Extend", 0.0); st.AssertSucceeded(); st = nodeDef.AddInputPort(ID_IN_FilterPoints, ID_G_100, siICENodeDataFloat, siICENodeStructureSingle, siICENodeContextSingleton, L"FilterPoints", L"FilterPoints", 0.0); st.AssertSucceeded(); st = nodeDef.AddInputPort(ID_IN_Smooth, ID_G_100, siICENodeDataBool, siICENodeStructureSingle, siICENodeContextSingleton, L"SmoothSilhouette", L"SmoothSilhouette", true); st.AssertSucceeded(); // Add output ports. CStringArray ToonixLineCustomType(1); ToonixLineCustomType[0] = L"ToonixLine"; st = nodeDef.AddOutputPort(ID_OUT_ToonixLine, ToonixLineCustomType, siICENodeStructureSingle, siICENodeContextSingleton, L"ToonixLine", L"ToonixLine", ID_UNDEF, ID_UNDEF, ID_CTXT_CNS); st.AssertSucceeded(); PluginItem nodeItem = in_reg.RegisterICENode(nodeDef); nodeItem.PutCategories(L"Toonix"); return CStatus::OK; }