remove some unused function args
[blender.git] / source / gameengine / Rasterizer / RAS_MeshObject.h
1 /**
2  * $Id$
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19  *
20  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21  * All rights reserved.
22  *
23  * The Original Code is: all of this file.
24  *
25  * Contributor(s): none yet.
26  *
27  * ***** END GPL LICENSE BLOCK *****
28  */
29 #ifndef __RAS_MESHOBJECT
30 #define __RAS_MESHOBJECT
31
32 #ifdef WIN32
33 // disable the STL warnings ("debug information length > 255")
34 #pragma warning (disable:4786)
35 #endif
36
37 #include <vector>
38 #include <set>
39 #include <list>
40
41 #include "RAS_Polygon.h"
42 #include "RAS_MaterialBucket.h"
43 #include "MT_Transform.h"
44
45 #include "GEN_HashedPtr.h"
46
47 struct Mesh;
48 class RAS_Deformer;
49
50 /* RAS_MeshObject is a mesh used for rendering. It stores polygons,
51  * but the actual vertices and index arrays are stored in material
52  * buckets, referenced by the list of RAS_MeshMaterials. */
53
54 class RAS_MeshObject
55 {
56 private:
57         unsigned int                            m_debugcolor;
58
59         bool                                            m_bModified;
60         bool                                            m_bMeshModified;
61
62         STR_String                                      m_name;
63         static STR_String                       s_emptyname;
64
65         vector<class RAS_Polygon*>      m_Polygons;
66
67         /* polygon sorting */
68         struct polygonSlot;
69         struct backtofront;
70         struct fronttoback;
71
72 protected:
73         list<RAS_MeshMaterial>                  m_materials;
74         Mesh*                                                   m_mesh;
75         bool                                                    m_bDeformed;
76
77 public:
78         // for now, meshes need to be in a certain layer (to avoid sorting on lights in realtime)
79         RAS_MeshObject(Mesh* mesh);
80         virtual ~RAS_MeshObject();
81
82
83         bool                            IsDeformed() { return m_bDeformed; }
84         
85         /* materials */
86         int                                     NumMaterials();
87         const STR_String&       GetMaterialName(unsigned int matid);
88         const STR_String&       GetTextureName(unsigned int matid);
89
90         RAS_MeshMaterial*       GetMeshMaterial(unsigned int matid);
91         RAS_MeshMaterial*       GetMeshMaterial(RAS_IPolyMaterial *mat);
92         int                                     GetMaterialId(RAS_IPolyMaterial *mat);
93
94         list<RAS_MeshMaterial>::iterator GetFirstMaterial();
95         list<RAS_MeshMaterial>::iterator GetLastMaterial();
96
97         //unsigned int          GetLightLayer();
98
99         /* name */
100         void                            SetName(const char *name);
101         STR_String&                     GetName();
102
103         /* modification state */
104         bool                            MeshModified();
105         void                            SetMeshModified(bool v){m_bMeshModified = v;}
106
107         /* original blender mesh */
108         Mesh*                           GetMesh() { return m_mesh; }
109
110         /* mesh construction */
111         
112         virtual RAS_Polygon*    AddPolygon(RAS_MaterialBucket *bucket, int numverts);
113         virtual void                    AddVertex(RAS_Polygon *poly, int i,
114                                                         const MT_Point3& xyz,
115                                                         const MT_Point2& uv,
116                                                         const MT_Point2& uv2,
117                                                         const MT_Vector4& tangent,
118                                                         const unsigned int rgbacolor,
119                                                         const MT_Vector3& normal,
120                                                         bool flat,
121                                                         int origindex);
122
123         void                                    SchedulePolygons(int drawingmode);
124
125         /* vertex and polygon acces */
126         int                                     NumVertices(RAS_IPolyMaterial* mat);
127         RAS_TexVert*            GetVertex(unsigned int matid, unsigned int index);
128         const float*            GetVertexLocation(unsigned int orig_index);
129
130         int                                     NumPolygons();
131         RAS_Polygon*            GetPolygon(int num) const;
132         
133         /* buckets */
134         virtual void            AddMeshUser(void *clientobj, SG_QList *head, RAS_Deformer* deformer);
135         virtual void            UpdateBuckets(
136                                                         void* clientobj,
137                                                         double* oglmatrix,
138                                                         bool useObjectColor,
139                                                         const MT_Vector4& rgbavec,
140                                                         bool visible,
141                                                         bool culled);
142
143         void                            RemoveFromBuckets(void *clientobj);
144         void                            EndConversion() {
145 #if 0
146                 m_sharedvertex_map.clear(); // SharedVertex
147                 vector<vector<SharedVertex> >   shared_null(0);
148                 shared_null.swap( m_sharedvertex_map ); /* really free the memory */
149 #endif
150         }
151
152         /* colors */
153         void                            DebugColor(unsigned int abgr);
154         void                            SetVertexColor(RAS_IPolyMaterial* mat,MT_Vector4 rgba);
155         
156         /* polygon sorting by Z for alpha */
157         void                            SortPolygons(RAS_MeshSlot& ms, const MT_Transform &transform);
158
159
160         bool                            HasColliderPolygon() {
161                 int numpolys= NumPolygons();
162                 for (int p=0; p<numpolys; p++)
163                         if (m_Polygons[p]->IsCollider())
164                                 return true;
165                 
166                 return false;
167         }
168
169         /* for construction to find shared vertices */
170         struct SharedVertex {
171                 RAS_DisplayArray *m_darray;
172                 int m_offset;
173         };
174
175         vector<vector<SharedVertex> >   m_sharedvertex_map;
176 };
177
178 #endif //__RAS_MESHOBJECT
179