How to enable object X-Ray option - C++



  • @r_gigante
    Hi Riccardo, Thank you I will try this.
    Best.



  • @mfersaoui

    Hi Riccardo,

    I try to do this in NodeData::Message. that works on the parent op. But how can I apply the X-Ray option on child object of node. because I want to apply the X-Ray only on some of node child objects.

    Best regards.

    Bool MyObject::Message(GeListNode* node, Int32 type, void* data)
    {
    
    	switch (type)
    	{
    	case (MSG_MENUPREPARE):
    	{
    		BaseObject* const op = static_cast<BaseObject*>(node);
    		
    		// op.GetCache()->GetDown()
    
    		break;
    	}
    	}
    }
    


  • Hi @mfersaoui, assuming you need to access the object pinned under your generator (actually the children), you should use op->GetDown() not op->GetCache()->GetDown().

    Best, Riccardo



  • @r_gigante
    Hi Riccardo,

    I have already tested to use op->GetDown(), but this crashing Cinema 4D.
    See example below:

    Bool MyObject::Message(GeListNode* node, Int32 type, void* data)
    {
    	switch (type)
    	{
    		case (MSG_MENUPREPARE):
    		{
    			BaseObject* const op = static_cast<BaseObject*>(node);
    			GePrint(op->GetDown()->GetName());
    			break;
    		}
    	}
    }
    


  • @mfersaoui before calling any method belonging to a pointer it's highly recommended to check for the pointer validity, so i would rearrange it as

    BaseObject* const op = static_cast<BaseObject*>(node);
    if (op->GetDown())
    	GePrint(op->GetDown()->GetName());
    break;
    

    This might prevent Cinema from crashing.

    Cheers, R



  • @r_gigante I try it but nothing happen, it not detect any child object.



  • @mfersaoui

    Hm, stupid question: Does you object have actually any children? The parameter node passed to Message() is the actual GeListNode sitting in your object manager, representing your plugin instance. If this node has no children, this code does not make any sense.

    Cheers
    zipit



  • @zipit
    My object contain a lot of child object, it is similar to the SDK Greek Temple Generator Example.



  • Well,

    everything you are showing here suggests ottherwise. It sounds like GeListNode::GetDown() returns the null pointer for your node (which would both explain the crashes and the non-execution of your print statement).

    Just to clarify again: node is the representation of your plugin instance in the editor, not the the root node of the object graph you did return in your GVO. If you want to access objects in the ouput of your ObjectData plugin GetCache() was the correct approach. But you also have to check the cache for null pointers, since there is no guarantee that any caches have been build when Message() is being executed.

    Cheers
    zipit



  • Hi @mfersaoui, I thought you were referring to objects pinned under the generator and not children in the cache. In this case checking that the cache is valid before attempting to access any of its methods is mandatory.

    Last but not least, I think we're running out of options here, cause even attempting to use SpecialEventAdd() / MessageData::CoreMessage() doesn't help too much and leads on some cases to unpredictable results.

    Best, Riccardo


Log in to reply