CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

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

Generated for Crystal Space by doxygen 1.2.18