Ofcourse in the code example i mean to set the pin data and links in their correct subcontainer, and not in the AttributeContainer
Posts made by ECHekman
-
RE: SubContainers and Symbol ranges
-
RE: SubContainers and Symbol ranges
Thank you for the detailed answer.
I think I have settled on how to store data then that makes it the most future proof for us.
A quick mockup of our setup would be something like this then:// OurShaderNode.h enum OurShaderNode { OUR_NODE_TYPE = 1001, OUR_NODE_PINS, OUR_NODE_PIN_LINKS, OUR_NODE_ATTRIBUTES, OUR_NODE_OFFSET = 10000, // Pin Ids. These map to IDs from our application OUR_NODE_PIN_SCALE = OUR_NODE_OFFSET + 1; // Maps to our internal ID PIN_SCALE which is 1, same for the others OUR_NODE_PIN_ALBEDO = OUR_NODE_OFFSET + 2; OUR_NODE_PIN_SPECULAR = OUR_NODE_OFFSET + 3; OUR_NODE_PIN_NORMAL = OUR_NODE_OFFSET + 4; OUR_NODE_PIN_FRAME = OUR_NODE_OFFSET + 245; // Attribute. These map to IDs from our application OUR_NODE_ATTRIBUTE_VALUE = OUR_NODE_OFFSET + 1; OUR_NODE_ATTRIBUTE_COUNT = OUR_NODE_OFFSET + 2; OUR_NODE_ATTRIBUTE_SCALE = OUR_NODE_OFFSET + 3; OUR_NODE_ATTRIBUTE_FRAME = OUR_NODE_OFFSET + 4; OUR_NODE_ATTRIBUTE_FILENAME = OUR_NODE_OFFSET + 3456; } // pluginOurShaderNode.cpp // These two functions will map c4d IDs to our internal Ids int ConvertToOurID(OurShaderNode c4dId) { return c4dId - OUR_NODE_OFFSET; } int ConvertToC4D(int ourId) { return ourId + OUR_NODE_OFFSET; } // pluginOurShaderNode is derived from the base class ShaderData Bool pluginOurShaderNode::Init(GeListNode* node, Bool isCloneInit) { BaseContainer *data = ((BaseShader*)node)->GetDataInstance(); // The subcontainers use overlapping numbers for their IDs, but this setup gives us the biggest range of id numbers BaseContainer PinContainer; // Contains all pin data AttributeContainer.SetVector(OUR_NODE_PIN_ALBEDO, Vector(1,0,0)); BaseContainer PinLinkContainer; // Containes links to other shadernodes. AttributeContainer.SetLink(OUR_NODE_PIN_ALBEDO, nullptr); BaseContainer AttributeContainer; // Contains all attribute data AttributeContainer.SetInt32(OUR_NODE_ATTRIBUTE_VALUE); data->SetContainer(OUR_NODE_PINS, PinContainer); data->SetContainer(OUR_NODE_PIN_LINKS, PinLinkContainer); data->SetContainer(OUR_NODE_ATTRIBUTES, AttributeContainer); }
-
SubContainers and Symbol ranges
I am looking into mapping symbols from my plugin application to symbols in c4d.
This is for ShaderData/TagData/ObjectData derived plugins.However im running into two issues. Some of these symbols clash with existing symbols in c4d.
1 I have read that the first 1000 are reserved. And that I shouldnt go above 1 million?
2. My other related issue is that I would like to reuse symbols in the same NodeData plugin.My solution idea was to use sub-containers to avoid both of these symbol clashes.
However I cannot find in the sdk if the same symbol restrictions apply for subcontainers.
Can I just put in any ID in a subcontainer? Or are there limitations for those aswel?Additionally, do links work the same as with normal BaseContainers?
-
How to use String::Split
I feel a bit silly asking this. But im trying to use the split function on maxon::string. And nothing seems to work.
Like array is a value receiver? but im getting loads of strange template errors.String cat = ninfo->mCategory; maxon::Array<const String&> parts; cat.Split(String("/"), true, parts); if(parts.GetCount()) info(parts[0]);
-
RE: Get and Set DTYPE_COLORA/DTYPE_VECTOR4D on basecontainer or gedata
DTYPE_VECTOR4 and DTYPE_COLORA are not maxon::data types internally in c4d.
When I get or set them as maxon::data like your example code the GeData changes to a DTYPE_DATA instead
Additionally the existing 4d colorpicker GUI for DTYPE_COLORA will override the maxon::data type and reset it to whatever DTYPE_COLORA is internally. -
RE: Data, DataTypes, Python and GUI
Ok thanks for the help Ferdinand. I will take the road of least resistance and just build on top of float64 vectors
-
RE: Get and Set DTYPE_COLORA/DTYPE_VECTOR4D on basecontainer or gedata
I made this separate thread specifically because of the clear singular question rule i have been told to follow. And this is a different question from the question on custom data types.
-
RE: Get and Set DTYPE_COLORA/DTYPE_VECTOR4D on basecontainer or gedata
This is a different question from:
https://developers.maxon.net/forum/topic/15823/data-datatypes-python-and-gui/6?_=1732092863717If you are referring to the same post i wrote on the backstage forum the suggestion i got there does not work:
const ColorA* color = data.GetCustomDataType<ColorA>();
^^ this does not work
I am asking how to use existing types here. And not new/custom ones
Specifically the DTYPE_COLORA and DTYPE_VECTOR4 and not the regular types DTYPE_COLOR and DTYPE_VECTOR -
Get and Set DTYPE_COLORA/DTYPE_VECTOR4D on basecontainer or gedata
How do I get and set Vector4 and ColorA to the basecontainer/gedata?
I have tried pretty much every possible function and method but I dont seem to be able to use Vec4/Color4.I have managed to get it via unsafe c-style casting:
GeData ge(DTYPE_COLORA, DEFAULTVALUETYPE::DEFAULTVALUE); // Create // Get const CustomDataType* customPtr = ge.GetCustomDataTypeI(DTYPE_COLORA); maxon::ColorA color = *(maxon::ColorA*)customPtr; // Set color = maxon::ColorA(0.5, 0.1, 0.6, 0.7); CustomDataType* customPtrDst = (CustomDataType*)&color; ge.SetCustomDataTypeI(DTYPE_COLORA, *customPtrDst); // Get again to check if it worked const CustomDataType* customPtr2 = ge.GetCustomDataTypeI(DTYPE_COLORA); maxon::ColorA color2 = *(maxon::ColorA*)customPtr2;
But this is basically undefined behavior
-
RE: Data, DataTypes, Python and GUI
Just to clear something up that you wrote: maxon::IntVector32 is not a new template specialization.
And are you sure maxon::IntVector32 is not wrapped in python. It is in the python sdk?
https://developers.maxon.net/docs/py/2025_0_0/modules/maxon_generated/datatypes/vec_col_mat/maxon.IntVector32.html?highlight=intvector32#module-maxon.IntVector32
Or am I missing something here?I have the UI working for the pre-existing maxon::IntVector32 data type. The only problem with this method is that when i animate it, it does not interpolate between multiple keyframes - it just jumps from one to the other.
The problem im trying to solve is that Octane supports these other types (int3 float4 long2 etc). But from what I now learned, and reading your answers, I will either need to chose between:
- Use Custom Data Type - dropping python support
- Use maxon::IntVector32 - dropping keyframe interpolation support
- Cast everything from Vector4d to int vectors and in64 vectors - possible data loss and clunkyness by having to set int values with floats in python
Btw, I recently got backstage access, would it be better to ask these questions there?
-
RE: Data, DataTypes, Python and GUI
I have two problems with using maxon::data route
For instance I have tried to do int32_3 by using maxon::IntVector32. Which is maxon::Vec3<maxon::Int32, 1>;
- However this type does not seem to support interpolating between keyframes
- I cant seem to dynamically create GUI for it
For example: This is how i generate UI for the bool checkbox:
const DescID cid = CreateDescID(DescLevel(guiID, DTYPE_BOOL, 0)); BaseContainer bc = GetCustomDataTypeDefault(DTYPE_BOOL); bc.SetInt32(DESC_CUSTOMGUI, CUSTOMGUI_BOOL); bc.SetString(DESC_NAME, name); bc.SetBool(DESC_SCALEH, scaleH); bc.SetBool(DESC_FITH, fitH); bc.SetInt32(DESC_ANIMATE, anim); description->SetParameter(cid, bc, CreateDescID(DescLevel(groupID)));
How would i do the same for maxon data types?
-
Data, DataTypes, Python and GUI
For the project I am working I would like to add new data types to the BaseContainer/GeData for a ShaderData and I'm wondering what the best method for storing, displaying, animating and python interop.
The types I want to add are the following vectors:
Int32_2, Int32_3, Int32_4 Float_2 Float_4 Int64_2
I have tried 3 methods so far:
Method 1: CustomDataType from the sdk example:
I implemented this for Int32_3. This one is the most promising so far as it gives me the greatest level of control over the data and GUI.
Drawbacks:- I am not sure how to set/get this data from python or other plugins?
- Would much prefer to have proper integrated types like maxon::IntVector32
Method 2: maxon::data types (IntVector32)
I tried IntVector32 and Vector4d for Int32_t and Float_4. The data can be set with the SetMaxonData function or SetData on GeData. This method seems to the most integrated, and these types also exist in python?
Drawbacks:- There seems to be no GUI for these types?
- They are not interpolated between keyframes
- I dont know how to properly add new GUI for these types as they do not have DTYPE_ value?
Method 3: DTYPE_VECTOR4 / DTYPE_COLORA / DTYPE_VECTOR2
These have GUI.
Drawbacks:- I cannot set or get the data from the BaseContainer. There is no GetVector4. And im not sure how to extract this data from the GeData.
- There are no int32 or int64 versions of these
Hopefully you can help me out on navigating this issue.
I would much prefer to use official data types, but im happy to implement my own custom data types. However I am not sure how these properly interop with python and other plugins. -
RE: Natvis settings not working?
Thanks Ferdinand. Putting those lines in the projectdefinitions.txt of the solution was the... solution
-
Natvis settings not working?
Im trying to get the natvis files to work, and I added the settings from the documentation.
However this does not seem to do anything. Is there something im missing?AdditionalSolutionFiles=\ ..\..\frameworks\core.framework\project\typeviewer\msvc\maxon.natvis;\ ..\..\frameworks\cinema.framework\project\typeviewer\msvc\c4dapi.natvis
I have gotten it to work by manually adding the natvis to the visual studio document folder, but i would like to automate it.
-
RE: Global static classes?
Could you explain the issue with this though? Is C4D doing strange stuff with c++ classes derived from ShaderData?
I wanted to avoid having to recreate the PluginNodeInfoStruct every time an instance is created by placing it in ::Init. Would the following be fine?
virtual PluginNodeInfoStruct& PluginNodeInfo() const override { static PluginNodeInfoStruct sPluginNodeInfo { SOME_ID, SOME_UI_ID, }; return sPluginNodeInfo; };
-
Global static classes?
In the documentation i read the following:
Do not use global static classes of complex types. Elementary data types (Int32, Float, Char etc.) are allowed, see Primitive Data Types Manual (Cinema API).
Im not sure what this exactly means. But im trying to create a settings class as a static member to ShaderData nodes that contains information about the derived class that the base class needs to know.
struct InfoStruct { public: UInt32 SomeID; Int32 SomeUI; }; PluginNodeBase : public ShaderData { INSTANCEOF(PluginNodeBase, ShaderData) public: virtual PluginNodeInfoStruct& PluginNodeInfo() const = 0; } class SomeClass: public PluginNodeBase { INSTANCEOF(VolumeMedium, PluginNodeBase) public: // Set plugin node info inline static PluginNodeInfoStruct sPluginNodeInfo { SOME_ID, SOME_UI_ID, }; virtual PluginNodeInfoStruct& PluginNodeInfo() const override { return sPluginNodeInfo; }; }
Would this be fine? or is there a reason Icould not use static in this way?
-
RE: Compiling material nodegraph to shaders
Thank you for your reply.
I take it this also means its not possible to manually convert node ourselves? -
Compiling material nodegraph to shaders
I am looking into supporting cinema4d nodegraph materials into our pathtracer plugin.
I looked through the documentation, but found very little about the material node system on the technical side.Would it be possible to compile or translate material nodegraphs into GLSL shaders?
-
BaseLink crash and tracking PolygonObjects/InstanceObjects in cache
Im trying to dynamically track all the objects in the active BaseDocument, including the cached InstanceObjects and BaseObjects that are created by cloner objects.
I have a function that scrapes the BaseDocument contents and keeps a list of all the relevant objects as BaseLinks. This list is updated every time there is a change in the BaseDocument.This is working very well with most scenes, and I can track all the InstanceObjects and (cached/deformed)PolygonObjects in the scene.
However, I found that in certain scenes, BaseLink::GetLink will crash on PolygonObjects taken from some cloner cache's. I suspect it has something to do with mograph cache?I also found that pointers to these PolygonObjects that crash GetLink, will work initially, but then suddenly stop working and return 0 on GetType.
Am i doing something wrong here? Or did i find a bug? Are there better ways to do what im trying to do?
-
Tracking object lifetime in a scene
Im working on a rendering plugin, and im looking for the best way to track the lifetime of various objects in the scene.
Currently im looking at Meshes (PolygonObject), Materials and Textures.What would be the best way to check if objects have been removed and added to a scene?
According to the documentation I should not use pointers, but baselinks. But I cannot compare baselinks with eachother.
I have also read that the various ID functions are not always unique for all objects.