THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 29/05/2010 at 20:52, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 11.5
Platform: Windows ;
Language(s) : C++ ;
---------
Okay, so I have created the following within GetVirtualObjects() :
BaseObject *Space::GetVirtualObjects(BaseObject* op, HierarchyHelp* hh)
{
BaseDocument *doc = op->GetDocument();
//DEFINE TEXTURE TAG
spaceTextTag = TextureTag::Alloc();
if (!spaceTextTag) return false;
//DEFINE MATERIAL
spaceMat = Material::Alloc();
if (!spaceMat) return false;
//DEFINE SHADER
starField = PluginShader::Alloc(1025338);
if (!starField) return FALSE;
//SET MATERIAL NAME
spaceMat->SetName("Space");
space->InsertTag(spaceTextTag,0);
spaceTextTag->SetMaterial(spaceMat);
TextureTag* myTag = (TextureTag* )(space->GetFirstTag());
if (!myTag) return FALSE;
if (doc->GetFirstMaterial() && doc->GetFirstMaterial()->GetName() == "Space")
{
doc->GetFirstMaterial()->Remove();
doc->InsertMaterial(spaceMat, NULL, 1);
}
else
{
doc->InsertMaterial(spaceMat, NULL, 1);
}
//INSERT AND SETUP THE NOISE SHADER FOR THE DISPLACEMENT CHANNEL
spaceMat->InsertShader(starField, NULL);
spaceMat->GetDataInstance()->SetLink(MATERIAL_COLOR_SHADER,starField);
return space;
}
The purpose of this is so that my object takes on the functions of the sky object without actually having to add a sky object as a child of my object. The problem here is that because GetVirtualObjects is called over and over this setup continuously creates a new material in the material manager. My question is how can I make it so it only creates one material and then does not create any more? Or better yet, is there a way to add the material to my object (Space Object) and have it effect the virtual sky that is being created behind the scenes?
Thanks,
~Shawn