2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
#ifndef __RAS_MESHOBJECT
|
|
|
|
|
#define __RAS_MESHOBJECT
|
|
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
// disable the STL warnings ("debug information length > 255")
|
|
|
|
|
#pragma warning (disable:4786)
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <set>
|
2008-09-19 14:15:36 +00:00
|
|
|
#include <list>
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
#include "RAS_Polygon.h"
|
2004-05-04 09:34:02 +00:00
|
|
|
#include "RAS_MaterialBucket.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "MT_Transform.h"
|
|
|
|
|
|
|
|
|
|
#include "GEN_HashedPtr.h"
|
|
|
|
|
|
2008-06-20 21:36:15 +00:00
|
|
|
struct Mesh;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-09-19 14:15:36 +00:00
|
|
|
/* RAS_MeshObject is a mesh used for rendering. It stores polygons,
|
|
|
|
|
* but the actual vertices and index arrays are stored in material
|
|
|
|
|
* buckets, referenced by the list of RAS_MeshMaterials. */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
class RAS_MeshObject
|
|
|
|
|
{
|
2008-09-19 14:15:36 +00:00
|
|
|
private:
|
2002-10-12 11:37:38 +00:00
|
|
|
unsigned int m_debugcolor;
|
2008-09-19 12:05:45 +00:00
|
|
|
int m_lightlayer;
|
2008-09-19 14:15:36 +00:00
|
|
|
|
|
|
|
|
bool m_bModified;
|
|
|
|
|
bool m_bMeshModified;
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
STR_String m_name;
|
|
|
|
|
static STR_String s_emptyname;
|
2006-04-02 21:04:20 +00:00
|
|
|
|
2008-09-19 14:15:36 +00:00
|
|
|
vector<class RAS_Polygon*> m_Polygons;
|
|
|
|
|
|
|
|
|
|
/* polygon sorting */
|
2004-07-17 05:23:17 +00:00
|
|
|
struct polygonSlot;
|
|
|
|
|
struct backtofront;
|
|
|
|
|
struct fronttoback;
|
2004-05-26 12:01:08 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
protected:
|
2008-09-19 14:15:36 +00:00
|
|
|
list<RAS_MeshMaterial> m_materials;
|
2008-06-20 21:36:15 +00:00
|
|
|
Mesh* m_mesh;
|
2008-09-19 14:15:36 +00:00
|
|
|
bool m_bDeformed;
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
public:
|
|
|
|
|
// for now, meshes need to be in a certain layer (to avoid sorting on lights in realtime)
|
2008-06-20 21:36:15 +00:00
|
|
|
RAS_MeshObject(Mesh* mesh, int lightlayer);
|
2002-10-12 11:37:38 +00:00
|
|
|
virtual ~RAS_MeshObject();
|
|
|
|
|
|
2008-09-19 12:05:45 +00:00
|
|
|
|
2008-09-19 14:15:36 +00:00
|
|
|
bool IsDeformed() { return m_bDeformed; }
|
|
|
|
|
|
|
|
|
|
/* materials */
|
2002-10-12 11:37:38 +00:00
|
|
|
int NumMaterials();
|
2004-03-22 22:02:18 +00:00
|
|
|
const STR_String& GetMaterialName(unsigned int matid);
|
|
|
|
|
const STR_String& GetTextureName(unsigned int matid);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-09-19 14:15:36 +00:00
|
|
|
RAS_MeshMaterial* GetMeshMaterial(unsigned int matid);
|
|
|
|
|
RAS_MeshMaterial* GetMeshMaterial(RAS_IPolyMaterial *mat);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-09-19 14:15:36 +00:00
|
|
|
list<RAS_MeshMaterial>::iterator GetFirstMaterial();
|
|
|
|
|
list<RAS_MeshMaterial>::iterator GetLastMaterial();
|
2004-05-26 12:01:08 +00:00
|
|
|
|
2008-09-19 14:15:36 +00:00
|
|
|
unsigned int GetLightLayer();
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-09-19 14:15:36 +00:00
|
|
|
/* name */
|
|
|
|
|
void SetName(STR_String name);
|
|
|
|
|
const STR_String& GetName();
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-09-19 14:15:36 +00:00
|
|
|
/* modification state */
|
|
|
|
|
bool MeshModified();
|
|
|
|
|
void SetMeshModified(bool v){m_bMeshModified = v;}
|
2008-09-15 14:20:31 +00:00
|
|
|
|
2008-09-19 14:15:36 +00:00
|
|
|
/* original blender mesh */
|
|
|
|
|
Mesh* GetMesh() { return m_mesh; }
|
|
|
|
|
|
|
|
|
|
/* mesh construction */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-09-19 14:15:36 +00:00
|
|
|
virtual RAS_Polygon* AddPolygon(RAS_MaterialBucket *bucket, int numverts);
|
|
|
|
|
virtual void AddVertex(RAS_Polygon *poly, int i,
|
2002-10-12 11:37:38 +00:00
|
|
|
const MT_Point3& xyz,
|
|
|
|
|
const MT_Point2& uv,
|
2007-01-07 04:39:39 +00:00
|
|
|
const MT_Point2& uv2,
|
2006-02-13 05:45:32 +00:00
|
|
|
const MT_Vector4& tangent,
|
2002-10-12 11:37:38 +00:00
|
|
|
const unsigned int rgbacolor,
|
|
|
|
|
const MT_Vector3& normal,
|
2008-06-20 21:36:15 +00:00
|
|
|
bool flat,
|
2008-09-19 14:15:36 +00:00
|
|
|
int origindex);
|
|
|
|
|
|
|
|
|
|
void SchedulePolygons(int drawingmode);
|
|
|
|
|
|
|
|
|
|
/* vertex and polygon acces */
|
|
|
|
|
int NumVertices(RAS_IPolyMaterial* mat);
|
|
|
|
|
RAS_TexVert* GetVertex(unsigned int matid, unsigned int index);
|
|
|
|
|
|
|
|
|
|
int NumPolygons();
|
|
|
|
|
RAS_Polygon* GetPolygon(int num) const;
|
2008-09-19 12:05:45 +00:00
|
|
|
|
2008-09-19 14:15:36 +00:00
|
|
|
/* buckets */
|
|
|
|
|
virtual void AddMeshUser(void *clientobj);
|
|
|
|
|
virtual void UpdateBuckets(
|
|
|
|
|
void* clientobj,
|
|
|
|
|
double* oglmatrix,
|
|
|
|
|
bool useObjectColor,
|
|
|
|
|
const MT_Vector4& rgbavec,
|
|
|
|
|
bool visible,
|
|
|
|
|
bool culled);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-09-19 14:15:36 +00:00
|
|
|
void RemoveFromBuckets(void *clientobj);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-09-19 14:15:36 +00:00
|
|
|
/* colors */
|
|
|
|
|
void DebugColor(unsigned int abgr);
|
|
|
|
|
void SetVertexColor(RAS_IPolyMaterial* mat,MT_Vector4 rgba);
|
|
|
|
|
|
|
|
|
|
/* polygon sorting by Z for alpha */
|
|
|
|
|
void SortPolygons(RAS_MeshSlot& ms, const MT_Transform &transform);
|
2006-04-02 21:04:20 +00:00
|
|
|
|
2008-09-19 14:15:36 +00:00
|
|
|
/* for construction to find shared vertices */
|
|
|
|
|
struct SharedVertex {
|
|
|
|
|
RAS_DisplayArray *m_darray;
|
|
|
|
|
int m_offset;
|
|
|
|
|
};
|
2006-04-02 21:04:20 +00:00
|
|
|
|
2008-09-19 14:15:36 +00:00
|
|
|
vector<vector<SharedVertex> > m_sharedvertex_map;
|
2002-10-12 11:37:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif //__RAS_MESHOBJECT
|
2002-10-30 02:07:20 +00:00
|
|
|
|