Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > SDK Help
  New Posts New Posts
  FAQ FAQ  Forum Search   Register Register  Login Login

Set BaseShader as shader links on Read method

 Post Reply Post Reply
Author
Message
peterakos View Drop Down
Member
Member


Joined: 2015 Jul 13
Online Status: Offline
Posts: 344
Post Options Post Options   Quote peterakos Quote  Post ReplyReply Direct Link To This Post Topic: Set BaseShader as shader links on Read method
    Posted: 2018 Jun 26 at 6:43am

User Information:

Cinema 4D Version:   R18 
Platform:   Windows  ;   
Language(s):     C++  ;   

---------

Hello.

I have a MaterialData with a couple of ShaderLink parameters.
In Read method of MaterialData, I need to make some checks. 
In some cases, I need to create specific BaseShader objects and set them in the ShaderLink parameters.
The problem is that the newly created shaders don't appear in the material.

Is this the correct workflow ?
I can see that if the shader links already contain shaders, I can replace them correcly, but if they are empty, I cannot create new to set them as links.
I have to do the whole procedure on Material Load after version checking. In read method I can check the level parameter and see if the material is old.

Thank you.
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1822
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Jun 27 at 9:19am
Hi,

it's a bit strange, that it seems to work, when replacing, but not when just creating a new shader. Can you please check, InsertShader() is called correctly in both cases?

Another issue might be, that during Read() there's no document (or rather the node isn't inserted), yet (see the note in NodeData::Read() / NodeData::Write() Manual). Not sure, why this should cause an issue with a link on first set, only, but we can't rule out this possibility, yet.

Another option is to just set a flag during Read() and then do the needed stuff in a SceneHook on MSG_DOCUMENTINFO with MSG_DOCUMENTINFO_TYPE_LOAD and MSG_DOCUMENTINFO_TYPE_MERGE.

Cheers,
Andreas
SDK Support Engineer
Back to Top
peterakos View Drop Down
Member
Member


Joined: 2015 Jul 13
Online Status: Offline
Posts: 344
Post Options Post Options   Quote peterakos Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Jun 28 at 12:48am
Hello Andreas.

I have checked InsertShader and indeed it doesn't work in Read method of the MaterialData.
I set a member flag in Read and I insert the shader in the Message method listening to MSG_DOCUMENTINFO_TYPE_LOAD/MERGE and it works fine.

Why do I have to use a SceneHook ? 
Is there something else that I also have to take into consideration ?

Thank you for your time Andreas !
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.094 seconds.