diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-11-11 04:39:08 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-11-11 04:39:08 +0400 |
commit | dfc55421dfed71b3b9cc074d1d3919bd02168ad7 (patch) | |
tree | 169e16da6e3589901236858cbc5586a1c5098745 /source/gameengine | |
parent | f8af8100d28910202f0b34f5aafea30321d59842 (diff) |
game engine material conversion: don't use the material to convert vertex colors, then extract back out (pre face).
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/Converter/BL_BlenderDataConversion.cpp | 29 | ||||
-rw-r--r-- | source/gameengine/Ketsji/BL_Material.cpp | 21 | ||||
-rw-r--r-- | source/gameengine/Ketsji/BL_Material.h | 5 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_BlenderMaterial.cpp | 7 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_BlenderMaterial.h | 2 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_PolygonMaterial.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_PolygonMaterial.h | 2 |
7 files changed, 20 insertions, 48 deletions
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index d127f1fba78..b5ff11007de 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -487,15 +487,14 @@ static bool ConvertMaterial( MTFace* tface, const char *tfaceName, MFace* mface, - MCol* mmcol, + MCol* mmcol, /* only for text, use first mcol, weak */ MTF_localLayer *layers, - bool glslmat) + const bool glslmat) { material->Initialize(); int numchan = -1, texalpha = 0; bool validmat = (mat!=0); bool validface = (tface!=0); - bool use_mcol = true; material->IdMode = DEFAULT_BLENDER; material->glslmat = (validmat)? glslmat: false; @@ -503,7 +502,6 @@ static bool ConvertMaterial( // -------------------------------- if (validmat) { - use_mcol = (mat->mode & MA_VERTEXCOLP || glslmat) ? true: false; // use lighting? material->ras_mode |= ( mat->mode & MA_SHLESS )?0:USE_LIGHT; material->ras_mode |= ( mat->game.flag & GEMAT_BACKCULL )?0:TWOSIDED; @@ -852,19 +850,9 @@ static bool ConvertMaterial( } } - unsigned int rgb[4]; - GetRGB(use_mcol, mface, mmcol, mat, rgb[0], rgb[1], rgb[2], rgb[3]); - - // swap the material color, so MCol on bitmap font works - if (validmat && use_mcol == false && (mat->game.flag & GEMAT_TEXT)) - { - rgb[0] = KX_rgbaint2uint_new(rgb[0]); - rgb[1] = KX_rgbaint2uint_new(rgb[1]); - rgb[2] = KX_rgbaint2uint_new(rgb[2]); - rgb[3] = KX_rgbaint2uint_new(rgb[3]); + if (validmat && mmcol) { /* color is only for text */ + material->m_mcol = *(unsigned int *)mmcol; } - - material->SetConversionRGB(rgb); material->SetConversionUV(uvName, uv); material->SetConversionUV2(uv2Name, uv2); @@ -1009,20 +997,19 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, KX_Scene* scene, bool twoside = false; if (converter->GetMaterials()) { + const bool glslmat = converter->GetGLSLMaterials(); + const bool use_mcol = ma ? (ma->mode & MA_VERTEXCOLP || glslmat) : true; /* do Blender Multitexture and Blender GLSL materials */ - unsigned int rgb[4]; MT_Point2 uv[4]; /* first is the BL_Material */ if (!bl_mat) bl_mat = new BL_Material(); ConvertMaterial(bl_mat, ma, tface, tfaceName, mface, mcol, - layers, converter->GetGLSLMaterials()); + layers, glslmat); /* vertex colors and uv's were stored in bl_mat temporarily */ - bl_mat->GetConversionRGB(rgb); - rgb0 = rgb[0]; rgb1 = rgb[1]; - rgb2 = rgb[2]; rgb3 = rgb[3]; + GetRGB(use_mcol, mface, mcol, ma, rgb0, rgb1, rgb2, rgb3); bl_mat->GetConversionUV(uv); uv0 = uv[0]; uv1 = uv[1]; diff --git a/source/gameengine/Ketsji/BL_Material.cpp b/source/gameengine/Ketsji/BL_Material.cpp index 4c7518769e1..a7d89517a08 100644 --- a/source/gameengine/Ketsji/BL_Material.cpp +++ b/source/gameengine/Ketsji/BL_Material.cpp @@ -36,10 +36,7 @@ BL_Material::BL_Material() void BL_Material::Initialize() { - rgb[0] = 0; - rgb[1] = 0; - rgb[2] = 0; - rgb[3] = 0; + m_mcol = 0xFFFFFFFFL; IdMode = 0; ras_mode = 0; glslmat = 0; @@ -98,22 +95,6 @@ void BL_Material::Initialize() } } -void BL_Material::SetConversionRGB(unsigned int *nrgb) -{ - rgb[0]=*nrgb++; - rgb[1]=*nrgb++; - rgb[2]=*nrgb++; - rgb[3]=*nrgb; -} - -void BL_Material::GetConversionRGB(unsigned int *nrgb) -{ - *nrgb++ = rgb[0]; - *nrgb++ = rgb[1]; - *nrgb++ = rgb[2]; - *nrgb = rgb[3]; -} - void BL_Material::SetConversionUV(const STR_String& name, MT_Point2 *nuv) { uvName = name; diff --git a/source/gameengine/Ketsji/BL_Material.h b/source/gameengine/Ketsji/BL_Material.h index b67bd95f878..082e265f387 100644 --- a/source/gameengine/Ketsji/BL_Material.h +++ b/source/gameengine/Ketsji/BL_Material.h @@ -87,17 +87,14 @@ public: MTFace tface; /* copy of the derived meshes tface */ Image* img[MAXTEX]; EnvMap* cubemap[MAXTEX]; + unsigned int m_mcol; /* for text color (only) */ - unsigned int rgb[4]; MT_Point2 uv[4]; MT_Point2 uv2[4]; STR_String uvName; STR_String uv2Name; - void SetConversionRGB(unsigned int *rgb); - void GetConversionRGB(unsigned int *rgb); - void SetConversionUV(const STR_String& name, MT_Point2 *uv); void GetConversionUV(MT_Point2 *uv); diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index 2154beeb205..cb995c3f738 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -124,7 +124,7 @@ MTFace* KX_BlenderMaterial::GetMTFace(void) const unsigned int* KX_BlenderMaterial::GetMCol(void) const { // fonts on polys - return mMaterial->rgb; + return &mMaterial->m_mcol; } void KX_BlenderMaterial::GetMaterialRGBAColor(unsigned char *rgba) const @@ -138,6 +138,11 @@ void KX_BlenderMaterial::GetMaterialRGBAColor(unsigned char *rgba) const RAS_IPolyMaterial::GetMaterialRGBAColor(rgba); } +bool KX_BlenderMaterial::IsMaterial(BL_Material *bl_mat) const +{ + return (mMaterial == bl_mat); +} + Material *KX_BlenderMaterial::GetBlenderMaterial() const { return mMaterial->material; diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.h b/source/gameengine/Ketsji/KX_BlenderMaterial.h index 1653669ebcc..c38eb2a6fd0 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.h +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.h @@ -76,6 +76,8 @@ public: TCachingInfo& cachingInfo )const; + /* mMaterial is private, but need this for conversion */ + bool IsMaterial(BL_Material *bl_mat) const; Material* GetBlenderMaterial() const; MTFace* GetMTFace(void) const; unsigned int* GetMCol(void) const; diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp index 36c94dc997b..f89b918f31b 100644 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp +++ b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp @@ -109,7 +109,7 @@ void KX_PolygonMaterial::Initialize( m_mcol = *mcol; } else { - memset(&m_mcol, 0, sizeof(m_mcol)); + m_mcol = 0; } m_material = ma; diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.h b/source/gameengine/Ketsji/KX_PolygonMaterial.h index 89bfb4ff9fb..2ce8f480c1c 100644 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.h +++ b/source/gameengine/Ketsji/KX_PolygonMaterial.h @@ -60,7 +60,7 @@ class KX_PolygonMaterial : public PyObjectPlus, public RAS_IPolyMaterial private: /** Blender texture face structure. */ mutable MTFace m_tface; - mutable unsigned int m_mcol; + mutable unsigned int m_mcol; /* for text color (only) */ Material* m_material; #ifdef WITH_PYTHON |