changed copyright years in source files
[fegdk.git] / core / code / video / f_model.h
blobbe049bc4096232c2c326d1f1706c19772d93e42d
1 /*
2 fegdk: FE Game Development Kit
3 Copyright (C) 2001-2008 Alexey "waker" Yakovenko
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 Alexey Yakovenko
20 waker@users.sourceforge.net
23 #ifndef __F_MODEL_H
24 #define __F_MODEL_H
26 #include "f_types.h"
27 #include "f_math.h"
28 #include "f_parser.h"
29 #include "f_sceneobject.h"
30 #include "f_material.h"
32 namespace fe
35 class baseTexture;
36 class file;
37 class lightSource;
39 struct silEdge_t
41 ushort f1, f2; // faces forming the edge
42 ushort v1, v2; // verts forming the edge
45 struct shadowVertex_t
47 vector4 xyzw;
50 struct modelTriangles_t
52 // this stuff is loaded externally
53 int32 numVerts;
54 drawVertex_t* verts;
55 int32 numIndexes;
56 ushort* indexes;
58 // this stuff is build load-time
59 // char* mtlIndexes;
60 ushort* silIndexes; // not using duplicated verts (ignoring texcoords, etc)
61 plane* facePlanes;
62 int32 numSilEdges;
63 silEdge_t* silEdges; // size must be at least [numVerts*2] (not including duplicates)
64 // FIXME find a way to cache results for static light/mesh combos
66 shadowVertex_t *shadowVerts; // this is NULL when using vertex shaders
67 int32 numShadowVolumeIndexes;
68 ushort* shadowVolumeIndexes; // size at least equal to silEdges
69 int32 numDupVerts;
70 ushort* dupVerts; // pairs {vertex, dupvertex}
73 struct modelSubset_t
75 modelTriangles_t* tris;
76 int32 firstVertex;
77 int32 firstFace;
78 int32 numVerts;
79 int32 numFaces;
80 materialPtr mtl;
81 baseTexturePtr lightmap;
84 // class modelData;
85 class mtlBlock;
87 class FE_API model : public geomSource
89 friend class modelData;
90 protected:
92 // !!! moved to meshData_t !!! (see geomSource)
93 // unsigned mbLightmaps : 1;
94 // unsigned mbTangents : 1;
95 // unsigned mbColors : 1;
96 // modelTriangles_t mTris;
97 // std::vector <modelSubset_t> mSurfaces;
98 private:
100 // smartPtr <modelData> mpData;
102 sceneObject* load (file *f, mtlBlock *mtls = NULL, sceneObject *parent = NULL);
105 * @brief builds all data which is not being loaded from file/memory storage.
106 * @brief initializes mTris, obb, builds tangents, etc.
108 void init (void);
110 public:
112 model (void);
113 sceneObject* load (const char *fname);
114 void loadMesh (file *f, int majorver, int minorver, std::vector <materialPtr> &mtls, int numSubsets, renderable *rend);
116 ~model (void);
119 * @brief ctor used to create model from data in memory.
120 * @brief may be used for e.g. procedural geometry or testing purposes
121 * @brief which require better performance
122 * @param verts vertices
123 * @param inds indexes
124 * @param subs subsets
125 * @parms mtls material list, used in creation of mtlBlock
127 // model (const char *name, model *parent, const matrix4 &mtx, const std::vector <drawVertex_t> &verts, std::vector <ushort> &inds, const std::vector <modelSubset_t> &subs, const std::vector <materialPtr> &mtls);
131 typedef smartPtr <model> modelPtr;
135 #endif // __F_MODEL_H