Create an object to control all object
-
On 16/03/2018 at 07:09, xxxxxxxx wrote:
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.
-
On 19/03/2018 at 07:03, xxxxxxxx wrote:
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. -
On 21/03/2018 at 04:13, xxxxxxxx wrote:
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.
-
On 21/03/2018 at 09:38, xxxxxxxx wrote:
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.
-
On 22/03/2018 at 04:17, xxxxxxxx wrote:
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.
-
On 22/03/2018 at 09:52, xxxxxxxx wrote:
As I wrote in my previous post, you'd need one Constraint tag per child.
-
On 22/03/2018 at 10:52, xxxxxxxx wrote:
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.
-
On 23/03/2018 at 06:35, xxxxxxxx wrote:
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:
![]([URL-REMOVED]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.
[URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.
-
On 24/03/2018 at 08:14, xxxxxxxx wrote:
Ok, thanks, Is there any example code related to Constrain tag implementation, that would be helpful for me.
-
On 26/03/2018 at 02:20, xxxxxxxx wrote:
The Py-LookAtCamera example probably comes closest to what you are looking for.
-
On 26/03/2018 at 06:46, xxxxxxxx wrote:
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();
} -
On 26/03/2018 at 08:50, xxxxxxxx wrote:
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.
-
On 26/03/2018 at 10:51, xxxxxxxx wrote:
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); -
On 27/03/2018 at 02:05, xxxxxxxx wrote:
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.