Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > SDK Help
  New Posts New Posts
  FAQ FAQ  Forum Search   Register Register  Login Login

Copy Overrides to other objects

 Post Reply Post Reply
Author
Message
mp5gosu View Drop Down
Member
Member


Joined: 2009 Mar 12
Online Status: Offline
Posts: 76
Post Options Post Options   Quote mp5gosu Quote  Post ReplyReply Direct Link To This Post Topic: Copy Overrides to other objects
    Posted: 2017 Aug 11 at 2:38am

User Information:

Cinema 4D Version:   18 
Platform:   Windows  ;   
Language(s):     C++  ;   

---------

Hi there,

I'm trying to copy some Overrides to another object (they are not of the same type, but base properties are still the same, as they derive from Obase)

The following code actually works to some extent, but not for all takes. 


I'm pretty sure that I made a mistake here. Also, I don't fully understand the sub-takes yet. Just started  with them. :)

Here's some example code:


    inline void TransferTakeOverrides(BaseObject* srcObj, BaseObject* tgtObj, BaseDocument* doc)
    {
        // Get doc's take data
        TakeData* takeData = doc->GetTakeData();

        if (!takeData)
            return;


        // Get main take to start from
        BaseTake* currentTake = takeData->GetMainTake();

        // Set main take active as we need the parameters in "backup state"
        //takeData->SetCurrentTake(takeData->GetMainTake());


        // TODO: Disable Auto-Take / Set Mode to manual

        // Iterate over all other takes
        while (currentTake)
        {

            // skip main take
    // ...

            // Check all overrides for object in current take
            BaseOverride* srcOverride = currentTake->FindOverride(takeData, srcObj);

            while (srcOverride)
            {
                maxon::BaseArray<DescID> srcDescIDs;
                srcOverride->GetAllOverrideDescID(srcDescIDs);

                for (auto descID : srcDescIDs)
                {
                    GeData overrideValue;

                    srcOverride->GetParameter(descID, overrideValue, DESCFLAGS_GET_0);

                    BaseOverride* tgtOverride = currentTake->FindOrAddOverrideParam(takeData, tgtObj, descID, overrideValue);
                    tgtOverride->UpdateSceneNode(takeData, descID);
                }

                 srcOverride = static_cast<BaseOverride*>(GetNextNode(static_cast<GeListNode*>(srcOverride)));
            }

             currentTake = static_cast<BaseTake*>(GetNextNode(static_cast<GeListNode*>(currentTake)));
        }
    }
Back to Top
mp5gosu View Drop Down
Member
Member


Joined: 2009 Mar 12
Online Status: Offline
Posts: 76
Post Options Post Options   Quote mp5gosu Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Aug 13 at 11:39am
Probably can answer this myself.

I simply retrieved the "Backup"-value via FindOverrideCounterPart() and provided this as the backupValue Parameter to FindOrAddOverrideParam().

However, I'm pretty sure there's a more elegant way?
Back to Top
mp5gosu View Drop Down
Member
Member


Joined: 2009 Mar 12
Online Status: Offline
Posts: 76
Post Options Post Options   Quote mp5gosu Quote  Post ReplyReply Direct Link To This Post Posted: Yesterday at 12:46am
Sorry for bumping this thread, but I would be very thankful for some feedback, if this is the right way. :)
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1430
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: Yesterday at 9:15am
Hi,

I'm terribly sorry, when you said, you could answer it yourself, I thought you had a working solution and considered the thread more or less done.

In general it works the way you describe, not sure you would want to skip the Main Take (as the comment in your code suggests), but that's probably a question of the desired final result.

If there's a more elegant way to achieve the same result, to be honest I don't know, yet. I will discuss it on Monday with the rest of the team.

One more note: As BaseOverride and BaseTake are both derived from GeListNode, there's no need for the cast, when passing them to your GetNextNode() as parameters. Might make the code a bit more readable without.

Cheers,
Andreas
SDK Support Engineer
Back to Top
mp5gosu View Drop Down
Member
Member


Joined: 2009 Mar 12
Online Status: Offline
Posts: 76
Post Options Post Options   Quote mp5gosu Quote  Post ReplyReply Direct Link To This Post Posted: Yesterday at 10:30am
Thanks Andreas, looking forward to your findings. 

The cast in the end was from a temporary code. I now use a generic "walker". So, no need to adress it. :)
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.086 seconds.