Navigation

    • Register
    • Login
    • Search
    1. Home
    2. JohnTerenece
    J

    JohnTerenece

    @JohnTerenece

    2
    Reputation
    37
    Posts
    24
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    • Profile
    • More
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups
    JohnTerenece Follow

    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 •
    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 •

    Latest posts made by JohnTerenece

    RE: FieldList Enable Clamping

    Thanks, that was exactly what I was looking for.

    John Terenece

    posted in Cinema 4D SDK •
    RE: FieldList Enable Clamping

    @Manuel
    Thanks for the reply.

    What I'm trying to change is this control.

    Clamp.png

    John Terenece

    posted in Cinema 4D SDK •
    FieldList Enable Clamping

    Hi.

    I'm working on a plugin that utilizes a FieldList control that I am creating using custom data type CUSTOMDATATYPE_FIELDLIST. My issue comes in with the "Enable/Disable Value Clamping" control and not being able to change it using code.

    I've looked through the sdk in relation to the FieldList entry and couldn't find anything that refrences it. The closest thing I could find was the FIELDLIST_FLAGS::CLAMPOUTPUT which not suprisingly had no effect on the control when used with SetFlags.

    This is my code for creating my FieldList control.

    	DescID DescFieldGroup = DescLevel(idFieldGroup, DTYPE_GROUP, 0);
    	if (!singleid || DescFieldGroup.IsPartOf(*singleid, NULL))
    	{
    		BaseContainer bc;
    		bc = GetCustomDataTypeDefault(DTYPE_GROUP);
    		bc.SetInt32(DESC_COLUMNS, 1);
    		bc.SetBool(DESC_SCALEH, TRUE);
    		if (!description->SetParameter(DescFieldGroup, bc, idMainGroup))
    			return TRUE;
    	}
    	cid = DescLevel(idGrowField, CUSTOMDATATYPE_FIELDLIST, 0);
    	if (!singleid || cid.IsPartOf(*singleid, NULL))
    	{
    
    		BaseContainer bc;
    		bc = GetCustomDataTypeDefault(CUSTOMDATATYPE_FIELDLIST);
    		bc.SetBool(DESC_FIELDLIST_NOCOLOR, TRUE);
    		
    		bc.SetBool(DESC_FIELDLIST_NODIRECTION, TRUE);
    		bc.SetBool(DESC_FIELDLIST_NOROTATION, TRUE);
    
    		if (!description->SetParameter(cid, bc, DescFieldGroup))
    			return TRUE;
    	}
    

    Is it possible to change the control via code or can it only be changed manually by a user.

    Any help would be greatly appreciated.

    John Terenece

    posted in Cinema 4D SDK •
    RE: GeDialog Failing To Open

    Thanks for the response. This seems to have solved the problem.

    John Terenece

    posted in Cinema 4D SDK •
    RE: GeDialog Failing To Open

    Release mode.

    posted in Cinema 4D SDK •
    GeDialog Failing To Open

    Hello.

    I am encountering a problem when I insert my object plugin into a scene in R26, save the document and then reopen the file. When I click the button to open the GeDialog Cinema immediately crashes on me.

    I stripped down the code for my GeDialog to the bare minimum that was still similar to the examples in the sdk and the problem is still occurring.

    #include "c4d_general.h"
    #include "c4d.h"
    #include "c4d_symbols.h"
    #include "main.h"
    
    #define ID_RUNDIALOG 1059364
    enum Controls
    {
    	idSendMessageLinkObject = 1000,
    	idLinkedObject,
    	idGatherChildren,
    
    	idOverallScrollGroup = 2000,
    	idGroupToFlush,
    	idControls,
    
    	idLaunchDialogWindow = 1500,
    	idBasicControlGroup,
    };
    
    class ObjDialog : public GeDialog
    {
    public:
    	ObjDialog() {}
    	virtual ~ObjDialog() {}
    	virtual Bool CreateLayout();
    	virtual Bool InitValues();
    	virtual void DestroyWindow();
    	virtual Bool Command(Int32 id, const BaseContainer& msg);
    	virtual Int32 Message(const BaseContainer& msg, BaseContainer& result);
    };
    
    
    Bool ObjDialog::CreateLayout()
    {
    	Bool res = GeDialog::CreateLayout();
    
    	SetTitle("Dialog Window"_s);
    
    	ScrollGroupBegin(idOverallScrollGroup, BFH_SCALEFIT | BFV_SCALEFIT, SCROLLGROUP_VERT | SCROLLGROUP_HORIZ);
    	{
    		GroupBegin(idGroupToFlush, BFH_SCALEFIT | BFV_SCALEFIT, 1, 0, String(), 0);
    		{
    			GroupBegin(idControls, BFH_SCALEFIT | BFV_SCALEFIT, 5, 0, String(), 0);
    			{
    			}
    			GroupEnd();
    		}
    		GroupEnd();
    	}
    	GroupEnd();
    
    	return res;
    }
    
    Bool ObjDialog::InitValues()
    {
    	if (!GeDialog::InitValues())
    		return false;
    	return true;
    }
    
    void ObjDialog::DestroyWindow() {}
    
    Bool ObjDialog::Command(Int32 id, const BaseContainer& msg)
    {
    	return true;
    }
    
    
    Int32 ObjDialog::Message(const BaseContainer& msg, BaseContainer& result)
    {
    	return GeDialog::Message(msg, result);
    }
    
    
    class RunDialog : public ObjectData
    {
    public:
    	virtual Bool Init(GeListNode* node);
    
    	virtual BaseObject* GetVirtualObjects(BaseObject* op, HierarchyHelp* hh);
    	virtual Bool Message(GeListNode* node, Int32 type, void* t_data);
    	virtual Bool GetDDescription(GeListNode* node, Description* description, DESCFLAGS_DESC& flags);
    
    	static NodeData* Alloc() { return NewObjClear(RunDialog); }
    
    	maxon::BaseArray<BaseObject*> objArrayToCheckForMatch;
    private:
    	ObjDialog dlg;
    };
    
    
    Bool RunDialog::GetDDescription(GeListNode *node, Description *description, DESCFLAGS_DESC &flags)
    {
    	BaseContainer *dataInstance;
    	const DescID *singleid;
    	if (!description->LoadDescription(node->GetType()))
    	{
    	}
    
    	dataInstance = ((BaseList2D*)node)->GetDataInstance(); // Get the container for the tag
    	if (!dataInstance)
    		return FALSE;
    	singleid = description->GetSingleDescID();
    	DescID cid;
    
    
    	DescID DescHelperControlGroup = DescLevel(idBasicControlGroup, DTYPE_GROUP, 0);
    	if (!singleid || DescHelperControlGroup.IsPartOf(*singleid, NULL))
    	{
    		BaseContainer bc;
    		bc = GetCustomDataTypeDefault(DTYPE_GROUP);
    		bc.SetString(DESC_NAME, "Run Dialog"_s);
    		bc.SetInt32(DESC_COLUMNS, 1);
    		bc.SetInt32(DESC_DEFAULT, 1);
    		bc.SetBool(DESC_SCALEH, TRUE);
    
    		if (!description->SetParameter(DescHelperControlGroup, bc, DescLevel(ID_RUNDIALOG)))
    			return TRUE;
    	}
    
    
    	cid = DescLevel(idLaunchDialogWindow, DTYPE_BUTTON, 0);
    	if (!singleid || cid.IsPartOf(*singleid, NULL))  //  important to check for speedup c4d!
    	{
    		BaseContainer bc;
    		bc = GetCustomDataTypeDefault(DTYPE_BUTTON);
    		bc.SetInt32(DESC_CUSTOMGUI, CUSTOMGUI_BUTTON);
    		bc.SetString(DESC_NAME, "Open Dialog"_s);
    		if (!description->SetParameter(cid, bc, DescHelperControlGroup))
    			return TRUE;
    	}
    
    
    
    
    	flags |= DESCFLAGS_DESC::LOADED;
    
    	return TRUE;
    }
    
    Bool RunDialog::Init(GeListNode* node)
    {
    	return true;
    }
    
    
    Bool RunDialog::Message(GeListNode* node, Int32 type, void* t_data)
    {
    	if (type == MSG_DESCRIPTION_COMMAND)
    	{
    		DescriptionCommand *dc = (DescriptionCommand*)t_data;
    		if (!dc)
    			return TRUE;
    		Int32 ID = Int32(dc->_descId[0].id);
    		BaseDocument* doc = node->GetDocument();
    		if (!doc)
    			return TRUE;
    
    		switch (ID)
    		{
    			// Problem occurs here
    			case idLaunchDialogWindow:
    			{
    				if (dlg.IsOpen() == false)
    					dlg.Open(DLG_TYPE::ASYNC, ID_RUNDIALOG, -1, -1, 300, 200, 0, OPENDIALOGFLAGS::IGNORELAYOUT);
    				break;
    			}
    		}
    	}
    
    	return true;
    }
    
    BaseObject* RunDialog::GetVirtualObjects(BaseObject* op, HierarchyHelp* hh)
    {
    	BaseObject *nullReturn = BaseObject::Alloc(Onull);
    
    	return nullReturn;
    }
    
    Bool RegisterRunDialog()
    {
    
    	return RegisterObjectPlugin(ID_RUNDIALOG, "Run Dialog"_s, OBJECT_GENERATOR | OBJECT_INPUT, RunDialog::Alloc, "ORunDialog"_s, AutoBitmap("atom.tif"_s), 0);
    }
    
    

    I've used this same code in R20 and R25 and haven't had a single issue with opening the GeDialog, I only started encountering the problem in R26.

    Looking at the examples in the sdk that deal with GeDialogs they are all opened via a CommandData plugin and the GeDialog manual specifically mentions that GeDialog based windows are typically owned by a CommandData plugin.

    Is it now a requirement to use a CommandData plugin to open a GeDialog?

    Any help would be greatly appreciated.

    John Terenece

    posted in Cinema 4D SDK •
    RE: Limit On the Number Of Takes

    @m_magalhaes

    Thanks for the response.

    Might be able to use your idea as potential solution.

    John Terenece

    posted in Cinema 4D SDK •
    RE: Limit On the Number Of Takes

    Just to clarify, I know that adding more objects and such to a document in Cinema will make it use up more memory and cause it to lag when it gets bad enough. My issue is that Cinema is running fine with a certain number of takes and then I add one more and it immediately crashes.

    posted in Cinema 4D SDK •
    Limit On the Number Of Takes

    Hi.

    I am running into an issue when creating a large number of takes where Cinema is crashing on me, and this problem seems unrelated to the actual creation of the takes.

    Using my code I try to create a large number of takes, around 1400, with parameters overridden for objects in the scene, at some point during the creation process Cinema will crash. I recreated the case inside of CInema without my code by creating a take with one overridden object and then copy and pasting it, when I get to around 1400 takes in the document Cinema crashes on me.

    Is this just a limitation of Cinema when it comes to takes and that it can't handle that many inside of one document? Having multiple documents with a thousand takes in them open at the same time does not cause Cinema to crash.

    Any help would be greatly appreciated.

    John Terenece

    posted in Cinema 4D SDK •
    RE: GeDialog Update

    So I was right I was missing something incredibly simple. Thanks for the response Manuel, it works perfectly now.

    posted in Cinema 4D SDK •