Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | 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 "imesh/mdldata.h" 00025 #include "csutil/dirtyaccessarray.h" 00026 #include "csutil/csobject.h" 00027 #include "csutil/refarr.h" 00028 00029 #define CS_DECLARE_ACCESSOR_METHODS(type,name) \ 00030 type Get##name () const; \ 00031 void Set##name (type) 00032 00033 #define CS_DECLARE_ARRAY_INTERFACE_NONUM(type,sing_name) \ 00034 type Get##sing_name (size_t n) const; \ 00035 void Set##sing_name (size_t n, type) 00036 00037 #define CS_DECLARE_ARRAY_INTERFACE(type,sing_name) \ 00038 CS_DECLARE_ARRAY_INTERFACE_NONUM (type, sing_name); \ 00039 size_t Get##sing_name##Count () const; \ 00040 size_t Add##sing_name (type obj); \ 00041 void Delete##sing_name (size_t n) 00042 00043 #define CS_DECLARE_OBJECT_INTERFACE \ 00044 CS_DECLARE_EMBEDDED_OBJECT (csObject, iObject); \ 00045 iObject *QueryObject () 00046 00051 #define CS_DECLARE_EMBEDDED_OBJECT(clname,itf) \ 00052 struct Embedded_##clname : public clname { \ 00053 typedef clname __scf_superclass__; \ 00054 SCF_DECLARE_EMBEDDED_IBASE (iBase); \ 00055 } scf##itf 00056 00061 #define CS_IMPLEMENT_EMBEDDED_OBJECT(Class) \ 00062 SCF_IMPLEMENT_EMBEDDED_IBASE_INCREF (Class); \ 00063 SCF_IMPLEMENT_EMBEDDED_IBASE_DECREF (Class); \ 00064 SCF_IMPLEMENT_EMBEDDED_IBASE_GETREFCOUNT (Class); \ 00065 SCF_IMPLEMENT_EMBEDDED_IBASE_REFOWNER (Class); \ 00066 SCF_IMPLEMENT_EMBEDDED_IBASE_QUERY (Class); \ 00067 void *o = __scf_superclass__::QueryInterface (iInterfaceID, iVersion); \ 00068 if (o) return o; \ 00069 SCF_IMPLEMENT_EMBEDDED_IBASE_QUERY_END 00070 00071 typedef csRefArray<iObject> csObjectVector; 00072 00073 class csIntArray; 00074 00075 //---------------------------------------------------------------------------- 00076 00078 class CS_CSTOOL_EXPORT csModelDataTexture : public iModelDataTexture 00079 { 00080 private: 00081 char *FileName; 00082 csRef<iImage> Image; 00083 csRef<iTextureWrapper> TextureWrapper; 00084 00085 public: 00086 SCF_DECLARE_IBASE; 00087 CS_DECLARE_OBJECT_INTERFACE; 00088 00090 csModelDataTexture (); 00092 virtual ~csModelDataTexture (); 00093 00095 void SetFileName (const char *fn); 00097 const char *GetFileName () const; 00098 00099 CS_DECLARE_ACCESSOR_METHODS (iImage*, Image); 00100 CS_DECLARE_ACCESSOR_METHODS (iTextureWrapper*, TextureWrapper); 00101 00107 void LoadImage (iVFS *VFS, iImageIO *ImageIO, int Format); 00108 00110 void Register (iTextureList *tl); 00111 00112 iModelDataTexture *Clone () const; 00113 }; 00114 00116 class CS_CSTOOL_EXPORT csModelDataMaterial : public iModelDataMaterial 00117 { 00118 private: 00119 csRef<iMaterial> BaseMaterial; 00120 csRef<iMaterialWrapper> MaterialWrapper; 00121 00122 public: 00123 SCF_DECLARE_IBASE; 00124 CS_DECLARE_OBJECT_INTERFACE; 00125 00127 csModelDataMaterial (); 00129 virtual ~csModelDataMaterial (); 00130 00131 CS_DECLARE_ACCESSOR_METHODS (iMaterial*, BaseMaterial); 00132 CS_DECLARE_ACCESSOR_METHODS (iMaterialWrapper*, MaterialWrapper); 00133 00135 void Register (iMaterialList *ml); 00136 00137 iModelDataMaterial *Clone () const; 00138 }; 00139 00141 class CS_CSTOOL_EXPORT csModelDataVertices : public iModelDataVertices 00142 { 00143 private: 00144 csDirtyAccessArray<csVector3> Vertices; 00145 csDirtyAccessArray<csVector3> Normals; 00146 csDirtyAccessArray<csColor> Colors; 00147 csDirtyAccessArray<csVector2> Texels; 00148 00149 public: 00150 SCF_DECLARE_IBASE; 00151 CS_DECLARE_OBJECT_INTERFACE; 00152 00154 csModelDataVertices (); 00156 csModelDataVertices (const iModelDataVertices *orig1, 00157 const iModelDataVertices *orig2); 00159 virtual ~csModelDataVertices(); 00160 00162 void CopyFrom (const iModelDataVertices *Other); 00163 00164 CS_DECLARE_ARRAY_INTERFACE (const csVector3 &, Vertex); 00165 CS_DECLARE_ARRAY_INTERFACE (const csVector3 &, Normal); 00166 CS_DECLARE_ARRAY_INTERFACE (const csColor &, Color); 00167 CS_DECLARE_ARRAY_INTERFACE (const csVector2 &, Texel); 00168 virtual size_t FindVertex (const csVector3 &v) const; 00169 virtual size_t FindNormal (const csVector3 &v) const; 00170 virtual size_t FindColor (const csColor &v) const; 00171 virtual size_t FindTexel (const csVector2 &v) const; 00172 00173 iModelDataVertices *Clone () const; 00174 }; 00175 00177 class CS_CSTOOL_EXPORT csModelDataAction : public iModelDataAction 00178 { 00179 private: 00180 csDirtyAccessArray<float> Times; 00181 csObjectVector States; 00182 00183 public: 00184 SCF_DECLARE_IBASE; 00185 CS_DECLARE_OBJECT_INTERFACE; 00186 00188 csModelDataAction (); 00190 virtual ~csModelDataAction (); 00191 00193 virtual size_t GetFrameCount () const; 00195 virtual float GetTime (size_t Frame) const; 00197 virtual iObject *GetState (size_t Frame) const; 00199 virtual void SetTime (size_t Frame, float NewTime); 00201 virtual void SetState (size_t Frame, iObject *State); 00203 virtual void AddFrame (float Time, iObject *State); 00205 virtual void DeleteFrame (size_t Frame); 00207 virtual float GetTotalTime () const; 00208 }; 00209 00211 class CS_CSTOOL_EXPORT csModelDataPolygon : public iModelDataPolygon 00212 { 00213 private: 00214 csDirtyAccessArray<int> Vertices; 00215 csDirtyAccessArray<int> Normals; 00216 csDirtyAccessArray<int> Colors; 00217 csDirtyAccessArray<int> Texels; 00218 iModelDataMaterial *Material; 00219 00220 public: 00221 SCF_DECLARE_IBASE; 00222 CS_DECLARE_OBJECT_INTERFACE; 00223 00225 csModelDataPolygon (); 00227 virtual ~csModelDataPolygon (); 00228 00230 size_t AddVertex (int ver, int nrm, int col, int tex); 00232 size_t GetVertexCount () const; 00234 void DeleteVertex (size_t n); 00235 00236 CS_DECLARE_ARRAY_INTERFACE_NONUM (int, Vertex); 00237 CS_DECLARE_ARRAY_INTERFACE_NONUM (int, Normal); 00238 CS_DECLARE_ARRAY_INTERFACE_NONUM (int, Color); 00239 CS_DECLARE_ARRAY_INTERFACE_NONUM (int, Texel); 00240 CS_DECLARE_ACCESSOR_METHODS (iModelDataMaterial*, Material); 00241 00242 iModelDataPolygon *Clone () const; 00243 }; 00244 00246 class CS_CSTOOL_EXPORT csModelDataObject : public iModelDataObject 00247 { 00248 private: 00249 csRef<iModelDataVertices> DefaultVertices; 00250 00251 public: 00252 SCF_DECLARE_IBASE; 00253 CS_DECLARE_OBJECT_INTERFACE; 00254 00256 csModelDataObject (); 00258 virtual ~csModelDataObject(); 00259 00260 CS_DECLARE_ACCESSOR_METHODS (iModelDataVertices*, DefaultVertices); 00261 }; 00262 00264 class CS_CSTOOL_EXPORT csModelDataCamera : public iModelDataCamera 00265 { 00266 private: 00267 csVector3 Position, UpVector, FrontVector, RightVector; 00268 00269 public: 00270 SCF_DECLARE_IBASE; 00271 CS_DECLARE_OBJECT_INTERFACE; 00272 00274 csModelDataCamera (); 00275 // Destructor 00276 virtual ~csModelDataCamera (); 00277 00278 CS_DECLARE_ACCESSOR_METHODS (const csVector3 &, Position); 00279 CS_DECLARE_ACCESSOR_METHODS (const csVector3 &, UpVector); 00280 CS_DECLARE_ACCESSOR_METHODS (const csVector3 &, FrontVector); 00281 CS_DECLARE_ACCESSOR_METHODS (const csVector3 &, RightVector); 00282 00284 void ComputeUpVector (); 00286 void ComputeFrontVector (); 00288 void ComputeRightVector (); 00289 00291 void Normalize (); 00293 bool CheckOrthogonality () const; 00294 00295 iModelDataCamera *Clone () const; 00296 }; 00297 00299 class CS_CSTOOL_EXPORT csModelDataLight : public iModelDataLight 00300 { 00301 private: 00302 float Radius; 00303 csColor Color; 00304 csVector3 Position; 00305 00306 public: 00307 SCF_DECLARE_IBASE; 00308 CS_DECLARE_OBJECT_INTERFACE; 00309 00311 csModelDataLight (); 00312 // Destructor 00313 virtual ~csModelDataLight (); 00314 00315 CS_DECLARE_ACCESSOR_METHODS (float, Radius); 00316 CS_DECLARE_ACCESSOR_METHODS (const csVector3 &, Position); 00317 CS_DECLARE_ACCESSOR_METHODS (const csColor &, Color); 00318 iModelDataLight *Clone () const; 00319 }; 00320 00321 class CS_CSTOOL_EXPORT csModelData : public iModelData 00322 { 00323 public: 00324 SCF_DECLARE_IBASE; 00325 CS_DECLARE_OBJECT_INTERFACE; 00326 00328 csModelData (); 00330 virtual ~csModelData (); 00331 00333 void LoadImages (iVFS *VFS, iImageIO *il, int Format); 00335 void RegisterTextures (iTextureList *tl); 00337 void RegisterMaterials (iMaterialList *ml); 00338 }; 00339 00340 #endif // __CS_MDLDATA_H__
Generated for Crystal Space by doxygen 1.3.9.1