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

Create an object to control all object

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


Joined: 2018 Feb 01
Online Status: Online
Posts: 23
Post Options Post Options   Quote amlendra Quote  Post ReplyReply Direct Link To This Post Topic: Create an object to control all object
    Posted: 2018 Mar 16 at 7:09am

User Information:

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

---------

I have created a parent object (null object as a parent). I want its child to behave like a single object that means all child move together. I  make parent object as an active object using the below API.

doc->SetActiveObject(ParentObject, SELECTION_ADD);

But when I click on any child object then child object move independently, there any API that disables the child to move independently.
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1754
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Mar 19 at 7:03am
Hi,

just by changing the selection you won't achieve the desired effect. By the way, where do you execute your code?
In order to achieve something like this, one would usually implement a custom tag (TagData plugin) or use the Python Scripting tag, which would then constrain certain parameters (e.g. position) of the host object to the parent of the host object.
Fortunately there's no need to implement this yourself, as there are already a bunch of tags, which can do the trick.
Protection tag, Constraint tag (from Character tags) and Xpresso tag come to my mind. And of course all of these can be created and configured or set up via code, in case you need a scripting solution.



Edited by Andreas Block - 2018 Mar 19 at 7:04am
Cheers,
Andreas
SDK Support Engineer
Back to Top
amlendra View Drop Down
Member
Member


Joined: 2018 Feb 01
Online Status: Online
Posts: 23
Post Options Post Options   Quote amlendra Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Mar 21 at 4:13am
I have tried constraint tag but it also treats like child and parent. If I select the parent, all child move with the parent but when I click child then it moves independently. I want all child and parent tied to each other and no child move independently.
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1754
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Mar 21 at 9:38am
Hm, if I create a Constraint tag in PSR mode on the parent object and set the child as target, I do get exactly what you describe. I can select the parent, move it around and the child follows. And vice versa I can select the child, move it around and the parent follows directly. Only problem I see, is workflow related, as one needs to set the offset between the two inside of the Constraint tag. And of course you need one Constraint tag per child object.

And there's always the option to implement your own custom tag.


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


Joined: 2018 Feb 01
Online Status: Online
Posts: 23
Post Options Post Options   Quote amlendra Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Mar 22 at 4:17am
With PSR parent is also moved with a child but another child is not moved. My requirement is different, suppose, if I have created a null objcet as a parent and it has 4 child cubes. if I select cub1 (child object) and move it, all child and parent should also move with child1. If I select parent (null object), all child should be move with the parent object.

Thank you so much.
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1754
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Mar 22 at 9:52am
As I wrote in my previous post, you'd need one Constraint tag per child.
Cheers,
Andreas
SDK Support Engineer
Back to Top
amlendra View Drop Down
Member
Member


Joined: 2018 Feb 01
Online Status: Online
Posts: 23
Post Options Post Options   Quote amlendra Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Mar 22 at 10:52am
Now when I am using Constraint tag in PSR mode for each child object then all object confine to each other and they behave like not controllable. You said that about the offset but it is not clear to me. Can elaborate it that will be very helpful for me. 

Thanks for quick reply.
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1754
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Mar 23 at 6:35am
Hi,

I'm sorry, but we should get through with this. This doesn't seem development related anymore and that's where we need to put our focus here.

Here's how I set it up:


Please note, I also "found" the "Maintain Original" checkbox, so you do not need to set the offset inside of the Constraint tag. With this configuration I can select any of the three objects, move it around and the other two stick to it as if it's one object.

For more information on the Constraint tag, I recommend our user help.

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


Joined: 2018 Feb 01
Online Status: Online
Posts: 23
Post Options Post Options   Quote amlendra Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Mar 24 at 8:14am
Ok, thanks, Is there any example code related to Constrain tag implementation, that would be helpful for me.
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1754
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Mar 26 at 2:20am
The Py-LookAtCamera example probably comes closest to what you are looking for.
Cheers,
Andreas
SDK Support Engineer
Back to Top
amlendra View Drop Down
Member
Member


Joined: 2018 Feb 01
Online Status: Online
Posts: 23
Post Options Post Options   Quote amlendra Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Mar 26 at 6:46am
Thank you for help, actually, I am asking the API to create constraint tag. Like, suppose want to create a morph tag need to call the below API.

CAPoseMorphTag* poseMorphTag = CAPoseMorphTag::Alloc();
if (poseMorphTag)
{
obj->InsertTag(poseMorphTag);
poseMorphTag->InitMorphs();
}
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1754
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Mar 26 at 8:50am
Sorry, I misunderstood.
    const Int32 ID_CONSTRAINT_TAG = 1019364;
    BaseTag* const constraintTag = obj->MakeTag(ID_CONSTRAINT_TAG);
    if (!constraintTag)
        // handle error
1019364 is the ID of the Character Animation Constraint tag. Unfortunately there's no public symbol defined, so you need to use the numerical value. In order to find the ID (i.e. for another tag), simply drag the tag to the command line of the Console and press return.

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


Joined: 2018 Feb 01
Online Status: Online
Posts: 23
Post Options Post Options   Quote amlendra Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Mar 26 at 10:51am
What I am doing wrong here target is not going to set, Please check the below code.

BaseTag* const constraintTag= static_cast<BaseTag*>(pCameraRig->MakeTag(ID_CONSTRAINT_TAG));
if (!constraintTag)
return false;
constraintTag->SetParameter(ID_CA_CONSTRAINT_TAG_PSR, true, DESCFLAGS_SET_0);
constraintTag->SetParameter(ID_CA_CONSTRAINT_TAG_PSR_MAINTAIN, true, DESCFLAGS_SET_0);
constraintTag->SetParameter(ID_CA_CONSTRAINT_TAG_PSR_LINK, Target, DESCFLAGS_SET_0);


Edited by amlendra - 2018 Mar 26 at 10:53am
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1754
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Mar 27 at 2:05am
Hi,

ID_CA_CONSTRAINT_TAG_PSR_LINK is the wrong ID (although I totally understand, why you expected it to be the right one).
The Constraint tag is special, as it allows for an arbitrary number of for example PSR constraints, which can be added via the Add button. Of course every target field of these needs it's own ID.
ID of the target field of the first PSR constraint is 10001 (simply drag the parameter to the Commandline of the Console to find out). Incremented by ten for every additional constraint. So, if you add a second PSR constraint, the ID of the second target field is 10011.

Cheers,
Andreas
SDK Support Engineer
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.094 seconds.