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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Wait for MaterialPreview to Finish?

    SDK Help
    0
    4
    397
    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
      Helper
      last edited by

      On 13/12/2014 at 10:27, xxxxxxxx wrote:

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

      ---------
      Hi,

      I'm trying to get the material preview image from the selected material. And put it on a button in a GeDialog.
      It mostly works. But there's one small glitch.
      If I create a new material with the GeDialog open. The preview image seems to be not quite finished yet when the GeDialog is trying to assign it to the button. And the button's image is blank.
      But...If I click on the material again after it's been created. The image shows up on the button.
      using myButton->Redraw() does not fix the problem.

      If I use: ShowBitmap(preview)
      instead of: myButton->SetImage(mat->GetPreview(0), TRUE, FALSE);
      What I get is a material preview with nothing but an alpha background.

      Is there some way that I can test if a preview has been fully rendered?
      In past cases like this. I've had to use a Callback() method which will only output when a task is finished. And This feels like one of those times.
      I'm trying to figure out how to write the RenderPreviewImageCallback(). But I'm not having much luck with it yet.

      Thanks,
      -ScottA

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

        On 13/12/2014 at 13:23, xxxxxxxx wrote:

        I found a solution to my problem.
        It turns out that if I use and instance of myButton->SetImage() in my CoreMessage code. It solves the problem.

        Even though I solved my problem. It would be very nice to know how to use the RenderPreviewImageCallback().

        If someone gets a chance. Can you please post an example?

        Thanks,
        -ScottA

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

          On 17/12/2014 at 04:43, xxxxxxxx wrote:

          Hello,

          I'm currently working on an example material that shows what one can do with the material preview element. I will try to add this callback to this example.

          Best wishes,
          Sebastian

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

            On 17/12/2014 at 07:14, xxxxxxxx wrote:

            Thanks,
            I tend to generally struggle with custom callbacks in all SDK's (not just Cinema). I don't usually write them in my own code.
            Some of them use templates and some don't. So it's rather confusing and alien looking to me until I see a working example to see how to use it.

            I'm hoping if I compile enough examples of them. I might some day be able to figure them out without asking for an example.
            I had this same trouble with casting. But eventually I compiled enough casting examples that I can now pretty much do any cast I need. But it took a few dozen examples in my notes to get to that point.

            -ScottA

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