Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/collada')
-rw-r--r--source/blender/collada/EffectExporter.cpp4
-rw-r--r--source/blender/collada/Materials.cpp1
-rw-r--r--source/blender/collada/collada_utils.cpp15
-rw-r--r--source/blender/collada/collada_utils.h5
4 files changed, 12 insertions, 13 deletions
diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp
index 80f84738f6e..2d69fae035f 100644
--- a/source/blender/collada/EffectExporter.cpp
+++ b/source/blender/collada/EffectExporter.cpp
@@ -112,26 +112,22 @@ void EffectsExporter::set_transparency(COLLADASW::EffectProfile &ep, Material *m
void EffectsExporter::set_diffuse_color(COLLADASW::EffectProfile &ep, Material *ma)
{
- // get diffuse color
COLLADASW::ColorOrTexture cot = bc_get_base_color(ma);
ep.setDiffuse(cot, false, "diffuse");
}
void EffectsExporter::set_ambient(COLLADASW::EffectProfile &ep, Material *ma)
{
- // get diffuse color
COLLADASW::ColorOrTexture cot = bc_get_ambient(ma);
ep.setAmbient(cot, false, "ambient");
}
void EffectsExporter::set_specular(COLLADASW::EffectProfile &ep, Material *ma)
{
- // get diffuse color
COLLADASW::ColorOrTexture cot = bc_get_specular(ma);
ep.setSpecular(cot, false, "specular");
}
void EffectsExporter::set_reflective(COLLADASW::EffectProfile &ep, Material *ma)
{
- // get diffuse color
COLLADASW::ColorOrTexture cot = bc_get_reflective(ma);
ep.setReflective(cot, false, "reflective");
}
diff --git a/source/blender/collada/Materials.cpp b/source/blender/collada/Materials.cpp
index 3b2c68ef95e..06f54884668 100644
--- a/source/blender/collada/Materials.cpp
+++ b/source/blender/collada/Materials.cpp
@@ -202,6 +202,7 @@ void MaterialNode::set_alpha(COLLADAFW::EffectCommon::OpaqueMode mode,
bNodeSocket *socket = nodeFindSocket(shader_node, SOCK_IN, "Alpha");
((bNodeSocketValueFloat *)socket->default_value)->value = alpha;
+ material->a = alpha;
}
else if (cot.isTexture()) {
int locy = -300 * (node_map.size() - 2);
diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp
index b688840cb09..d5011581204 100644
--- a/source/blender/collada/collada_utils.cpp
+++ b/source/blender/collada/collada_utils.cpp
@@ -1321,10 +1321,10 @@ void bc_add_default_shader(bContext *C, Material *ma)
COLLADASW::ColorOrTexture bc_get_base_color(Material *ma)
{
- Color default_color = {0.8, 0.8, 0.8, 1.0};
+ Color default_color = {ma->r, ma->g, ma->b, 1.0}; // for alpha see bc_get_alpha()
bNode *shader = bc_get_master_shader(ma);
if (ma->use_nodes && shader) {
- return bc_get_cot_from_shader(shader, "Base Color", default_color);
+ return bc_get_cot_from_shader(shader, "Base Color", default_color, false);
}
else {
return bc_get_cot(default_color);
@@ -1414,16 +1414,17 @@ double bc_get_float_from_shader(bNode *shader, double &val, std::string nodeid)
COLLADASW::ColorOrTexture bc_get_cot_from_shader(bNode *shader,
std::string nodeid,
- Color &default_color)
+ Color &default_color,
+ bool with_alpha)
{
bNodeSocket *socket = nodeFindSocket(shader, SOCK_IN, nodeid.c_str());
if (socket) {
bNodeSocketValueRGBA *dcol = (bNodeSocketValueRGBA *)socket->default_value;
float *col = dcol->value;
- return bc_get_cot(col);
+ return bc_get_cot(col, with_alpha);
}
else {
- return bc_get_cot(default_color); /* default black */
+ return bc_get_cot(default_color, with_alpha);
}
}
@@ -1447,9 +1448,9 @@ COLLADASW::ColorOrTexture bc_get_cot(float r, float g, float b, float a)
return cot;
}
-COLLADASW::ColorOrTexture bc_get_cot(Color col)
+COLLADASW::ColorOrTexture bc_get_cot(Color col, bool with_alpha)
{
- COLLADASW::Color color(col[0], col[1], col[2], col[3]);
+ COLLADASW::Color color(col[0], col[1], col[2], (with_alpha) ? col[3] : 1.0);
COLLADASW::ColorOrTexture cot(color);
return cot;
}
diff --git a/source/blender/collada/collada_utils.h b/source/blender/collada/collada_utils.h
index c0425e59d1a..b313fcd6e66 100644
--- a/source/blender/collada/collada_utils.h
+++ b/source/blender/collada/collada_utils.h
@@ -397,9 +397,10 @@ double bc_get_shininess(Material *ma);
double bc_get_float_from_shader(bNode *shader, double &ior, std::string nodeid);
COLLADASW::ColorOrTexture bc_get_cot_from_shader(bNode *shader,
std::string nodeid,
- Color &default_color);
+ Color &default_color,
+ bool with_alpha = true);
COLLADASW::ColorOrTexture bc_get_cot(float r, float g, float b, float a);
-COLLADASW::ColorOrTexture bc_get_cot(Color col);
+COLLADASW::ColorOrTexture bc_get_cot(Color col, bool with_alpha = true);
#endif