Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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
    • Recent
    • Tags
    • Users
    • Login

    Material directly into Material Manager

    Scheduled Pinned Locked Moved SDK Help
    8 Posts 0 Posters 642 Views
    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.
    • H Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 12/01/2009 at 10:02, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   11 
      Platform:   Windows  ;   
      Language(s) :     C++  ;

      ---------
      Okay, really excited about my getting of my duff and exploring the possibility of developing my own plugin.

      Would like to know how (code, function, etc.) i need to use to get material to show up in the material manager directly from plugin response.

      Thanks!

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 12/01/2009 at 10:52, xxxxxxxx wrote:

        Not sure that I understand the question completely. You create a material using:

        Material* mat = Material::Alloc();
        if (!mat) // return some error
        doc- >InsertMaterial(mat, NULL, FALSE);
        mat->Message(MSG_UPDATE);
        EventAdd();

        To 'attach' the material to a particular scene object, you must have a Texture tag and association:

        TextureTag* ttag = TextureTag::Alloc();
        if (!ttag) // return some error
        op- >InsertTag(ttag);
        // Set projection to relevant projection
        ttag->SetParameter(DescID(TEXTURETAG_PROJECTION),          GeData(TEXTURETAG_PROJECTION_UVW), DESCFLAGS_DONTCHECKMINMAX);
        // Make Material<->TextureTag association
        ttag->SetMaterial(mat);
        ttag->Message(MSG_UPDATE);
        EventAdd();

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 12/01/2009 at 10:55, xxxxxxxx wrote:

          robert,

          you answered my question. thanks.

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 17/01/2009 at 11:43, xxxxxxxx wrote:

            Need some help...tried the code and did below:

            BaseDocument     *doc = GetActiveDocument(); //if(!doc) return FALSE;

            BaseMaterial* mat = BaseMaterial::Alloc(Mbase);
            if (!mat) // return some error
            doc->InsertMaterial(mat, NULL, FALSE);
            mat->Message(MSG_UPDATE);
            EventAdd();

            Unfortunately, don't think that this is correct. When this part of the code is executed in my plugin, the application simply closes. No material, nothing.

            I suspect that I am not declaring mat and doc, etc. as I am supposed to. Help.

            Thanks.

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 17/01/2009 at 12:09, xxxxxxxx wrote:

              You have to allocate a Material (as my code above shows). The BaseMaterial is just the base class for the instantiation you see in the document. That is, it doesn't represent a complete material that C4D can use in the document. InsertMaterial() uses an argument of BaseMaterial to allow it to support various types of material (Material, PluginMaterial for the moment).

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 18/01/2009 at 03:12, xxxxxxxx wrote:

                if (!mat) // return some error

                -> you really have to complete this line otherwise doc->InsertMaterial(...) will only be executed if mat == NULL!

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 18/01/2009 at 07:46, xxxxxxxx wrote:

                  Good point. Yes, I was just making comment as the error response depends upon what the coder is doing. This must actually be 'return FALSE;' or something similar otherwise it reads like this, which isn't good:

                  if (!mat) doc->InsertMaterial(mat, NULL, FALSE);

                  You can go the positive route:

                  if (mat)
                  {
                  doc->InsertMaterial(mat, NULL, FALSE);
                  mat->Message(MSG_UPDATE);
                  EventAdd();
                  }

                  1 Reply Last reply Reply Quote 0
                  • H Offline
                    Helper
                    last edited by

                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                    On 18/01/2009 at 14:02, xxxxxxxx wrote:

                    holy crud! beautiful and i did not even begin to consider that if (!mat) // return some error was the culprit!

                    thank you!

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