SICALLBACK VDB_Node_VolumeToMesh_BeginEvaluate(ICENodeContext& ctxt)
{
   Application().LogMessage(L"[VDB_Node_VolumeToMesh] BeginEvaluate");

   CValue userData = ctxt.GetUserData();
   VDB_Node_VolumeToMesh* vdbNode;
   if (userData.IsEmpty())
   {
      vdbNode = new VDB_Node_VolumeToMesh;
   }
   else
   {
      vdbNode = (VDB_Node_VolumeToMesh*)(CValue::siPtrType)userData;
   }

   CICEPortState vdbGridPortState(ctxt, kVDBGrid);
   CICEPortState isoPortState(ctxt, kIsoValue);
   CICEPortState adaptPortState(ctxt, kAdaptivity);

   bool vdbGridDirty = vdbGridPortState.IsDirty(CICEPortState::siAnyDirtyState);
   bool isoDirty = isoPortState.IsDirty(CICEPortState::siAnyDirtyState);
   bool adaptDirty = adaptPortState.IsDirty(CICEPortState::siAnyDirtyState);

   vdbGridPortState.ClearState();
   isoPortState.ClearState();
   adaptPortState.ClearState();

   if (vdbGridDirty || isoDirty || adaptDirty)
   {
      vdbNode->Cache(ctxt);
   }

   ctxt.PutUserData((CValue::siPtrType)vdbNode);
   return CStatus::OK;
}
Exemplo n.º 2
0
SICALLBACK ToonixLighter_BeginEvaluate( ICENodeContext& in_ctxt )
{
	TXLight* light = NULL;
	CValue userData = in_ctxt.GetUserData();

	if(userData.IsEmpty())
	{
		// Build a new Light Object
		light = new TXLight();

		// Get the input TXGeometry
		CDataArrayCustomType ToonixData( in_ctxt, ID_IN_ToonixData );

		CDataArrayCustomType::TData* pBufferToonixData;
		ULONG nSizeToonixData;
		ToonixData.GetData( 0,(const CDataArrayCustomType::TData**)&pBufferToonixData, nSizeToonixData );
		TXData* data = (TXData*)pBufferToonixData;
		light->_geom = data->_geom;


		in_ctxt.PutUserData((CValue::siPtrType)light);
	}
	else
	{
		light = (TXLight*)(CValue::siPtrType)in_ctxt.GetUserData( );
	}

	if(GetLighterDirtyState(in_ctxt))
	{
		//Application().LogMessage(L"Toonix Lighter >State Dirty...");
		// Get lights positions used for light detection
		light->_lights.clear();
		
		siICENodeDataType inPortType;
		siICENodeStructureType inPortStruct;
		siICENodeContextType inPortContext;

		in_ctxt.GetPortInfo( ID_IN_LightPosition, inPortType, inPortStruct, inPortContext );
		if ( inPortStruct == XSI::siICENodeStructureSingle )
		{
			//Application().LogMessage(L"ONE Light");
			CDataArrayVector3f lightPointData( in_ctxt, ID_IN_LightPosition );
			light->_lights.push_back(lightPointData[0]);
			light->_nbl = 1;
		}
		else if ( inPortStruct == XSI::siICENodeStructureArray )
		{
			//Application().LogMessage(L"MULTI Lights");
			CDataArray2DVector3f lightPointsData( in_ctxt, ID_IN_LightPosition );
			CDataArray2DVector3f::Accessor lightPointData = lightPointsData[0];
			light->_nbl = lightPointData.GetCount();

			for(LONG l=0;l<light->_nbl;l++)
			{
				light->_lights.push_back(lightPointData[l]);
			}
		}

		light->_bias.resize(light->_nbl);

		in_ctxt.GetPortInfo( ID_IN_LightBias, inPortType, inPortStruct, inPortContext );
		if ( inPortStruct == XSI::siICENodeStructureSingle )
		{
			CDataArrayFloat lightBiasData( in_ctxt, ID_IN_LightBias );
			light->_bias[0] = lightBiasData[0];
		}
		else if ( inPortStruct == XSI::siICENodeStructureArray )
		{
			CDataArray2DFloat lightPointsData( in_ctxt, ID_IN_LightBias );
			CDataArray2DFloat::Accessor lightPointData = lightPointsData[0];
			ULONG nbl = lightPointData.GetCount();

			for(LONG l=0;l<nbl&&l<light->_nbl;l++)
			{
				light->_bias[l] = lightPointData[l];
			}
		}

		light->_distance.resize(light->_nbl);

		in_ctxt.GetPortInfo( ID_IN_LightDistance, inPortType, inPortStruct, inPortContext );
		if ( inPortStruct == XSI::siICENodeStructureSingle )
		{
			CDataArrayFloat lightDistanceData( in_ctxt, ID_IN_LightDistance );
			light->_distance[0] = lightDistanceData[0];
		}
		else if ( inPortStruct == XSI::siICENodeStructureArray )
		{
			CDataArray2DFloat lightDistancesData( in_ctxt, ID_IN_LightDistance );
			CDataArray2DFloat::Accessor lightDistanceData = lightDistancesData[0];
			ULONG nbl = lightDistanceData.GetCount();

			for(LONG l=0;l<nbl&&l<light->_nbl;l++)
			{
				light->_distance[l] = lightDistanceData[l];
			}
		}

		CDataArrayBool revertData( in_ctxt, ID_IN_Revert );
		light->_reverse = revertData[0];
		CDataArrayFloat pushData( in_ctxt, ID_IN_Push );
		light->_push = pushData[0];

		CDataArrayVector3f viewData( in_ctxt, ID_IN_ViewPosition );
		light->_view = viewData[0];

		light->Build();

		in_ctxt.PutUserData((CValue::siPtrType)light);
	}
	return CStatus::OK;
}