Thank you Ferdinand!
I'll continue in backstage with this topic.
V.
Posts made by WTools3D
-
RE: Reading Display scale factor? <Retina,non-Retina>
-
Reading Display scale factor? <Retina,non-Retina>
Hi guys,
When drawing bitmaps on the screen using BaseDraw::DrawTexture(), there is a difference between Retina and non-Retina displays. The scale factor is usually 1.0 for regular displays and 2.0 for Retina displays. When the scale factor is larger, the pixel size of the bitmap needs to increase accordingly.
Is there any way to retrieve this factor directly from the Cinema C++ SDK? I would expect this to be accessible in the BaseDraw or BaseView class.
I hope I’m asking correctly this time.
Thanks,
V.Let me know if you’d like further revisions!
@edit:
--- the size of the bitmap in pixels needs to increase accordingly. ----
just to be more clear. -
RE: Workplane Manipulation Within a ToolData-Derived Plugin
I am sorry for a messy question and thank for answering it anyways.
I'll try to be more precise next time.This solution works fine.
Thank you!
V. -
Workplane Manipulation Within a ToolData-Derived Plugin
Hi,
When the workplane is modified using the ToolData custom plugin, the ortho viewports do not refresh to reflect the new workplane. The modification is done in the ToolData::Mouse callback:// Example: Modify the Workplane Matrix here BaseObject* workplane = doc->GetWorkplaneObject(); if (workplane) { Matrix newMatrix; // Modify the matrix as needed workplane->SetMg(newMatrix); // Notify Cinema 4D that a change has occurred EventAdd(); // Force the viewports to update DrawViews(DRAWFLAGS::DRAWFLAGS_FORCEFULLREDRAW); }
When the workplane is modified using Cinema 4D's native tools, the ortho viewports automatically align to the new workplane.
Any clue on how to achieve this programmatically in a custom plugin tool?
Thanks!
-
RE: ObjectData::GetDimension() ignored?
Now it's more clear.
I assumed behavior of the framing commands on wrong premise.Maybe you could add some further explanation in the documentation where the overwritten bounding data is used in the cinema.
Thank you for your suggestions how to resolve this on my side!
Regards,
Viktor -
RE: ObjectData::GetDimension() ignored?
Hi Ferdinand.
I'll explain each issue separately:First. try to multiply *rad value by 10, in your example.
case 1: *rad = Vector(rady, rado + radx, rado + radx) *10; break;Then when you try to select this object and use 'Frame Selected Elements' function in the viewport.
It will frame to the size of actual geometry not to the overridden size multiplied by 10.
So it ignores the override. -
RE: Animatable control not working (DESC_ANIMATE_ON)
Yes, this condition was the issue!
It was a copy-paste part from some C4D example without deeper thinking.
Now it works as expected also with animations!Regarding the value as a class parameter, it is of course handled for read-write copy.
Our plugins are ported into more applications not just for C4D. Using its own data management so that's why the Get-Set callback are used.Thank you for your quick and useful help, as usual
Regards,
Viktor -
ObjectData::GetDimension() ignored?
Hi guys.
ObjectData::GetDimension() callback is ignored in most of the cases.-
When ObjectData::GetVirtualObjects() callback returns null object, in this case GetDimension() is completely ignored. It is the case when it would be most useful!
-
When ObjectData::GetVirtualObjects() callback returns valid PolygonObject, in this case GetDimension() is again ignored because the plugin is calculating dimension from returned PolygonObject.
Is there some additional settings which needs to be set to force plugin to use GetDimension()?
Thanks!
-
-
Animatable control not working (DESC_ANIMATE_ON)
Hi.
I am struggling to update existing plugins to be animatable.
Plugins are geometry generator derived from ObjectData.
Panel is generated with GetDDescription() callback.
And internal data are handled via GetDParameter() and SetDParameter() callbacks.Below is simplified example.
I need to animate the internal parameter (Float m_value).
It doesn't work when set to DESC_ANIMATE_ON.
Animation of Value parameter appears in panel with the animate diamond icon, but it doesn't switch to red state when clicking on it.#define CTL_VAL_ID 1001 //=========================================================================================================== // class //=========================================================================================================== class TestData : public ObjectData { INSTANCEOF(TestData, ObjectData); // Cinema4D hierarchy public: // create static NodeData* Create() { return NewObjClear(TestData); } //---------------------------------------------------------- // DATA //---------------------------------------------------------- Float m_value = 15; //---------------------------------------------------------- // panel //---------------------------------------------------------- Bool GetDDescription(GeListNode* node, Description* description, DESCFLAGS_DESC& flags) { // validation if (node == nullptr || description == nullptr) return false; // load the description for Obase if (description->LoadDescription(Obase) == false) return false; // load all parameters if (description->GetSingleDescID() == nullptr) { // const DescID cid = DescLevel(CTL_VAL_ID, DTYPE_REAL, 0); //--------------------------------------------------------------------- BaseContainer bc = GetCustomDataTypeDefault(DTYPE_REAL); //--------------------------------------------- bc.SetInt32(DESC_UNIT, e_CtlUnitType::flt); bc.SetString(DESC_NAME, String("Value: ")); bc.SetInt32(DESC_SCALEH, 1); //--------------------------------------------- // animate ON bc.SetInt32(DESC_ANIMATE, DESC_ANIMATE_ON); //--------------------------------------------- // set parameter description->SetParameter(cid, bc, DescLevel(ID_OBJECTPROPERTIES)); } // controls loaded into tool description flags |= DESCFLAGS_DESC::LOADED; // base class return SUPER::GetDDescription(node, description, flags); } //---------------------------------------------------------- Bool GetDParameter(GeListNode* node, const DescID& id, GeData& t_data, DESCFLAGS_GET& flags) override { // shortcuts BaseContainer* bc = static_cast<BaseObject*>(node)->GetDataInstance(); //----------------------------------------- // parameter value to bc (get from bc) if (CTL_VAL_ID == id[0].id) { bc->SetFloat(CTL_VAL_ID, m_value); return true; } //--------------------- // base return SUPER::GetDParameter(node, id, t_data, flags); } //---------------------------------------------------------- Bool SetDParameter(GeListNode* node, const DescID& id, const GeData& t_data, DESCFLAGS_SET& flags) override { //----------------------------------------- // parameter value from bc (set in bc) C4dControls controls(t_data); if (CTL_VAL_ID == id[0].id) { m_value = t_data.GetFloat(); return true; } //----------------------------------------- // base return SUPER::SetDParameter(node, id, t_data, flags); } }; RegisterObjectPlugin(1060016, String("#$44 Test Nurbs"), OBJECT_GENERATOR | OBJECT_USECACHECOLOR, TestData::Create, maxon::String(""), nullptr, 0);
-
RE: R25 - DrawPoint2D,DrawHandle2D not drawing pixel size anymore
I just found out it's a GPU issue.
Pixels are not visible on Intel UHD 630.
Mac M1 well.
GeForce works on 4K monitor but not on HD monitor.So it is a bug.
-
RE: Spline generator drawing and selection override.
I guess it is probably not doable with current api.
I am marking this as solved!I sacrifice the possibility that the generator can be changed to a Spline object with the Cinema Make Editable command.
If the call to NurbsData::GetContour() returns null, no highlighting or geometry will be drawn.
So I can draw everything without any collisions.Only downside of this is that additional command for conversion of this object to a spline object is needed.
Thanks.
-
R25 - DrawPoint2D,DrawHandle2D not drawing pixel size anymore
Hi,
I am not able to draw a pixel in R25 anymore.
DrawPoint2D and DrawHandle2D() with DRAWHANDLE::MINI option doesn't work anymore.
R21,S22,R23,S24 works fine.Is anything changed in R25 drawing api?
I hope it is just an error on my side. But it works in all other versions.
Problem is just in R25.Anybody else having a problem with this?
Thanks!
Viktor -
RE: Spline generator drawing and selection override.
@m_adam said in Spline generator drawing and selection override.:
What do you mean by being part of the generator? If they are children of your generator, and your generator is registered with the OBJECT_INPUT then the cache should be automatically touched and therefor not shown.
No children.
I just want to disable drawing of Spline Object by cinema. Spline object which is returned in GetContour() callback.
But only for the time it is being generated. Until you call Make Editable command which destroy generator and keep just Spline object.So I want to override drawing of that generated Spline object. And draw selected and not selected parts with differnt colors.
Avoid to overdrawing selected parts over existing draw made by cinema which makes "glitches".So in short just need to disable drawing spline object and highlighting.
Sorry for confusion.
Thanks!
V -
RE: Spline generator drawing and selection override.
@m_adam said in Spline generator drawing and selection override.:
Just return true in your draw method during the HIGHLIGHT_PASS, this way nothing will be drawn.
I have tested all returns of DRAWRESULT from NurbsData::Draw() callback. (R21-R25)
In R21 the spline is always white, in R25 it is orange.
No matter if I exit with return SUPER::Draw(op, type, bd, bh) or return any DRAWRESULT result.V.
-
RE: Spline generator drawing and selection override.
I'll try to explain briefly the plugin first and the glitches.
Plugin NurbsData (derived from ObjectData) is complete NURBS generator.
NURBS data are stored in base container as a single data parameter.
Data contains geometry,topology, UV and selection.
Selection depends on Cinema mode (points,<segments-edges>, <curves-surfaces- polygons>)Object has an internal switch for curves or surfaces.
When works in curves mode the NurbsData::GetContour() returns the Spline object.
When works in surfaces mode the NurbsData::GetVirtualObjects() returns the Polygon object.It is all implemented and works, only makes drawing glitches depends on Cinema version.
Problematic is when drawing NURBS selection. (specially curve segments), it is not matching the highlighted curves, It is just 1-2 pixels random difference depend on viewport settings.
But it is a huge problem on large scale floor-plans with thousands of lines, because the visibility is messy then.If still not clear, I can show it. (call with a sceen-share)
Thanks!
Viktor -
Spline generator drawing and selection override.
I have implemented NURBS object as a spline and polygon generator.
I am trying to have the same visual look from R21 to R25.
There are several visual glitches and problems specially when drawing additional geometry.
So the best way would be to override the drawing of everything.I would need to completely disable drawing of spline geometry(cache) and highlighting of selected object.
-
Is there a way to disable drawing spline cache object while it is part of generator object?
But it have to be visible after it is converted to spline object. -
Is there a way how to completely disable object highlighting per specified plugin?
In R21 it was optional :
I am not able to find this in R25 and not even in SDK.
I have already missed the deadline because of struggling with this.
Any advice would help.
thanks! -
-
RE: ToolData::GetDDescription() redundant call, why?
Thank you guys for quick reply.
But I was probably not clear enough with the question.I do understated the concept of setting panel description via GetDDescription() callback.
I already did the checks for whether it is request for full description of just single id.
As it is listed in the example below (it is member function of C4dControls class from previous snippetvoid C4dControls::AddIntChoice(int id, int gid, const String& name, const BaseContainer& items) { const DescID cid = DescLevel(id, DTYPE_LONG, 0); //--------------------------------------------------------------------- if (ex_descr && (!ex_singleid || cid.IsPartOf(*ex_singleid, nullptr)) ) { BaseContainer bc = GetCustomDataTypeDefault(DTYPE_LONG); //--------------------------------------------- bc.SetInt32 (DESC_CUSTOMGUI, ID_QUICKTABSRADIO_GADGET); bc.SetString(DESC_NAME, name); bc.SetInt32 (DESC_SCALEH, 1); // animate OFF bc.SetInt32 (DESC_ANIMATE, DESC_ANIMATE_OFF); //--------------------------------------------- bc.SetContainer(DESC_CYCLE, items); //--------------------------------------------- ex_descr->SetParameter(cid, bc, DescLevel(gid)); } }
But it is still calling to rewrite each control description several times after any event in GUI.
What confuses me the most, is that each series of calls is with the different pointer to description (Description* description)
For example there are five different pointers to description when ToolData::GetDDescription() is executed for the same event. (after mouse click into attribute manager)Is this the way how it really works?
There are more versions of description for the same panel, and all of them have to be initialized repeatedly after each event?Thanks!
Viktor -
ToolData::GetDDescription() redundant call, why?
Hi,
I have a questions about behavior of ToolData class member function GetDDescription().
I can't find any example and I don't understand why Cinema is calling this function several times after each user event in GUI.Below is the code of overridden member function.
I am filling description with controls every time now. (function LoadControls())Bool LwCadToolData::GetDDescription (BaseDocument* doc, BaseContainer& data, Description* description, DESCFLAGS_DESC& flags) { // validation if (description == nullptr) return false; ApplicationOutput("GetDDescription flags: @", flags); // initialize controls LoadControls(C4dControls(description, description->GetSingleDescID())); // controls loaded into tool description flags |= DESCFLAGS_DESC::LOADED; //--------------------- // base return SUPER::GetDDescription(doc, data, description, flags); }
Problem is that after each mouse event , this function is executed several times, always a different description pointer.
Below is the list of calls after a single click.GetDDescription flags: NONE
GetDDescription flags: NONE
GetDDescription flags: NONE
GetDDescription flags: NONE
GetDDescription flags: RESOLVEMULTIPLEDATA|MAPTAGS
GetDDescription flags: NONECould you please give me a hint, how to optimize this properly?
Optimal way is to fill description only once.
Is it necessary fill it every time the GetDDescription() function is executed?Thanks!
-
RE: BaseDraw::DrawHUDText() - setting color ?
Works like a charm!
It's much more flexible than I hoped;)Thanks a lot!
-
BaseDraw::DrawHUDText() - setting color ?
I am trying to draw colored text with BaseDraw::DrawHUDText().
Using BaseDraw::SetPen() before, has no effect.Is there any way to draw text with custom color using DrawHUDText funcrtion ?
Thanks!