Changeset View
Changeset View
Standalone View
Standalone View
source/blender/collada/EffectExporter.cpp
| Context not available. | |||||
| ep.setShaderType(COLLADASW::EffectProfile::LAMBERT); | ep.setShaderType(COLLADASW::EffectProfile::LAMBERT); | ||||
| } | } | ||||
| void EffectsExporter::writePhong(COLLADASW::EffectProfile &ep, Material *ma) | void EffectsExporter::write_Phong_or_Constant(COLLADASW::EffectProfile &ep, Material *ma, bool is_shadeless) | ||||
gaiaclary: i think there is no need to use the parameter is_shadeless here. See below line 195 | |||||
| { | { // Is Constant(shadeless Material) | ||||
| COLLADASW::ColorOrTexture cot; | if (is_shadeless) { | ||||
| ep.setShaderType(COLLADASW::EffectProfile::PHONG); | ep.setShaderType(COLLADASW::EffectProfile::CONSTANT); | ||||
| // shininess | } | ||||
Not Done Inline ActionsWhy not make one method: void EffectsExporter::writeShader(COLLADASW::EffectProfile &ep, COLLADASW::ShaderType, Material *ma ) This would avoid duplication of code. gaiaclary: Why not make one method:
void EffectsExporter::writeShader(COLLADASW::EffectProfile &ep… | |||||
| ep.setShininess(ma->har, false, "shininess"); | //Is Phong shader | ||||
| // specular | else { | ||||
| cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f); | COLLADASW::ColorOrTexture cot; | ||||
| ep.setSpecular(cot, false, "specular"); | ep.setShaderType(COLLADASW::EffectProfile::PHONG); | ||||
| // shininess | |||||
| ep.setShininess(ma->har, false, "shininess"); | |||||
| // specular | |||||
| cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f); | |||||
| ep.setSpecular(cot, false, "specular"); | |||||
| } | |||||
| } | } | ||||
| void EffectsExporter::writeTextures(COLLADASW::EffectProfile &ep, | void EffectsExporter::writeTextures(COLLADASW::EffectProfile &ep, | ||||
| 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); | ||||
Not Done Inline ActionsSeems you're unintentionally modifying material bitflags here. sergey: Seems you're unintentionally modifying material bitflags here. | |||||
| ep.openProfile(); | ep.openProfile(); | ||||
| if (is_shadeless) { | |||||
| write_Phong_or_Constant(ep, ma, is_shadeless); | |||||
gaiaclaryAuthorUnsubmitted 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. | |||||
| ep.setShaderType(COLLADASW::EffectProfile::CONSTANT); | |||||
| } | |||||
| else { | |||||
| // set shader type - one of three blinn, phong or lambert | // set shader type - one of three blinn, phong or lambert | ||||
| if (ma->spec > 0.0f) { | if (ma->spec > 0.0f) { | ||||
| if (ma->spec_shader == MA_SPEC_BLINN) { | if (ma->spec_shader == MA_SPEC_BLINN) { | ||||
| Context not available. | |||||
| else { | else { | ||||
| // \todo figure out handling of all spec+diff shader combos blender has, for now write phong | // \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 | // for now set phong in case spec shader is not blinn | ||||
| writePhong(ep, ma); | write_Phong_or_Constant(ep, ma, is_shadeless); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
Not Done Inline Actionssomething wrong with indentation here? gaiaclary: something wrong with indentation here? | |||||
| Context not available. | |||||
| } | } | ||||
| else { | else { | ||||
| // \todo figure out handling of all spec+diff shader combos blender has, for now write phong | // \todo figure out handling of all spec+diff shader combos blender has, for now write phong | ||||
| writePhong(ep, ma); | write_Phong_or_Constant(ep, ma, is_shadeless); | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| // index of refraction | // index of refraction | ||||
| if (ma->mode & MA_RAYTRANSP) { | if (ma->mode & MA_RAYTRANSP) { | ||||
| Context not available. | |||||
| } | } | ||||
Not Done Inline ActionsSame as above. sergey: Same as above. | |||||
| // emission | // emission | ||||
| cot = getcol(ma->emit, ma->emit, ma->emit, 1.0f); | if (!is_shadeless) { | ||||
gaiaclaryAuthorUnsubmitted 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) {...}… | |||||
| ep.setEmission(cot, false, "emission"); | cot = getcol(ma->emit, ma->emit, ma->emit, 1.0f); | ||||
| ep.setEmission(cot, false, "emission"); | |||||
| } | |||||
| else { | |||||
| cot = getcol(ma->r, ma->g, ma->b, 1.0f); | |||||
| ep.setEmission(cot,false,"emission"); | |||||
gaiaclaryAuthorUnsubmitted 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. | |||||
| } | |||||
| // 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); | if (!is_shadeless) { | ||||
| ep.setDiffuse(cot, false, "diffuse"); | cot = getcol(ma->r * ma->ref, ma->g * ma->ref, ma->b * ma->ref, 1.0f); | ||||
| ep.setDiffuse(cot, false, "diffuse"); | |||||
| } | |||||
| // 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); | if (this->scene->world) | ||||
| else | cot = getcol(this->scene->world->ambr * ma->amb, this->scene->world->ambg * ma->amb, this->scene->world->ambb * ma->amb, 1.0f); | ||||
gaiaclaryAuthorUnsubmitted Not Done Inline Actionsadd a line break and indent here gaiaclary: add a line break and indent here | |||||
| cot = getcol(ma->amb, ma->amb, ma->amb, 1.0f); | else | ||||
| cot = getcol(ma->amb, ma->amb, ma->amb, 1.0f); | |||||
| ep.setAmbient(cot, false, "ambient"); | ep.setAmbient(cot, false, "ambient"); | ||||
| } | |||||
| // 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. | |||||
i think there is no need to use the parameter is_shadeless here. See below line 195