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

    Get the real document in MATPREVIEW_GENERATE_IMAGE material message

    Cinema 4D SDK
    r20 c++
    2
    4
    1.0k
    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.
    • P
      peterakos
      last edited by

      Hello.

      I have implemented a MaterialData plugin in which I draw my own preview listening to MATPREVIEW_GENERATE_IMAGE.
      To do that, I use the GeListNode* node parameter passed in Message(....), which in this case is the currently selected material.
      To produce the preview, I need to parse the material's parameters and transfer the material into my engine, which produces a preview image.
      If a parameter uses a bitmap shader, I am going to need that image.
      I get the image path using GenerateTexturePath. As first parameter in this function I pass the document's path.
      The problem is that the document in MATPREVIEW_GENERATE_IMAGE is the sphere.c4d in resource\modules\xtensions\preview_scenes.
      The result of this is that GenerateTexturePath returns false.

      So basically, MATPREVIEW_GENERATE_IMAGE forces me to use a GeListNode and a document that I don't need.
      Can I switch this functionality to use the real node and document file ? (othewise my preview generation cannot find the requested images in Bitmap Shaders).

      Thank you.
      Petros.

      1 Reply Last reply Reply Quote 0
      • r_giganteR
        r_gigante
        last edited by

        Hi Petros,

        you can conveniently find the original document when the MATPREVIEW_PREPARE_SCENE message is intercepted.

        In this case the data passed is MatPreviewPrepareScene where you can find, among the members, the original document (pOriginalDoc).
        From there on you know what to do.

        Best, Riccardo

        1 Reply Last reply Reply Quote 2
        • P
          peterakos
          last edited by

          Hello.

          MATPREVIEW_PREPARE_SCENE is not triggered at all.
          In the ideal scenario, I need the original node, but if that's not possible I could use the original document.

          Thank you for your time !

          1 Reply Last reply Reply Quote 0
          • r_giganteR
            r_gigante
            last edited by

            Hi Petros, in order to have the MATPREVIEW_PREPARE_SCENE being dispatched, you've to set MatPreviewObjectInfo::bNeedsOwnScene to true. At the same time also MatPreviewObjectInfo::bHandlePreview needs to be set to true when the host object is responsible for the rendering.

            Finally I think that looking at MATPREVIEW enums can be helpful as well.

            Best, Riccardo

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