Parameter MATERIAL_USE_REFLECTANCE [SOLVED]
-
On 11/11/2016 at 04:46, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R17.055
Platform: Windows ;
Language(s) : C++ ;---------
The bool parameter I want set is highlighted in red:
The list of parameter IDs that controls the checkboxes in this section are:
MATERIAL_USE_COLOR MATERIAL_USE_DIFFUSION MATERIAL_USE_LUMINANCE MATERIAL_USE_TRANSPARENCY MATERIAL_USE_REFLECTION MATERIAL_USE_ENVIRONMENT MATERIAL_USE_FOG MATERIAL_USE_BUMP MATERIAL_USE_ALPHA MATERIAL_USE_SPECULAR MATERIAL_USE_SPECULARCOLOR MATERIAL_USE_GLOW MATERIAL_USE_DISPLACEMENT MATERIAL_USE_NORMAL
This works without a problem:
material->SetParameter(DescID(MATERIAL_USE_COLOR), false, DESCFLAGS_SET_0);
This does not (i.e. the checkbox remains checked) :
material->SetParameter(DescID(MATERIAL_USE_REFLECTION), false, DESCFLAGS_SET_0);
Is this a bug or am I missing something?
Judging by the naming of the parameter IDs, it seems like this just wasn't updated once "Reflection", "Specular" and "Specular Color" was merged into "Reflectance".
-
On 14/11/2016 at 01:35, xxxxxxxx wrote:
Hello,
I could not reproduce any issues with MATERIAL_USE_REFLECTION under R18. This is the code I use to switch the parameter:
GeData data; material->GetParameter(MATERIAL_USE_REFLECTION, data, DESCFLAGS_GET_0); const Bool status = data.GetBool(); material->SetParameter(MATERIAL_USE_REFLECTION, !status, DESCFLAGS_SET_0); EventAdd();
best wishes,
Sebastian -
On 14/11/2016 at 03:18, xxxxxxxx wrote:
I guess this must be a bug in 17.055 then, your code does not affect the reflectance checkbox. SetParameter() does return true but nothing actually changes.
I can control every other material checkbox by using the same code.
Edit: Can confirm that the problem persists under R18. I truly do not get it.
If I'm unclear in what I'm trying to do, I want to change this:
to this:
The following parameter IDs:
MATERIAL_USE_REFLECTION MATERIAL_USE_SPECULAR MATERIAL_USE_SPECULARCOLOR
doesn't make sense post R16 and I don't think they actually do anything. It would make sense for them all to be replaced by:
MATERIAL_USE_REFLECTANCE
which doesn't exist.
-
On 14/11/2016 at 09:10, xxxxxxxx wrote:
Hello,
sorry but I also can't reproduce any problems with the above code and R17.055. What kind of plugin are you writing, in what context are you calling your code?
best wishes,
Sebastian -
On 14/11/2016 at 09:28, xxxxxxxx wrote:
I edited my above post further.
I'm creating a plugin that is based on the STL loader example. I'm essentially calling the code from what was STLLoaderData::Load().
Edit: This is the WIP static function I wrote to create materials. Once called from Load() it is inserted into the base document and assigned to corresponding polygon object.
static BaseMaterial* importMaterial(BaseDocument* doc, FileSystem* fs, Texture texture) { static const std::vector<std::string> IMG_EXTS = { ".jpg", ".jpeg", ".png", ".tga" }; std::string path; for (const auto &ext : IMG_EXTS) { if (fs->contents.find(reinterpret_cast<char*>(&texture.name) + ext) != fs->contents.end()) { try { path = fs->writeFile((reinterpret_cast<char*>(&texture.name) + ext), c4dToStdStr(doc->GetDocumentPath().GetString()), "tex"); } catch (const std::exception& ex) { GePrint(ex.what()); return nullptr; } break; } } BaseMaterial* material = BaseMaterial::Alloc(Mmaterial); if (!material) { return nullptr; } if (!path.empty()) { BaseShader* bitmap_shader = BaseShader::Alloc(Xbitmap); if (!bitmap_shader) { BaseMaterial::Free(material); return nullptr; } bitmap_shader->SetParameter(DescID(BITMAPSHADER_FILENAME), Filename(path.c_str()), DESCFLAGS_SET_0); material->SetParameter(DescID(MATERIAL_COLOR_SHADER), bitmap_shader, DESCFLAGS_SET_0); material->InsertShader(bitmap_shader); } material->SetParameter(DescID(MATERIAL_USE_REFLECTION), false, DESCFLAGS_SET_0); material->SetName(reinterpret_cast<char*>(&texture.name)); material->Message(MSG_UPDATE); return material; }
-
On 15/11/2016 at 01:23, xxxxxxxx wrote:
Hello,
when one loads a scene with a SceneLoader, Cinema will do some clean-up after that scene is created. This includes handling the reflection layers. By default this will turn on the reflectance channel.
To avoid this one has to inform Cinema that the reflection settings are imported. This is done by setting the REFLECTION_LAYER_IMPORTED parameter.
// disable reflection channel material->SetParameter(MATERIAL_USE_REFLECTION, false, DESCFLAGS_SET_0); // inform Cinema that the reflection data is imported material->SetParameter(REFLECTION_LAYER_IMPORTED, true, DESCFLAGS_SET_0);
best wishes,
Sebastian -
On 15/11/2016 at 02:14, xxxxxxxx wrote:
Ah, I see. It works correctly now, thank you!