GetVirtualObjects or GetContour



  • Hello,

    I am creating an ObjectData plugin that will return a spline from GetContour. The points of this spline are based on the point values taken from a Matrix Mograph. Currently I am getting these points inside of GetVirtualObjects using this code.

    BaseObject* DoubleCircleData::GetVirtualObjects(BaseObject* op, HierarchyHelp* hh)
    {
    	BaseObject *matrixObj= op->GetDown();
    	if (!matrixObj)
    		return nullptr;
    	BaseObject* clone = op->GetHierarchyClone(hh, matrixObj, HIERARCHYCLONEFLAGS::ASPOLY, nullptr, nullptr);
    	if (!clone)
    		return nullptr;
    	Int32 ptCount = ToPoly(clone)->GetPointCount();
    	const Vector* padr = ToPoint(clone)->GetPointR();
            return nullptr;
    
    }
    

    This code works properly and I am able to get the points I need from the Matrix. I am looking for an alternative method for getting the points that does not require it being run inside of GetVirtualObjects. For the purposes of my plugin I need to return a SplineObject and I am not sure if using GetVirtualObjects for this purpose is appropriate.

    Any help would be greatly appreciated.

    John Thomas



  • Hi John, thanks for reaching out us.

    With regard to your question, the proper way to return a SplineObject is indeed to implement the ObjectData::GetContour()method and register the plugin by specifying the OBJECT_ISSPLINE flag.

    With regard instead to retrieving the points taken from a mograph matrix, you can actually consider to access the BaseObject's cache as described here. Last but myabe mostly important, accessing the MoGraph generators' items data should be done via the MoData class.

    An example of accessing such data in the context of an ObjectData::GetContour method could look like:

    ...	
    	// check for a child pinned under this generator
    	BaseObject *child = op->GetDown();
    	if (!child)
    		return nullptr;
    	
    	// check for the type of the child - in this case a MoGraph Matrix
    	if (child->GetType() != 1018545) // check for Mograph Matrix
    		return nullptr;
    	
    	// access the tag containing the MoData on a MoGraph object and check it
    	BaseTag *tmp = child->GetTag(ID_MOTAGDATA);
    	if (!tmp)
    		return nullptr;
    	
    	// populate the GetMoDataMessage instance by sending a MSG_GET_MODATA
    	GetMoDataMessage modataMsg;
    	if (!tmp->Message(MSG_GET_MODATA, &modataMsg))
    		return nullptr;
    	
    	// access the MoData from the returned GetMoDataMessage and check its validity
    	MoData *matrixData = modataMsg.modata;
    	if (!matrixData)
    		return nullptr;
    	
    	// retrieve the number of Matrix items as well as the array containing the matrix for each of them
    	Int32 matrixItemsCnt = matrixData->GetCount();
    	Matrix* itemsMtxArray = static_cast<Matrix*>(matrixData->GetArray(MODATA_MATRIX));
    
    ...
    

    Best, Riccardo



  • Thank you for your answer. That was exactly what I was looking for.

    John Thomas


Log in to reply