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. Aaron
    3. Posts
    A
    • Profile
    • Following 0
    • Followers 0
    • Topics 7
    • Posts 23
    • Best 1
    • Controversial 0
    • Groups 0

    Posts made by Aaron

    • Motion Blur, ExecutePasses in VideoPostData

      Hi colleagues,
      What's the way to get several steps of motion blur transformation matrices for BaseObjects of the BaseDocument within the single frame that is on the render process of VideoPostData?
      I usually do

      1. ClonedDoc = BaseDoc->GetClone(COPYFLAGS_0, NULL);
      2. Then do execute of passes and collection of matrix positions
        for(time steps) {
        ClonedDoc->SetTime();
        ClonedDoc->ExecutePasses()
        }
      3. Then use matrix positions to calculate motion blur
        The observations tell that GetClone and ExecutePasses are expensive calls.
        Is there any way to get subframe transformation matrices?
        I have seen some get motion data, but it seems to be for Physical render.

      Thanks,
      Aaron


      I think there is a bug in the following situation:

      1. There is a recent featured with object Liquid Mesh in the document of VideoPostData pipeline
      2. When we just collect the scene elements the polygon object cache (POC) returned by Liquid Mesh->GetCache() contains the polygons to build this nice liquid object mesh
      3. When we want to add Motion Blur and call document->ExecutePasses(...) for some time then this POC is flushed and has no polygons or vertices, so it's not collected and can't be rendered
      4. Even if we don't call ExecutePasses() but add Sub-Frame Motion Blur effect in Cinema Settings then POC is also flushed the same way as in #3.

      Bake to Alembic for Liquid Mesh helps but still...

      posted in Cinema 4D SDK c++ 2025
      A
      Aaron
    • RE: BaseBitmap.Init("somefile.exr") crashes with multiple std::thread

      @ferdinand said in BaseBitmap.Init("somefile.exr") crashes with multiple std::thread:

      omp #parallel

      Sorry for late reply, I am not advocating for std::threads, I understand your design explanation.
      The omp #parallel thing is OpenMP directive to launch parallel threads. It's an old but simple method.
      Actually I have made a solution by exploiting Cinema way of launching threads and it works fine.
      However, I hope it would be good to make BaseBitmap->Init a thread safe and independent call from other C4D threads and resources.
      I will collect an example for you with exr images soon.

      Cheers,
      Aaron

      posted in Cinema 4D SDK
      A
      Aaron
    • RE: BaseBitmap.Init("somefile.exr") crashes with multiple std::thread

      Few more experiments:

      1. When I replace std::thread to omp #parallel for the result is the same - crash
      2. When I launch a std::thread and from inside it I launch several C4D threads each with BaseBitmap.Init() then it works just fine.

      I honestly think that BaseBitmap.Init() should be local and independent function from any other C4D infrastructure.

      posted in Cinema 4D SDK
      A
      Aaron
    • RE: BaseBitmap.Init("somefile.exr") crashes with multiple std::thread

      Ferdinand, thank you very much for detailed explanation!
      Sure I will integrate the most recent threading mechanisms. The files that we tried to read in parallel are different. I guess there is something with OpenEXR reader that you probably wrap around. Other file types reading in parallel is working just fine.
      The whole code workflow is more complex because it involves several libraries and plugin system communication.
      So I have reduced the issue just that short and it's reproduces always.
      My goal was indeed to read in parallel, it's not very fast to read and decode sequentially when you deal with 1000s of files.
      However for some file types we can probably serialize the access.
      Best regards,
      Aaron

      posted in Cinema 4D SDK
      A
      Aaron
    • RE: BaseBitmap.Init("somefile.exr") crashes with multiple std::thread

      Ferdinand, thank you for very quick reply.
      Of course I know about this sample code with leaks, it was just to keep the message very short.
      It's working code for jpg, png, bmp - it scales well on multi-core, reads data correctly, never had a problem with that formats. But not for exr, no any exr in multi-threaded environment.
      Actually all exr files fail, you may check. I have catched it on 8K exr files.
      It was IMAGERESULT::MISC_ERROR (-6) error code that I mentioned for situation of parallel BaseBitmap.Init() without using mutex to access this function.

      Sure I have to use C4D threads to do this kind of optimization. Thank you very much!
      I was just hoping to figure out maybe some special image IO mutex lock may help.

      Best regards,
      Aaron

      posted in Cinema 4D SDK
      A
      Aaron
    • BaseBitmap.Init("somefile.exr") crashes with multiple std::thread

      Hello colleagues,
      I have found an issue that when we want to read several .EXR files in parallel using multiple std::threads they crash on BaseBitmap.Init(file.EXR).
      It doesn't crash when we read exr sequentially without threads. It doesn't crash when we use C4DThread instead, however some bitmaps are not read correctly and return err codes. However to perform correctly we need to use C4DThread and mutex lock/unlock before/after bitmap.Init(exr)
      You may test this short code. I have tested 4 different 8K .exr files. It reproduces the crash always. Maybe I miss something, some threading parameter for this case.

      void bthread(int id)
      {
      	String st[4] = {"S:\\test\\img1_8K.exr",
      					"S:\\test\\img2_8K.exr",
      					"S:\\test\\img3_8K.exr",
      					"S:\\test\\img4_8K.exr" };
      
      	Filename fn(st[id]);
      
      	BaseBitmap* bitmapE = BaseBitmap::Alloc();
      	IMAGERESULT res = bitmapE->Init(fn);
      	printf("\n [file %s result %d size %d x %d]", st[id].GetCStringCopy(), res, bitmapE->GetBw(), bitmapE->GetBh());
      	BaseBitmap::Free(bitmapE);
      }
      
      void test_exr()
      {
      	std::thread* t[4];
      	for (int i = 0; i < 4; i++)
      	{
      		t[i] = new std::thread(bthread, i);
      		t[i]->detach();
      	}
      }
      
      posted in Cinema 4D SDK 2025 c++ windows
      A
      Aaron
    • RE: How to access thinkin particles data channels correctly?

      Solved, it works this way:

      Vector v(0.0);
      tps->GetData(pid, channel, &v, ID_GV_VALUE_TYPE_VECTOR);
      
      posted in Cinema 4D SDK
      A
      Aaron
    • How to access thinkin particles data channels correctly?

      Hi All,
      There is thinking particles system and it has few named channels such as here:

       Float   [chan   5] DataChannelType    19 DataChannelName mass(Real)
       Float   [chan   6] DataChannelType    19 DataChannelName oldP(Real)
       Float   [chan   8] DataChannelType    19 DataChannelName pscale(Real)
       Float   [chan 10] DataChannelType    19 DataChannelName spriteuv(Real)
       Vector [chan   1] DataChannelType    23 DataChannelName Cd(Vector)
      

      I get channel info using tps->DataChannelType(chan) and etc.
      19 is DTYPE_REAL, 23 is DTYPE_VECTOR
      But when I try to read the channel value per particle then it returns false and doesn't read the values. For example this request returns false:

        TP_MasterSystem* tps;
        Vector fval(0.0);
        tps->GetData(pid, channel, &fval, DTYPE_VECTOR);
      // nothing is written in fval. I also tried to use GeData, but it didn't help
      

      Other particle data such as tps->Transform(...), tps->Color(...), tps->Age(...) is returning relevant results.

      Please, can someone show me a valid example of correct TP data channel access?

      Cheers

      posted in Cinema 4D SDK c++ 2024
      A
      Aaron
    • RE: MoGraph color tag access

      Hi @m_adam Maxime,
      I don't understand yet, how to use the Python example within a C++ environment. Can't find C++ functions such as this:

      md = c4d.modules.mograph.GeGetMoData(op)
      ... 
      offset = op[c4d.MG_LINEAR_OFFSET]
      

      I have noticed that for example the Text object type has MoData->GetCount() with N elements corresponding to the number of letters. And then the cache object of Text has N children each with Motion Graphics Color Tag [tag->GetType() = 1018768].
      I thought there could be a way to read this color tag somehow.

      But if no then during scene traversal there is a way to inherit the array of the Text object with MoData->GetCount() > 0 and then count each descendant object with Motion Graphics Color Tag with increasing id to reference to the correct element of MoData->GetArray()

      Same extraction can be done for Voronoi Fracture and other MoGraph objects with some checks.

      posted in Cinema 4D SDK
      A
      Aaron
    • RE: Save Project with Assets not updating the maxon::Url of node textures in R26 and 2023

      Hi @Manuel I have checked the new update 2023.2.0 and the feature works just fine with custom bitmaps without any change from my side. Congrats with a very quick bugfix! This is very cool! 🙂
      Also it's great the half-year version 2023.2 doesn't need 3rd party plugin rebuild and recompile as in S24, S26. Thanks for this!

      posted in Cinema 4D SDK
      A
      Aaron
    • MoGraph color tag access

      Hello colleagues,
      Ho can we access the color of MoGraph data for each object where Motion Graphics Color Tag [with tag->GetType() = 1018768] is assigned?

      For example there is Text object or Voronoi Fracture object which have these tags for generated child objects.

      Thanks in advance!

      posted in Cinema 4D SDK c++
      A
      Aaron
    • RE: Save Project with Assets not updating the maxon::Url of node textures in R26 and 2023

      Hi @Manuel, thanks a lot! It's very good that things work in 2023.1.2, I will check it. Also there was an issue in S26.000
      Btw I am on beta forum too and I can duplicate a topic there.
      Will return to the topic on Tuesday because need to travel 🙂

      posted in Cinema 4D SDK
      A
      Aaron
    • RE: Save Project with Assets not updating the maxon::Url of node textures in R26 and 2023

      @Deyan thank you, in our case nodespace nodes (e.g. bitmap) didn't require too much message handling. All I did was making node layout in Resource Editor, and then describing this layout data access inside the code and the parse it. Message handling was used in the previous material system using BaseMaterial / BaseShader concept.

      @Manuel thanks for investigation! This is my screenshot from bitmap layout in resource editor. Url type is used. But I have opened it in R25. Still can't open resource editor in 2023 even removing the option you mentioned.
      cinema_3rdparty_bitmap_asset_issue.jpg

      How can I include Import Data node for tests? Btw, it can be easy to test it with CentiLeo plugin, I mean the nodespace & bitmap. No registration is required https://centileo.com/download/

      posted in Cinema 4D SDK
      A
      Aaron
    • RE: Save Project with Assets not updating the maxon::Url of node textures in R26 and 2023

      @Manuel Hi Manuel, I am Kirill from CentiLeo project. I have written a question here because it seems there is more life on the public forum and the nodes api is now public.
      The issue performs as I have described. So there is a custom bitmap that is described with ImageTupple for Cinema inside

      MAXON_METHOD maxon::Result<void> NodeSpaceExample::Init(maxon::DataDictionary spaceData)
      {
      ..
      }
      

      Then when I try to save "Project with Assets" I get the new project file where the filenames defined as maxon::Url in the resource editor are not updated to local file paths such as tex/texturename.jpg and they remain old in attrib manager. But in fact the files are copied to the specified project folder together with images. Only manual change can fix them. Also the asset inspector doesn't change the filenames.
      The node structure was defined in the resource editor of the older Cinema R21.
      The issue is on R26 and still on R2023. It works well for older Cinema versions.
      I thought there is some new property appeared on resource editor that prevents from Url modification (something like ownership or perfmission) or maybe some little API feature that intervene into the process.
      The other issue is that I still can't open resource editor in R2023. Cinema was launched with a cmd line

      "C:\Program Files\Maxon Cinema 4D 2023\Cinema 4D.exe" g_applicationRepositoryWritable=true g_descriptionEditorDeveloperMode=true
      

      edit resource not working.jpg

      posted in Cinema 4D SDK
      A
      Aaron
    • Save Project with Assets not updating the maxon::Url of node textures in R26 and 2023

      Hello colleagues,
      There is a custom node space and there is a bitmap node with a the filepath of the type Url. The image drag&drop to nodes area is working from windows expolrer, everyting his working except for "Save project with Assets".
      So the bitmap files are copied to the specified location, but the file strings are not updated in the custom bitmap node. None of them.
      This code links C4D logic with the custom file path as described in the C++ API:

      spaceData.Set(maxon::nodes::NODESPACE::IMAGENODEASSETID, mynodes::NODE::BITMAP::GetId()) iferr_return;
      	maxon::nodes::NODESPACE::ImageNodePortTuple imageTuple; 
      	imageTuple.first = maxon::NodePath::Create(maxon::ToSingletonBlock<maxon::InternedId>(mynodes::NODE::BITMAP::RESULT)) iferr_return;
      	imageTuple.second = maxon::NodePath::Create(maxon::ToSingletonBlock<maxon::InternedId>(mynodes::NODE::BITMAP::FILENAME)) iferr_return;
      	imageTuple.third = maxon::NodePath::Create(maxon::ToSingletonBlock<maxon::InternedId>(mynodes::NODE::BITMAP::FRAME_START)) iferr_return;
      	imageTuple.fourth = maxon::NodePath::Create(maxon::ToSingletonBlock<maxon::InternedId>(mynodes::NODE::BITMAP::FRAME_END)) iferr_return;
      	spaceData.Set(maxon::nodes::NODESPACE::IMAGENODEPORTS, std::move(imageTuple)) iferr_return; 
      

      Also the Asset Inspector relink doesn't actually change the file strings on the node.
      This functionality is not working in R26 and 2023.
      But it is working in R21-R25 nicely! The bitmap related code is the same.
      I also can't open the Resource Editor in 2023.1.3. I am using the options to launch the Cinema:

      "C:\Program Files\Maxon Cinema 4D 2023\Cinema 4D.exe" g_applicationRepositoryWritable=true g_developerNodeEditorFunctions=true g_descriptionEditorDeveloperMode=true
      

      Then click Resource Edit in the node editor and nothing happens.
      Cinema version is 2023.1.3. The compiled SDK for node space was 2023.0.0.

      Please help me to fix this

      posted in Cinema 4D SDK 2023 c++ maxon api
      A
      Aaron
    • RE: C4D hangs when call BaseShader->Edit() for the message MSG_DESCRIPTION_CHECKUPDATE

      Ok, I will. Just need to remove all not-needed things

      posted in Cinema 4D SDK
      A
      Aaron
    • C4D hangs when call BaseShader->Edit() for the message MSG_DESCRIPTION_CHECKUPDATE

      Hello!
      There is a problem. There is a bitmap button in material description. After click it sends a message MSG_DESCRIPTION_CHECKUPDATE. Inside this message there is a call to base shader -> Edit(). I just want to show the properties of shader in attribute manager instead of material properties. And C4D R20 demo hangs.
      If the button is not bitmap (but a usual one) then it sends a message MSG_DESCRIPTION_COMMAND which calls base shader->Edit() and we get no any hang.
      One thing: if there is no GetDDescription there is no hang after Edit() call. But GetDDescription is used to make bitmap buttons and other staff. Even basic GetDDescription with checks for null input vars and just LoadDescription is enough to make the hang.
      StopAllThreads() befor calling shader->Edit doesn't help to avoid the problem.

      posted in Cinema 4D SDK r20 c++ windows
      A
      Aaron
    • RE: Node-Based Materials

      My guess is there will be no any SDK for long time because it didn't happen yet for the first R20 release. This looks a bit strange. But this is the choice of Maxon. Would be interesting just to know what Maxon developers think about it.

      posted in Cinema 4D SDK
      A
      Aaron
    • RE: Cinema 4D R20.059 bug with many RegisterShaderPlugin() calls

      Hi Riccardo, I think the issue is solved because there is no any issue. Some not good methods of software distribution just confused us.
      Btw, what benefits different parameters of SetPluginPriority() give to us? For example the xdll has several plugins like materials, shader, tags and renderer. Even some icons with plugin ids. What priority is better to use in this case? I see https://developers.maxon.net/docs/cpp/2023_2/page_manual_module_functions.html
      For example, what is C4DPL_INIT_PRIORITY_ADVANCEDRENDER:

      1. Does it give higher thread priority during some PV rendering task?
      2. Or does it just load the plugin before other renderers and give the chance to lock system resources before others?
      posted in Cinema 4D SDK
      A
      Aaron
    • RE: Node-Based Materials

      Hi, Maxime! Also another node-related question: will you ever make the SDK access for custom material and shader plugins operating inside node based GUI?

      posted in Cinema 4D SDK
      A
      Aaron