Changeset View
Changeset View
Standalone View
Standalone View
source/blender/collada/EffectExporter.cpp
| Context not available. | |||||
| void EffectsExporter::operator()(Material *ma, Object *ob) | void EffectsExporter::operator()(Material *ma, Object *ob) | ||||
| { | { | ||||
| bool is_shadeless = ma->mode & MA_SHLESS; | |||||
| // create a list of indices to textures of type TEX_IMAGE | // create a list of indices to textures of type TEX_IMAGE | ||||
| std::vector<int> tex_indices; | std::vector<int> tex_indices; | ||||
| if (this->export_settings->include_material_textures) | if (this->export_settings->include_material_textures) | ||||
| Context not available. | |||||
| COLLADASW::EffectProfile ep(mSW); | COLLADASW::EffectProfile ep(mSW); | ||||
| ep.setProfileType(COLLADASW::EffectProfile::COMMON); | ep.setProfileType(COLLADASW::EffectProfile::COMMON); | ||||
| ep.openProfile(); | ep.openProfile(); | ||||
| // set shader type - one of three blinn, phong or lambert | if (is_shadeless) { | ||||
| if (ma->spec > 0.0f) { | ep.setShaderType(COLLADASW::EffectProfile::CONSTANT); | ||||
| if (ma->spec_shader == MA_SPEC_BLINN) { | |||||
| writeBlinn(ep, ma); | |||||
| } | |||||
| else { | |||||
| // \todo figure out handling of all spec+diff shader combos blender has, for now write phong | |||||
| // for now set phong in case spec shader is not blinn | |||||
| writePhong(ep, ma); | |||||
| } | |||||
| } | } | ||||
| else { | else { | ||||
| if (ma->diff_shader == MA_DIFF_LAMBERT) { | // set shader type - one of three blinn, phong or lambert | ||||
sergey: Seems you're unintentionally modifying material bitflags here. | |||||
| writeLambert(ep, ma); | if (ma->spec > 0.0f) { | ||||
| if (ma->spec_shader == MA_SPEC_BLINN) { | |||||
| writeBlinn(ep, ma); | |||||
Not Done Inline Actionsno need to call this function here. line 195 below already does the trick. gaiaclary: no need to call this function here. line 195 below already does the trick. | |||||
| } | |||||
| else { | |||||
| // \todo figure out handling of all spec+diff shader combos blender has, for now write phong | |||||
| // for now set phong in case spec shader is not blinn | |||||
| writePhong(ep, ma); | |||||
| } | |||||
| } | } | ||||
| else { | else { | ||||
| // \todo figure out handling of all spec+diff shader combos blender has, for now write phong | if (ma->diff_shader == MA_DIFF_LAMBERT) { | ||||
| writePhong(ep, ma); | writeLambert(ep, ma); | ||||
| } | |||||
| else { | |||||
| // \todo figure out handling of all spec+diff shader combos blender has, for now write phong | |||||
| writePhong(ep, ma); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
Not Done Inline Actionssomething wrong with indentation here? gaiaclary: something wrong with indentation here? | |||||
| // index of refraction | // index of refraction | ||||
| if (ma->mode & MA_RAYTRANSP) { | if (ma->mode & MA_RAYTRANSP) { | ||||
| Context not available. | |||||
| } | } | ||||
| // emission | // emission | ||||
| cot = getcol(ma->emit, ma->emit, ma->emit, 1.0f); | if (is_shadeless) { | ||||
| cot = getcol(ma->r, ma->g, ma->b, 1.0f); | |||||
| } | |||||
| else { | |||||
| cot = getcol(ma->emit, ma->emit, ma->emit, 1.0f); | |||||
Not Done Inline ActionsSame as above. sergey: Same as above. | |||||
| } | |||||
| ep.setEmission(cot, false, "emission"); | ep.setEmission(cot, false, "emission"); | ||||
Not Done Inline ActionsHaving double negation sounds not right to me. I would rather use: if(is_shadeless) {...} else {...}or maybe: instead of is_shadeless, use boolean has_shade... gaiaclary: Having double negation sounds not right to me. I would rather use:
if(is_shadeless) {...}… | |||||
| // diffuse multiplied by diffuse intensity | // diffuse multiplied by diffuse intensity | ||||
| cot = getcol(ma->r * ma->ref, ma->g * ma->ref, ma->b * ma->ref, 1.0f); | |||||
| ep.setDiffuse(cot, false, "diffuse"); | if (!is_shadeless) { | ||||
| cot = getcol(ma->r * ma->ref, ma->g * ma->ref, ma->b * ma->ref, 1.0f); | |||||
| ep.setDiffuse(cot, false, "diffuse"); | |||||
| } | |||||
Not Done Inline Actionsyou could move line 241 and line 245 below the if/else block. gaiaclary: you could move line 241 and line 245 below the if/else block. | |||||
| // ambient | // ambient | ||||
| /* ma->ambX is calculated only on render, so lets do it here manually and not rely on ma->ambX. */ | /* ma->ambX is calculated only on render, so lets do it here manually and not rely on ma->ambX. */ | ||||
| if (this->scene->world) | if (is_shadeless) | ||||
| cot = getcol(this->scene->world->ambr * ma->amb, this->scene->world->ambg * ma->amb, this->scene->world->ambb * ma->amb, 1.0f); | |||||
| else | |||||
| cot = getcol(ma->amb, ma->amb, ma->amb, 1.0f); | cot = getcol(ma->amb, ma->amb, ma->amb, 1.0f); | ||||
| else { | |||||
| ep.setAmbient(cot, false, "ambient"); | if (this->scene->world) | ||||
| cot = getcol(this->scene->world->ambr * ma->amb, | |||||
| this->scene->world->ambg * ma->amb, | |||||
| this->scene->world->ambb * ma->amb, 1.0f); | |||||
| ep.setAmbient(cot, false, "ambient"); | |||||
| } | |||||
Not Done Inline Actionsadd a line break and indent here gaiaclary: add a line break and indent here | |||||
| // reflective, reflectivity | // reflective, reflectivity | ||||
| if (ma->mode & MA_RAYMIRROR) { | if (ma->mode & MA_RAYMIRROR) { | ||||
| Context not available. | |||||
| // specular | // specular | ||||
| if (ep.getShaderType() != COLLADASW::EffectProfile::LAMBERT) { | if (ep.getShaderType() != COLLADASW::EffectProfile::LAMBERT) { | ||||
| cot = getcol(ma->specr * ma->spec, ma->specg * ma->spec, ma->specb * ma->spec, 1.0f); | if (!is_shadeless) { | ||||
| ep.setSpecular(cot, false, "specular"); | cot = getcol(ma->specr * ma->spec, ma->specg * ma->spec, ma->specb * ma->spec, 1.0f); | ||||
| ep.setSpecular(cot, false, "specular"); | |||||
| } | |||||
| } | } | ||||
| // XXX make this more readable if possible | // XXX make this more readable if possible | ||||
| Context not available. | |||||
Seems you're unintentionally modifying material bitflags here.