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
    1. Maxon Developers Forum
    2. JohnTerenece
    3. Best
    J
    • Profile
    • Following 0
    • Followers 0
    • Topics 17
    • Posts 51
    • Best 3
    • Controversial 0
    • Groups 0

    Best posts made by JohnTerenece

    • RE: DESC_PARENT_COLLAPSE Display

      Thanks for the response.

      DESC_GUIOPEN works having the twirl down open by default. What I'm looking for is the ability to modify whether or not it is actively open based on controls by the user. For example if "Angle Threshold" is greater than 90 degrees than have it twirled down, otherwise have it closed.

      John Terenece

      posted in Cinema 4D SDK
      J
      JohnTerenece
    • BaseTake AddTake

      Hi.

      I am currently working on an object plugin that would utilize Takes for a user to be able to quickly iterate through different potential versions of their scene. I've looked through the sdk and the different manuals that are available and I believe I understand the processes required.

      My issue comes in with the amount of time it take Cinema to run my plugin in regards to the creation of the Takes and if this is just the time that it takes to create them.

      I created a simple scene with a hundred objects underneath my plugin. With the code below I create a Take and assign a layer to each of the child objects. For time testing I create an additional 500 Takes using the first Take as the cloneFrom inside AddTake. This isn't a final version of my code just a test example.

      The code is executed on a button press.

      
      			case idRunTakes:
      			{
      				TakeData* takeData = doc->GetTakeData();
      				if (!takeData)
      					return TRUE;
      
      				LayerObject *hideLayer = LayerObject::Alloc();
      
      				const Vector hsv = Vector(1.0, 0, 0);
      				const Vector rgb = HSVToRGB(hsv);
      				newTakeTime = 0;
      				settingTakeTime = 0;
      				LayerData newdata;
      				newdata.color = rgb;
      				newdata.solo = FALSE;
      				newdata.view = FALSE;
      				newdata.render = FALSE;
      				newdata.manager = TRUE;
      				newdata.locked = FALSE;
      				newdata.generators = FALSE;
      				newdata.deformers = FALSE;
      				newdata.expressions = FALSE;
      				newdata.animation = FALSE;
      				newdata.xref = TRUE;
      				hideLayer->SetLayerData(doc, newdata);
      				hideLayer->SetName("Hide Layer"_s);
      
      				GeListHead* layerList = NULL;
      				layerList = doc->GetLayerObjectRoot();
      
      				layerList->InsertLast(hideLayer);
      				maxon::BaseArray<BaseObject*> childObjArray;
      				GatherAllChildObjects(splineObj->GetDown(), childObjArray);
      
      				DescID aliasLinkDId = DescLevel(ID_LAYER_LINK, DA_ALIASLINK, 0);
      				GeData setData;
      				setData.SetBaseList2D((BaseList2D*)hideLayer);
      
      				Float createNewTakesTime = 0;
      				Float timeStart = 0;
      				Float loopTimeStart = GeGetMilliSeconds();
      
      				timeStart = GeGetMilliSeconds(); 
      				BaseTake* newTake = takeData->AddTake(String("Take " + String::IntToString(0)), nullptr, nullptr);
      				if (newTake == nullptr)
      					return TRUE;
      
      				createNewTakesTime = createNewTakesTime + GeGetMilliSeconds() - timeStart;
      				for (Int32 childObjIndex = 0; childObjIndex < childObjArray.GetCount(); childObjIndex++)
      				{
      					BaseOverride* overrideNode = newTake->FindOrAddOverrideParam(takeData, childObjArray[childObjIndex], aliasLinkDId, setData);
      					if (overrideNode == nullptr)
      						return TRUE;
      
      					childObjArray[childObjIndex]->SetLayerObject(hideLayer);
      					overrideNode->UpdateSceneNode(takeData, aliasLinkDId);
      				}
      
      
      				for (Int32 takeIndex = 1; takeIndex < 501; takeIndex++)
      				{
      					timeStart = GeGetMilliSeconds();
      // This is the line taking up a lot of time
      					BaseTake* loopTake = takeData->AddTake(String("Take " + String::IntToString(takeIndex)), nullptr, newTake);
      					if (loopTake == nullptr)
      						return TRUE;
      					createNewTakesTime = createNewTakesTime + GeGetMilliSeconds() - timeStart;
      					
      				}
      				ApplicationOutput("Take time " + String::FloatToString(createNewTakesTime) + "    " + String::FloatToString(GeGetMilliSeconds() - loopTimeStart - createNewTakesTime));
      				break;
      			}
      
      
      // Code for getting all of the child objects
      void TakeCreatorPlugin::GatherAllChildObjects(BaseObject *childObject, maxon::BaseArray<BaseObject*> &objChildOfNullsArray)
      {
      	if (childObject == nullptr)
      		return;
      
      	while (childObject)
      	{
      		objChildOfNullsArray.Append(childObject);
      
      
      		GatherAllChildObjects(childObject->GetDown(), objChildOfNullsArray);
      		childObject = childObject->GetNext();
      	}
      }
      

      Running the code in my test scene gives the following print out "Take time 1920.243 20.232". So most of the time my plugin is running is taken up by adding the takes into the document. Is this just the time that Cinema takes in this kind of circumstance to create the Takes or am I just missing a crucial step,

      I've looked through the manuals in the sdk and tried to follow them.

      I've also tried to create all of the Takes empty and add the Overrides to each one individually which increases the time that step takes which isn't desirable either.

      Any help would be greatly appreciated.

      JohnTerenece

      posted in Cinema 4D SDK c++ r20 sdk
      J
      JohnTerenece
    • Capsules Drag & Drop

      Hi.

      When working on a tag plugin I've recently been encountering a problem when I try to interact with Capsules, my plugin is meant to have parameters dropped onto it from the object it is attached to.

      In my code I can properly receive the drag and drop operation and get the information from the parameter that was dropped onto it, the issue comes in when I try to determine which object the parameter came from.

      When it comes to the Capsules in the object manager my code does not return the results that I am expecting when I try to verify that the parameters were dragged from the object that the tag is on.

      The code below is a stripped down version of my drag and drop code.

      Bool TagExample::Message(GeListNode* node, Int32 type, void* t_data)
      {
      	BaseDocument* doc = node->GetDocument();
      	if (!doc)
      		return TRUE;
      
      	BaseTag* tag = static_cast<BaseTag*> (node);
              if (!tag)
                 return TRUE;
      	if (type == MSG_DRAGANDDROP)
      	{
      
      		DragAndDrop* dnd = static_cast<DragAndDrop*>(t_data);
      		if (!dnd)
      			return TRUE;
      
                   if (dnd->type == DRAGTYPE_DESCID)
      		{
      
      			DescPropertyDragData* dndid = static_cast<DescPropertyDragData*>(dnd->data);
      
      			AutoAlloc<AtomArray> dndidarr;
      			dndid->arr->CopyTo(dndidarr);
      			if (dndidarr->GetCount() <= 0)
      				return TRUE;
      
      			BaseObject* tagObject = tag->GetObject();
      
      			if (!tagObject)
      				return TRUE;
      
      			BaseObject *draggedObject = (BaseObject*)dndidarr->GetIndex(0);
                              if (!draggedObject)
                                   return TRUE;
      			if (draggedObject != tagObject)
      				ApplicationOutput("Do not equal");
      			else
      				ApplicationOutput("The objects equal")
      
      
      
      			return TRUE;
      		}
      	}
      	
      	return true;
      }
      
      

      For some reason when I drag a parameter from a Neutron Cube, that my tag is on, onto my tag I don't get the expected result of the dragged object and the tag object equalling each other. If I do the same procedure on a regular Cube (Ocube) I am able to properly catch that the objects are one and the same. The same behavior is encountered with other Capsules.

      I'm not very familiar with Capsules, is there a specific way that Capsules need to be interacted with in order to achieve the desired results?

      Any help would be greatly appreciated.

      John Terenece

      posted in Cinema 4D SDK 2023 c++ windows
      J
      JohnTerenece