Wait for MaterialPreview to Finish?
-
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 -
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 -
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 -
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