diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2006-11-20 07:28:02 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2006-11-20 07:28:02 +0300 |
commit | e435fbc3c5a00e5b63c1cd2609ab6828187660d3 (patch) | |
tree | 3f1da9c51451dee55a203cd001d37f8774d2582f /source/gameengine/BlenderRoutines | |
parent | 0a7c43c6e5fc7d5d75a4645eca1164cede2d03a6 (diff) |
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
Diffstat (limited to 'source/gameengine/BlenderRoutines')
5 files changed, 28 insertions, 23 deletions
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp index af367f1797e..da3bda0a220 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp @@ -110,8 +110,8 @@ void BL_SwapBuffers() myswapbuffers(); } -void BL_RenderText(int mode,const char* textstr,int textlen,struct TFace* tface, - float v1[3],float v2[3],float v3[3],float v4[3]) +void BL_RenderText(int mode,const char* textstr,int textlen,struct MTFace* tface, + unsigned int *col,float v1[3],float v2[3],float v3[3],float v4[3]) { Image* ima; @@ -131,6 +131,8 @@ void BL_RenderText(int mode,const char* textstr,int textlen,struct TFace* tface, characters = 0; } + if(!col) glColor3f(1.0f, 1.0f, 1.0f); + glPushMatrix(); for (index = 0; index < characters; index++) { // lets calculate offset stuff @@ -140,30 +142,30 @@ void BL_RenderText(int mode,const char* textstr,int textlen,struct TFace* tface, // character = character - ' ' + 1; matrixGlyph(ima->ibuf, character, & centerx, ¢ery, &sizex, &sizey, &transx, &transy, &movex, &movey, &advance); - + glBegin(GL_POLYGON); // printf(" %c %f %f %f %f\n", character, tface->uv[0][0], tface->uv[0][1], ); // glTexCoord2f((tface->uv[0][0] - centerx) * sizex + transx, (tface->uv[0][1] - centery) * sizey + transy); glTexCoord2f((tface->uv[0][0] - centerx) * sizex + transx, (tface->uv[0][1] - centery) * sizey + transy); - spack(tface->col[0]); + if(col) spack(col[0]); // glVertex3fv(v1); glVertex3f(sizex * v1[0] + movex, sizey * v1[1] + movey, v1[2]); glTexCoord2f((tface->uv[1][0] - centerx) * sizex + transx, (tface->uv[1][1] - centery) * sizey + transy); - spack(tface->col[1]); + if(col) spack(col[1]); // glVertex3fv(v2); glVertex3f(sizex * v2[0] + movex, sizey * v2[1] + movey, v2[2]); glTexCoord2f((tface->uv[2][0] - centerx) * sizex + transx, (tface->uv[2][1] - centery) * sizey + transy); - spack(tface->col[2]); + if(col) spack(col[2]); // glVertex3fv(v3); glVertex3f(sizex * v3[0] + movex, sizey * v3[1] + movey, v3[2]); if(v4) { // glTexCoord2f((tface->uv[3][0] - centerx) * sizex + transx, 1.0 - (1.0 - tface->uv[3][1]) * sizey - transy); glTexCoord2f((tface->uv[3][0] - centerx) * sizex + transx, (tface->uv[3][1] - centery) * sizey + transy); - spack(tface->col[3]); + if(col) spack(col[3]); // glVertex3fv(v4); glVertex3f(sizex * v4[0] + movex, sizey * v4[1] + movey, v4[2]); } diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.h b/source/gameengine/BlenderRoutines/KX_BlenderGL.h index e7cc220f88c..b0f97f1a76c 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderGL.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.h @@ -49,8 +49,8 @@ void BL_HideMouse(); void BL_NormalMouse(); void BL_WaitMouse(); -void BL_RenderText(int mode,const char* textstr,int textlen,struct TFace* tface, - float v1[3],float v2[3],float v3[3],float v4[3]); +void BL_RenderText(int mode,const char* textstr,int textlen,struct MTFace* tface, + unsigned int *col,float v1[3],float v2[3],float v3[3],float v4[3]); void BL_print_gamedebug_line(char* text, int xco, int yco, int width, int height); void BL_print_gamedebug_line_padded(char* text, int xco, int yco, int width, int height); diff --git a/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.cpp b/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.cpp index df96ae55691..cdb6ce5b829 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.cpp @@ -48,7 +48,7 @@ KX_BlenderPolyMaterial::KX_BlenderPolyMaterial(const STR_String &texname, int lightlayer, bool bIsTriangle, void* clientobject, - struct TFace* tface) + struct MTFace* tface) : RAS_IPolyMaterial(texname, false, matname, @@ -79,7 +79,7 @@ void KX_BlenderPolyMaterial::Activate(RAS_IRasterizer* rasty, TCachingInfo& cach if ((m_drawingmode & 4)&& (rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED)) { - update_realtime_texture((struct TFace*) m_tface, rasty->GetTime()); + update_realtime_texture((struct MTFace*) m_tface, rasty->GetTime()); set_tpage(m_tface); rasty->EnableTextures(true); } diff --git a/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.h b/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.h index fd6d39cc8e3..1dab77cb901 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.h @@ -35,14 +35,14 @@ #include "RAS_MaterialBucket.h" #include "RAS_IRasterizer.h" -struct TFace; -extern "C" int set_tpage(TFace* tface); /* Worst hack ever */ +struct MTFace; +extern "C" int set_tpage(MTFace* tface); /* Worst hack ever */ #if 0 class KX_BlenderPolyMaterial : public RAS_IPolyMaterial { /** Blender texture face structure. */ - TFace* m_tface; + MTFace* m_tface; public: @@ -58,7 +58,7 @@ public: int lightlayer, bool bIsTriangle, void* clientobject, - struct TFace* tface); + struct MTFace* tface); /** * Returns the caching information for this material, @@ -80,20 +80,20 @@ public: * Returns the Blender texture face structure that is used for this material. * @return The material's texture face. */ - TFace* GetTFace(void) const; + MTFace* GetMTFace(void) const; protected: private: }; -inline TFace* KX_BlenderPolyMaterial::GetTFace(void) const +inline MTFace* KX_BlenderPolyMaterial::GetMTFace(void) const { return m_tface; } inline RAS_IPolyMaterial::TCachingInfo KX_BlenderPolyMaterial::GetCachingInfo(void) const { - return GetTFace(); + return GetMTFace(); } #endif diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp index 9ceae753908..caf3d120fab 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp @@ -256,17 +256,20 @@ void KX_BlenderRenderTools::RenderText(int mode,RAS_IPolyMaterial* polymat,float STR_String mytext = ((CValue*)m_clientobject)->GetPropertyText("Text"); const unsigned int flag = polymat->GetFlag(); - struct TFace* tface = 0; + struct MTFace* tface = 0; + unsigned int *col = 0; if(flag & RAS_BLENDERMAT) { KX_BlenderMaterial *bl_mat = static_cast<KX_BlenderMaterial*>(polymat); - tface = bl_mat->GetTFace(); + tface = bl_mat->GetMTFace(); + col = bl_mat->GetMCol(); } else { KX_PolygonMaterial* blenderpoly = static_cast<KX_PolygonMaterial*>(polymat); - tface = blenderpoly->GetTFace(); + tface = blenderpoly->GetMTFace(); + col = blenderpoly->GetMCol(); } - BL_RenderText( mode,mytext,mytext.Length(),tface,v1,v2,v3,v4); + BL_RenderText( mode,mytext,mytext.Length(),tface,col,v1,v2,v3,v4); } @@ -445,7 +448,7 @@ RAS_IPolyMaterial* KX_BlenderRenderTools::CreateBlenderPolyMaterial( texname, ba,matname,tile,tilexrep,tileyrep,mode,transparant,zsort, lightlayer - ,bIsTriangle,clientobject,(struct TFace*)tface);*/ + ,bIsTriangle,clientobject,(struct MTFace*)tface);*/ return NULL; } |