SetLink in a material

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 15/01/2008 at 18:53, xxxxxxxx wrote:

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

---------
Hello All,

i'm trying to setlink inside a my custom material with two others materials allocated and inserted in the same scene with:

front=(BaseMaterial* )bcmat->GetMaterialLink(VRAY2SIDEDMATERIAL_PARAMS_LINK1, pp->GetDocument());
back=(BaseMaterial* )bcmat->GetMaterialLink(VRAY2SIDEDMATERIAL_PARAMS_LINK2, pp->GetDocument());

if (front) {
frontMat=(BaseMaterial* )front->GetClone(NULL,NULL);
scene->pDoc->InsertMaterial(frontMat);
bcmat->SetLink(VRAY2SIDEDMATERIAL_PARAMS_LINK1,frontMat);
}

but if just here i try to get the linked material:

front=(BaseMaterial* )bcmat->GetMaterialLink(VRAY2SIDEDMATERIAL_PARAMS_LINK1, node->GetDocument());

front is 0x00000000

so.. seem that i'm using the wrong way to fill the material link inside my materil..

Any help?

Thanks
Renato

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 15/01/2008 at 22:25, xxxxxxxx wrote:

This is the material snapshot:

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 16/01/2008 at 08:36, xxxxxxxx wrote:

Hi all,

please it's urgent for us 😞

Cheers
Renato

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 17/01/2008 at 20:28, xxxxxxxx wrote:

Hi all,

i see that the CopyTo for this material is called 3 time.

  1. The first one is all ok, the snode links to materials are copied to the dnode.. it work 🙂

  2. now the current dnode is the same (same pointer) as the previous dnode.. but the 2 material link are now NULL;

the rendering is called..

  1. as the first time, it work but unuseless.. 😞

What i really don't understand, why the entire container is not copied? I used to play inside the copyto to understand what's can be the cause..

still investigating..
Renato T.

Edit:

I forgot.. this problem is only in the material preview.. all kind of rendering are working very good..

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 20/01/2008 at 08:44, xxxxxxxx wrote:

The problem is that the material preview is designed to only copy one material to a new (internal) document. Links only work within the same document, so that's why it fails.
I'm sorry, but I don't see a solution for this type of purpose right now!

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 20/01/2008 at 08:58, xxxxxxxx wrote:

Hello Philip,

Thanks for your answer.. but really there is no solution?
Do i must write my custom preview routine and bypass the pDoc things?

Cheers
Renato

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 20/01/2008 at 09:17, xxxxxxxx wrote:

You could try to detect a material preview situation and use GetData(id).GetBaseLink()->ForceGetLink() instead of GetMaterialLink().
ForceGetLink does no document checking but is risky in a multithreaded environment as the one document might be long gone by the time you access it. Therefore it should be limited to the material preview situation only.

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 20/01/2008 at 11:28, xxxxxxxx wrote:

Thanks Philip,

i'll try..

but what about a custom preview scene?

Cheers
Renato