Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages
mdldata.h
00001 /* 00002 Copyright (C) 2001 by Martin Geisse <mgeisse@gmx.net> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public 00015 License along with this library; if not, write to the Free 00016 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 00019 #ifndef __CS_MDLDATA_H__ 00020 #define __CS_MDLDATA_H__ 00021 00022 #include "csextern.h" 00023 00024 #include "csgeom/vector3.h" 00025 #include "csutil/cscolor.h" 00026 #include "csutil/csobject.h" 00027 #include "csutil/dirtyaccessarray.h" 00028 #include "csutil/refarr.h" 00029 00030 #include "imesh/mdldata.h" 00031 00032 #define CS_DECLARE_ACCESSOR_METHODS(type,name) \ 00033 type Get##name () const; \ 00034 void Set##name (type) 00035 00036 #define CS_DECLARE_ARRAY_INTERFACE_NONUM(type,sing_name) \ 00037 type Get##sing_name (size_t n) const; \ 00038 void Set##sing_name (size_t n, type) 00039 00040 #define CS_DECLARE_ARRAY_INTERFACE(type,sing_name) \ 00041 CS_DECLARE_ARRAY_INTERFACE_NONUM (type, sing_name); \ 00042 size_t Get##sing_name##Count () const; \ 00043 size_t Add##sing_name (type obj); \ 00044 void Delete##sing_name (size_t n) 00045 00046 #define CS_DECLARE_OBJECT_INTERFACE \ 00047 CS_DECLARE_EMBEDDED_OBJECT (csObject, iObject); \ 00048 iObject *QueryObject () 00049 00054 #define CS_DECLARE_EMBEDDED_OBJECT(clname,itf) \ 00055 struct Embedded_##clname : public clname { \ 00056 typedef clname __scf_superclass__; \ 00057 SCF_DECLARE_EMBEDDED_IBASE (iBase); \ 00058 } scf##itf 00059 00064 #define CS_IMPLEMENT_EMBEDDED_OBJECT(Class) \ 00065 SCF_IMPLEMENT_EMBEDDED_IBASE_INCREF (Class) \ 00066 SCF_IMPLEMENT_EMBEDDED_IBASE_DECREF (Class) \ 00067 SCF_IMPLEMENT_EMBEDDED_IBASE_GETREFCOUNT (Class) \ 00068 SCF_IMPLEMENT_EMBEDDED_IBASE_REFOWNER (Class) \ 00069 SCF_IMPLEMENT_EMBEDDED_IBASE_QUERY (Class) \ 00070 void *o = __scf_superclass__::QueryInterface (iInterfaceID, iVersion); \ 00071 if (o) return o; \ 00072 SCF_IMPLEMENT_EMBEDDED_IBASE_QUERY_END 00073 00074 typedef csRefArray<iObject> csObjectVector; 00075 00076 class csIntArray; 00077 00078 //---------------------------------------------------------------------------- 00079 00081 class CS_CRYSTALSPACE_EXPORT csModelDataTexture : public iModelDataTexture 00082 { 00083 private: 00084 char *FileName; 00085 csRef<iImage> Image; 00086 csRef<iTextureWrapper> TextureWrapper; 00087 00088 public: 00089 SCF_DECLARE_IBASE; 00090 CS_DECLARE_OBJECT_INTERFACE; 00091 00093 csModelDataTexture (); 00095 virtual ~csModelDataTexture (); 00096 00098 void SetFileName (const char *fn); 00100 const char *GetFileName () const; 00101 00102 CS_DECLARE_ACCESSOR_METHODS (iImage*, Image); 00103 CS_DECLARE_ACCESSOR_METHODS (iTextureWrapper*, TextureWrapper); 00104 00110 void LoadImage (iVFS *VFS, iImageIO *ImageIO, int Format); 00111 00113 void Register (iTextureList *tl); 00114 00115 iModelDataTexture *Clone () const; 00116 }; 00117 00119 class CS_CRYSTALSPACE_EXPORT csModelDataMaterial : public iModelDataMaterial 00120 { 00121 private: 00122 csRef<iMaterial> BaseMaterial; 00123 csRef<iMaterialWrapper> MaterialWrapper; 00124 00125 public: 00126 SCF_DECLARE_IBASE; 00127 CS_DECLARE_OBJECT_INTERFACE; 00128 00130 csModelDataMaterial (); 00132 virtual ~csModelDataMaterial (); 00133 00134 CS_DECLARE_ACCESSOR_METHODS (iMaterial*, BaseMaterial); 00135 CS_DECLARE_ACCESSOR_METHODS (iMaterialWrapper*, MaterialWrapper); 00136 00138 void Register (iMaterialList *ml); 00139 00140 iModelDataMaterial *Clone () const; 00141 }; 00142 00144 class CS_CRYSTALSPACE_EXPORT csModelDataVertices : public iModelDataVertices 00145 { 00146 private: 00147 csDirtyAccessArray<csVector3> Vertices; 00148 csDirtyAccessArray<csVector3> Normals; 00149 csDirtyAccessArray<csColor> Colors; 00150 csDirtyAccessArray<csVector2> Texels; 00151 00152 public: 00153 SCF_DECLARE_IBASE; 00154 CS_DECLARE_OBJECT_INTERFACE; 00155 00157 csModelDataVertices (); 00159 csModelDataVertices (const iModelDataVertices *orig1, 00160 const iModelDataVertices *orig2); 00162 virtual ~csModelDataVertices(); 00163 00165 void CopyFrom (const iModelDataVertices *Other); 00166 00167 CS_DECLARE_ARRAY_INTERFACE (const csVector3 &, Vertex); 00168 CS_DECLARE_ARRAY_INTERFACE (const csVector3 &, Normal); 00169 CS_DECLARE_ARRAY_INTERFACE (const csColor &, Color); 00170 CS_DECLARE_ARRAY_INTERFACE (const csVector2 &, Texel); 00171 virtual size_t FindVertex (const csVector3 &v) const; 00172 virtual size_t FindNormal (const csVector3 &v) const; 00173 virtual size_t FindColor (const csColor &v) const; 00174 virtual size_t FindTexel (const csVector2 &v) const; 00175 00176 iModelDataVertices *Clone () const; 00177 }; 00178 00180 class CS_CRYSTALSPACE_EXPORT csModelDataAction : public iModelDataAction 00181 { 00182 private: 00183 csDirtyAccessArray<float> Times; 00184 csObjectVector States; 00185 00186 public: 00187 SCF_DECLARE_IBASE; 00188 CS_DECLARE_OBJECT_INTERFACE; 00189 00191 csModelDataAction (); 00193 virtual ~csModelDataAction (); 00194 00196 virtual size_t GetFrameCount () const; 00198 virtual float GetTime (size_t Frame) const; 00200 virtual iObject *GetState (size_t Frame) const; 00202 virtual void SetTime (size_t Frame, float NewTime); 00204 virtual void SetState (size_t Frame, iObject *State); 00206 virtual void AddFrame (float Time, iObject *State); 00208 virtual void DeleteFrame (size_t Frame); 00210 virtual float GetTotalTime () const; 00211 }; 00212 00214 class CS_CRYSTALSPACE_EXPORT csModelDataPolygon : public iModelDataPolygon 00215 { 00216 private: 00217 csDirtyAccessArray<int> Vertices; 00218 csDirtyAccessArray<int> Normals; 00219 csDirtyAccessArray<int> Colors; 00220 csDirtyAccessArray<int> Texels; 00221 iModelDataMaterial *Material; 00222 00223 public: 00224 SCF_DECLARE_IBASE; 00225 CS_DECLARE_OBJECT_INTERFACE; 00226 00228 csModelDataPolygon (); 00230 virtual ~csModelDataPolygon (); 00231 00233 size_t AddVertex (int ver, int nrm, int col, int tex); 00235 size_t GetVertexCount () const; 00237 void DeleteVertex (size_t n); 00238 00239 CS_DECLARE_ARRAY_INTERFACE_NONUM (int, Vertex); 00240 CS_DECLARE_ARRAY_INTERFACE_NONUM (int, Normal); 00241 CS_DECLARE_ARRAY_INTERFACE_NONUM (int, Color); 00242 CS_DECLARE_ARRAY_INTERFACE_NONUM (int, Texel); 00243 CS_DECLARE_ACCESSOR_METHODS (iModelDataMaterial*, Material); 00244 00245 iModelDataPolygon *Clone () const; 00246 }; 00247 00249 class CS_CRYSTALSPACE_EXPORT csModelDataObject : public iModelDataObject 00250 { 00251 private: 00252 csRef<iModelDataVertices> DefaultVertices; 00253 00254 public: 00255 SCF_DECLARE_IBASE; 00256 CS_DECLARE_OBJECT_INTERFACE; 00257 00259 csModelDataObject (); 00261 virtual ~csModelDataObject(); 00262 00263 CS_DECLARE_ACCESSOR_METHODS (iModelDataVertices*, DefaultVertices); 00264 }; 00265 00267 class CS_CRYSTALSPACE_EXPORT csModelDataCamera : public iModelDataCamera 00268 { 00269 private: 00270 csVector3 Position, UpVector, FrontVector, RightVector; 00271 00272 public: 00273 SCF_DECLARE_IBASE; 00274 CS_DECLARE_OBJECT_INTERFACE; 00275 00277 csModelDataCamera (); 00278 // Destructor 00279 virtual ~csModelDataCamera (); 00280 00281 CS_DECLARE_ACCESSOR_METHODS (const csVector3 &, Position); 00282 CS_DECLARE_ACCESSOR_METHODS (const csVector3 &, UpVector); 00283 CS_DECLARE_ACCESSOR_METHODS (const csVector3 &, FrontVector); 00284 CS_DECLARE_ACCESSOR_METHODS (const csVector3 &, RightVector); 00285 00287 void ComputeUpVector (); 00289 void ComputeFrontVector (); 00291 void ComputeRightVector (); 00292 00294 void Normalize (); 00296 bool CheckOrthogonality () const; 00297 00298 iModelDataCamera *Clone () const; 00299 }; 00300 00302 class CS_CRYSTALSPACE_EXPORT csModelDataLight : public iModelDataLight 00303 { 00304 private: 00305 float Radius; 00306 csColor Color; 00307 csVector3 Position; 00308 00309 public: 00310 SCF_DECLARE_IBASE; 00311 CS_DECLARE_OBJECT_INTERFACE; 00312 00314 csModelDataLight (); 00315 // Destructor 00316 virtual ~csModelDataLight (); 00317 00318 CS_DECLARE_ACCESSOR_METHODS (float, Radius); 00319 CS_DECLARE_ACCESSOR_METHODS (const csVector3 &, Position); 00320 CS_DECLARE_ACCESSOR_METHODS (const csColor &, Color); 00321 iModelDataLight *Clone () const; 00322 }; 00323 00324 class CS_CRYSTALSPACE_EXPORT csModelData : public iModelData 00325 { 00326 public: 00327 SCF_DECLARE_IBASE; 00328 CS_DECLARE_OBJECT_INTERFACE; 00329 00331 csModelData (); 00333 virtual ~csModelData (); 00334 00336 void LoadImages (iVFS *VFS, iImageIO *il, int Format); 00338 void RegisterTextures (iTextureList *tl); 00340 void RegisterMaterials (iMaterialList *ml); 00341 }; 00342 00343 #endif // __CS_MDLDATA_H__
Generated for Crystal Space by doxygen 1.4.4