Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    GetVirtualObjects or GetContour

    Cinema 4D SDK
    c++ sdk r20
    2
    3
    878
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      JohnThomas
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • r_giganteR
        r_gigante
        last edited by

        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

        1 Reply Last reply Reply Quote 3
        • J
          JohnThomas
          last edited by

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

          John Thomas

          1 Reply Last reply Reply Quote 0
          • First post
            Last post