Changeset View
Changeset View
Standalone View
Standalone View
source/blender/collada/DocumentImporter.cpp
| Show First 20 Lines • Show All 794 Lines • ▼ Show 20 Lines | void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Material *ma) | ||||
| else if (shader == COLLADAFW::EffectCommon::SHADER_PHONG) { | else if (shader == COLLADAFW::EffectCommon::SHADER_PHONG) { | ||||
| ma->spec_shader = MA_SPEC_PHONG; | ma->spec_shader = MA_SPEC_PHONG; | ||||
| ma->har = ef->getShininess().getFloatValue(); | ma->har = ef->getShininess().getFloatValue(); | ||||
| } | } | ||||
| // lambert | // lambert | ||||
| else if (shader == COLLADAFW::EffectCommon::SHADER_LAMBERT) { | else if (shader == COLLADAFW::EffectCommon::SHADER_LAMBERT) { | ||||
| ma->diff_shader = MA_DIFF_LAMBERT; | ma->diff_shader = MA_DIFF_LAMBERT; | ||||
| } | } | ||||
| else if (shader == COLLADAFW::EffectCommon::SHADER_CONSTANT) { | |||||
gaiaclary: reduce redundancy:
else if (shader == COLLADAFW::EffectCommon::SHADER_CONSTANT) {
ma… | |||||
| ma->mode = MA_SHLESS; | |||||
| } | |||||
| // default - lambert | // default - lambert | ||||
| else { | else { | ||||
| ma->diff_shader = MA_DIFF_LAMBERT; | ma->diff_shader = MA_DIFF_LAMBERT; | ||||
| fprintf(stderr, "Current shader type is not supported, default to lambert.\n"); | fprintf(stderr, "Shader type %d is not supported, default to lambert.\n", shader); | ||||
| } | } | ||||
| // reflectivity | // reflectivity | ||||
| ma->ray_mirror = ef->getReflectivity().getFloatValue(); | ma->ray_mirror = ef->getReflectivity().getFloatValue(); | ||||
| // index of refraction | // index of refraction | ||||
| ma->ang = ef->getIndexOfRefraction().getFloatValue(); | ma->ang = ef->getIndexOfRefraction().getFloatValue(); | ||||
| int i = 0; | int i = 0; | ||||
| COLLADAFW::Color col; | COLLADAFW::Color col; | ||||
| ▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | if (ef->getEmission().isColor()) { | ||||
| // XXX there is no emission color in blender | // XXX there is no emission color in blender | ||||
| // but I am not sure | // but I am not sure | ||||
| } | } | ||||
| // texture | // texture | ||||
| else if (ef->getEmission().isTexture()) { | else if (ef->getEmission().isTexture()) { | ||||
| COLLADAFW::Texture ctex = ef->getEmission().getTexture(); | COLLADAFW::Texture ctex = ef->getEmission().getTexture(); | ||||
| mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); | mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); | ||||
| if (mtex != NULL) { | if (mtex != NULL) { | ||||
| mtex->mapto = MAP_EMIT; | mtex->mapto = (shader == COLLADAFW::EffectCommon::SHADER_CONSTANT) ? MAP_COL : MAP_EMIT; | ||||
| i++; | i++; | ||||
| } | } | ||||
| } | } | ||||
| if (ef->getOpacity().isTexture()) { | if (ef->getOpacity().isTexture()) { | ||||
| COLLADAFW::Texture ctex = ef->getOpacity().getTexture(); | COLLADAFW::Texture ctex = ef->getOpacity().getTexture(); | ||||
| mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); | mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); | ||||
| if (mtex != NULL) { | if (mtex != NULL) { | ||||
| Show All 14 Lines | else if (ef->getOpacity().isTexture()) { | ||||
| ctex = ef->getOpacity().getTexture(); | ctex = ef->getOpacity().getTexture(); | ||||
| if (mtex != NULL) mtex->mapto &= MAP_ALPHA; | if (mtex != NULL) mtex->mapto &= MAP_ALPHA; | ||||
| else { | else { | ||||
| mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); | mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); | ||||
| if (mtex != NULL) mtex->mapto = MAP_ALPHA; | if (mtex != NULL) mtex->mapto = MAP_ALPHA; | ||||
| } | } | ||||
| } | } | ||||
| #endif | #endif | ||||
| /** | |||||
| * <constant> cannot have diffuse, ambient, specular, shininnes as its child. | |||||
| * So color is solely based on | |||||
| * the emission color, so we map emission color to material's color | |||||
| */ | |||||
| if (shader == COLLADAFW::EffectCommon::SHADER_CONSTANT) { | |||||
| COLLADAFW::Color col_emmission; | |||||
| if (ef->getEmission().isValid()) { | |||||
Not Done Inline ActionsWould think variable names can be improved here, also perhaps using array instead of decoupled variables. Like: int emission[3]; sergey: Would think variable names can be improved here, also perhaps using array instead of decoupled… | |||||
Not Done Inline Actionsfloat emission[3]; gaiaclary: float emission[3];
float ambience[3];
Then you maybe can make use of the Blender's vector… | |||||
| col_emmission = ef->getEmission().getColor(); | |||||
| ma->r = col_emmission.getRed(); | |||||
| ma->g = col_emmission.getGreen(); | |||||
Not Done Inline ActionsSpace between "if" and "(". sergey: Space between "if" and "(". | |||||
| ma->b = col_emmission.getBlue(); | |||||
Not Done Inline ActionsIndentation seems to be broken. sergey: Indentation seems to be broken. | |||||
| } | |||||
| } | |||||
| material_texture_mapping_map[ma] = texindex_texarray_map; | material_texture_mapping_map[ma] = texindex_texarray_map; | ||||
| } | } | ||||
| /** When this method is called, the writer must write the effect. | /** When this method is called, the writer must write the effect. | ||||
Not Done Inline ActionsSame. sergey: Same. | |||||
| * \return The writer should return true, if writing succeeded, false otherwise.*/ | * \return The writer should return true, if writing succeeded, false otherwise.*/ | ||||
| bool DocumentImporter::writeEffect(const COLLADAFW::Effect *effect) | bool DocumentImporter::writeEffect(const COLLADAFW::Effect *effect) | ||||
| { | { | ||||
| if (mImportStage != General) | if (mImportStage != General) | ||||
| return true; | return true; | ||||
| const COLLADAFW::UniqueId& uid = effect->getUniqueId(); | const COLLADAFW::UniqueId& uid = effect->getUniqueId(); | ||||
| if (uid_effect_map.find(uid) == uid_effect_map.end()) { | if (uid_effect_map.find(uid) == uid_effect_map.end()) { | ||||
Not Done Inline ActionsWhat happens when ambient and emission are defined? then the sum could become > 1. What will blender do in that case? is this possible after all? (maybe the collada specifications tell how to merge ambient and emission... Could you add some minimal comment here please?) gaiaclary: What happens when ambient and emission are defined? then the sum could become > 1. What will… | |||||
| fprintf(stderr, "Couldn't find a material by UID.\n"); | fprintf(stderr, "Couldn't find a material by UID.\n"); | ||||
| return true; | return true; | ||||
| } | } | ||||
| Material *ma = uid_effect_map[uid]; | Material *ma = uid_effect_map[uid]; | ||||
| std::map<COLLADAFW::UniqueId, Material *>::iterator iter; | std::map<COLLADAFW::UniqueId, Material *>::iterator iter; | ||||
| for (iter = uid_material_map.begin(); iter != uid_material_map.end(); iter++) { | for (iter = uid_material_map.begin(); iter != uid_material_map.end(); iter++) { | ||||
| if (iter->second == ma) { | if (iter->second == ma) { | ||||
| ▲ Show 20 Lines • Show All 431 Lines • Show Last 20 Lines | |||||
reduce redundancy:
else if (shader == COLLADAFW::EffectCommon::SHADER_CONSTANT) { ma->mode = MA_SHLESS; } else { // default - lambert ma->diff_shader = MA_DIFF_LAMBERT; }