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

    using standard material in MaterialData

    Scheduled Pinned Locked Moved SDK Help
    3 Posts 0 Posters 249 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 02/03/2009 at 11:03, xxxxxxxx wrote:

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

      ---------
      Hi all.

      This is probably a naive question, but is there a possibility to use a standard (to the user invisible) material inside a MaterialData plugin?

      I'm working on an exporter to an external renderer which has a material system that can be translated more or less into the C4D material system. To avoid having to write the area light sampling for different BxDFs I wanted to use the C4D internal standard material instead, to do the actual shading.

      The problem is, that I don't know how to setup the C4D Material instance, so that it's returning a different colour than black. I tried it with setting the parameters directly in it's container and by setting the description values (see below the code snippets). Nothing worked.

      Does someone have an idea, what I'm doing wrong here?

      Thanks,
      Marcus

      Here is some example/test code:

      Class declaration in testmaterial.h:

      > \> class TestMaterial : public MaterialData \> { \> INSTANCEOF(TestMaterial,MaterialData) \> \> \> public: \> \> static NodeData\* alloc(void); \> static Bool registerPlugin(void); \> \> virtual Bool Init(GeListNode \*node); \> virtual void Free(GeListNode \*node); \> virtual LONG InitRender(PluginMaterial \*mat, InitRenderStruct \*irs); \> virtual void FreeRender(PluginMaterial \*mat); \> virtual void CalcSurface(PluginMaterial \*mat, VolumeData \*vd); \> \> \> private: \> \> Material \*mC4DMaterial; \> }; \> \>

      Implementation in testmaterial.cpp:

      > \> NodeData\* TestMaterial::alloc(void) \> { \> return gNew TestMaterial; \> } \> \> \> Bool TestMaterial::registerPlugin(void) \> { \> return RegisterMaterialPlugin(1000001, \>                                 "Test Material", \>                                 0, \>                                 TestMaterial::alloc, \>                                 String(), \>                                 0); \> } \> \> \> Bool TestMaterial::Init(GeListNode \*node) \> { \> mC4DMaterial = NULL; \> return TRUE; \> } \> \> \> void TestMaterial::Free(GeListNode \*node) \> { \> if (mC4DMaterial) Material::Free(mC4DMaterial); \> } \> \> \> LONG TestMaterial::InitRender(PluginMaterial   \*mat, \>                              InitRenderStruct \*irs) \> { \> // create a new standard material \> mC4DMaterial = Material::Alloc(); \> if (!mC4DMaterial) { \>     return LOAD_NOMEM; \> } \> \> // setup standard material \> mC4DMaterial->SetChannelState(CHANNEL_COLOR, TRUE); \> mC4DMaterial->SetParameter(DescID(MATERIAL_COLOR_COLOR), Vector(1.0, 0.0, 0.0), 0); \> mC4DMaterial->SetParameter(DescID(MATERIAL_COLOR_BRIGHTNESS), 1.0, 0); \> mC4DMaterial->Message(MSG_UPDATE); \> \> return LOAD_OK; \> } \> \> \> void TestMaterial::FreeRender(PluginMaterial \*mat) \> { \> if (mC4DMaterial) { \>     Material::Free(mC4DMaterial); \> } \> } \> \> \> void TestMaterial::CalcSurface(PluginMaterial \*mat, \>                                VolumeData     \*volumeData) \> { \> // test: set result colour to green \> volumeData->col.x = 0.0; \> volumeData->col.y = 1.0; \> volumeData->col.z = 0.0; \> if (mC4DMaterial->GetInfo() & SHADER_INITCALCULATION) { \>     mC4DMaterial->InitCalculation(volumeData, INIT_SURFACE); \> } \> // this function call makes it black again -> something is going on here \> mC4DMaterial->CalcSurface(volumeData); \> } \> \>

      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 03/03/2009 at 03:10, xxxxxxxx wrote:

        Basically the same problem as this thread:

        sample material

        So far I don't get it to work either.

        cheers,
        Matthias

        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 03/03/2009 at 04:04, xxxxxxxx wrote:

          Thanks Matthias. I guess it's InitRender() call for the internal material that is missing... and I don't know how to do that on a BaseMaterial/Material instance. In the example above, mC4DMaterial->GetNodeData() returns NULL.

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