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:
authorKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2004-11-25 11:09:18 +0300
committerKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2004-11-25 11:09:18 +0300
commit9744ea8a36a84d5fc87fcfcfd2a0d4879e33bc86 (patch)
treec21f164e630eb644443b71fbfc0f068f7bdd1e17 /source/gameengine
parent970ac5aa99005669f86288fa2f21f3c04cd7469a (diff)
Make the material colour the default colour for objects if textures & vertex colours are not available (instead of white)
Diffstat (limited to 'source/gameengine')
-rw-r--r--source/gameengine/Converter/BL_BlenderDataConversion.cpp91
1 files changed, 58 insertions, 33 deletions
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
index 7fa2b68e0c2..a716098514a 100644
--- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp
+++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
@@ -162,28 +162,39 @@
static unsigned int KX_rgbaint2uint_new(unsigned int icol)
{
- unsigned int temp=0;
- unsigned char *cp= (unsigned char *)&temp;
- unsigned char *src= (unsigned char *)&icol;
- cp[3]= src[0];//alpha
- cp[2]= src[1];//blue
- cp[1]= src[2];//green
- cp[0]= src[3];//red
- return temp;
+ union
+ {
+ unsigned int integer;
+ unsigned char cp[4];
+ } out_colour, in_colour;
+
+ in_colour.integer = icol;
+ out_colour.cp[0] = in_colour.cp[3]; // red
+ out_colour.cp[1] = in_colour.cp[2]; // green
+ out_colour.cp[2] = in_colour.cp[1]; // blue
+ out_colour.cp[3] = in_colour.cp[0]; // alpha
+
+ return out_colour.integer;
}
/* Now the real converting starts... */
static unsigned int KX_Mcol2uint_new(MCol col)
{
/* color has to be converted without endian sensitivity. So no shifting! */
- unsigned int temp=0;
- unsigned char *cp= (unsigned char *)&temp;
- unsigned char *src = (unsigned char *) &col;
- cp[0]= src[3]; // red
- cp[1]= src[2]; // green
- cp[2]= src[1]; // blue
- cp[3]= src[0]; // Alpha
- return temp;
+ union
+ {
+ MCol col;
+ unsigned int integer;
+ unsigned char cp[4];
+ } out_colour, in_colour;
+
+ in_colour.col = col;
+ out_colour.cp[0] = in_colour.cp[3]; // red
+ out_colour.cp[1] = in_colour.cp[2]; // green
+ out_colour.cp[2] = in_colour.cp[1]; // blue
+ out_colour.cp[3] = in_colour.cp[0]; // alpha
+
+ return out_colour.integer;
}
RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* rendertools, KX_Scene* scene, KX_BlenderSceneConverter *converter)
@@ -269,6 +280,8 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools*
}
+ Material* ma = give_current_material(blenderobj, 1 /* mface->mat_nr */);
+ const char* matnameptr = (ma ? ma->id.name : "");
bool polyvisible = true;
if (mesh->tface && tface)
@@ -293,11 +306,9 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools*
{
uv3 = MT_Point2(tface->uv[3]);
rgb3 = KX_rgbaint2uint_new(tface->col[3]);
- } else {
- }
-
-
- } else
+ }
+ }
+ else
{
//
if (mmcol)
@@ -316,27 +327,41 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools*
mmcol += 4;
}
- else{
+ else
+ {
// If there are no vertex colors OR texfaces,
// Initialize face to white and set COLLSION true and everything else FALSE
- rgb0 = KX_rgbaint2uint_new(0xFFFFFFFF);
- rgb1 = KX_rgbaint2uint_new(0xFFFFFFFF);
- rgb2 = KX_rgbaint2uint_new(0xFFFFFFFF);
-
- if (mface->v4)
- rgb3 = KX_rgbaint2uint_new(0xFFFFFFFF);
-
+ unsigned int colour = 0xFFFFFFFFL;
mode = TF_DYNAMIC;
transp = TF_SOLID;
tile = 0;
+ if (ma)
+ {
+ // If we have a material, take the default colour from the material.
+ union
+ {
+ unsigned char cp[4];
+ unsigned int integer;
+ } col_converter;
+
+ col_converter.cp[3] = (unsigned char) (ma->r*255.0);
+ col_converter.cp[2] = (unsigned char) (ma->g*255.0);
+ col_converter.cp[1] = (unsigned char) (ma->b*255.0);
+ col_converter.cp[0] = (unsigned char) (ma->alpha*255.0);
+
+ colour = col_converter.integer;
+ }
+
+ rgb0 = KX_rgbaint2uint_new(colour);
+ rgb1 = KX_rgbaint2uint_new(colour);
+ rgb2 = KX_rgbaint2uint_new(colour);
+
+ if (mface->v4)
+ rgb3 = KX_rgbaint2uint_new(colour);
}
}
- Material* ma = give_current_material(blenderobj, 1 /* mface->mat_nr */);
- const char* matnameptr = (ma ? ma->id.name : "");
-
-
bool istriangle = (mface->v4==0);
bool zsort = ma?(ma->mode & MA_ZTRA) != 0:false;