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

    'CreateNewTexture': identifier not found

    Cinema 4D SDK
    windows c++ 2024
    2
    5
    657
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • sasha_janvierS
      sasha_janvier
      last edited by

      Hey guys,

      I have the following code:

      #include "c4d.h"
      
      ...
      
      Filename path = "C:\\path\\uv-islands-matte-01.png";
      BaseContainer settings;
      settings.SetInt32(TEXTURE_WIDTH, 1024);
      settings.SetInt32(TEXTURE_HEIGHT, 1024);
      
      PaintTexture* paintTexture = CreateNewTexture(path, settings);
      if (!paintTexture) {
          ApplicationOutput("Failed to create a new paint texture.");
          return TRUE;
      }
      

      Upon building my solution in Visual Studio 2019, I get the following error:

      Error C3861 'CreateNewTexture': identifier not found
      

      Shouldn't CreateNewTexture() be already available, given that I am including c4d.h? I've tried brute-forcing the import by adding #include <c4d_painter.h> at the top of my script, but this obviously didn't help.

      Additional context:

      I am trying to create a "matte" bitmap image of my currently selected Object, where the UV islands of my Object are pure white, while the background (i.e. non-UV islands) is pure black.

      This should be doable by programmatically by creating a new texture with a black background, then selecting all polygons in Polygon Mode by using CallCommand / SendModelingCommand, then executing the command "Fill Polygons" with the white foreground color and then finally saving the results. I'm not sure if this is all entirely possible with the current SDK, but I can compromise on some parts.

      Either way, I can't go too far with the plan outlined above, given how CreateNewTexture() is not working to begin with.

      Any insight / guidance would be very much appreciated. Here's hoping that this is just some silly oversight on my part.

      Thank you!

      Sasha Janvier

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @sasha_janvier
        last edited by ferdinand

        Hello @sasha_janvier,

        thank you for reaching out to us. PaintTexture::CreateNewTexture is a static method of PaintTexture, so your statement should look like this:

        PaintTexture* const paintTexture = PaintTexture::CreateNewTexture(path, settings);
        

        ℹ You should avoid umbrella includes such as #include "c4d.h". For once they can significantly increase your compile times (not that much of a problem in the SDK context), but they also obfuscate your dependencies and what you are doing in a file.

        Cheers,
        Ferdinand

        PS: I am still on the alpha/bitmap thing, we did not find a solution on Friday.

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • sasha_janvierS
          sasha_janvier
          last edited by

          Ah! Thank you so very much once again, @ferdinand! I was right about it being a silly oversight on my part. Much appreciated!

          PS: I am still on the alpha/bitmap thing, we did not find a solution on Friday.

          Thank you for the update! I was considering messaging you about this.

          For now, I am trying to move forward as much as possible without the alpha channel. Here's hoping that you guys can solve this eventually 🤞

          Thanks again and please, if possible, keep me in the loop!

          Sasha Janvier

          1 Reply Last reply Reply Quote 0
          • sasha_janvierS
            sasha_janvier
            last edited by

            It seems like executing the code I provided in my first message (along with your revision) in Cinema 4D triggers a breakpoint error in Visual Studio 2019.

            @ferdinand Are you by any chance able to reproduce this?

            I've tried using SetParameter() instead of SetInt32() with the right nomenclature/format, and it only lead to more errors.

            I hope this isn't yet another oversight on my part. I've spent quite some time digging through the forum and looking at examples in the GitHub repo (not the CreateNewTexture() as there are no examples of that, but examples of setting parameters). So far, no success.

            Thank you once again.

            Sasha Janvier

            1 Reply Last reply Reply Quote 0
            • sasha_janvierS
              sasha_janvier
              last edited by

              Edit: Nevermind. Once again, a silly oversight. I hadn't provided enough TEXTURE-type settings to the BaseContainer, such as TEXTURE_FILEFORMAT.

              Apologies!

              Sasha Janvier

              1 Reply Last reply Reply Quote 0
              • First post
                Last post