K3dGameData.h

Go to the documentation of this file.
00001 
00013 /***************************************************************************
00014  *   Copyright (C) 2007 by Jan Koci   *
00015  *   honza.koci@email.cz   *
00016  *   http://kengine.sourceforge.net/tutorial/
00017  *                                                                         *
00018  *   This program is free software; you can redistribute it and/or modify  *
00019  *   it under the terms of the GNU General Public License as published by  *
00020  *   the Free Software Foundation; either version 2 of the License, or     *
00021  *   (at your option) any later version.                                   *
00022  *                                                                         *
00023  *   This program is distributed in the hope that it will be useful,       *
00024  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00025  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00026  *   GNU General Public License for more details.                          *
00027  *                                                                         *
00028  *   You should have received a copy of the GNU General Public License     *
00029  *   along with this program; if not, write to the                         *
00030  *   Free Software Foundation, Inc.,                                       *
00031  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00032  ***************************************************************************/
00033 
00034 #pragma once
00035 
00036 #include "K3dSystemData.h"
00037 #include "K3dConfData.h"
00038 #include "K3dCameraData.h"
00039 #include "K3dLineData.h"
00040 #include "K3dSceneData.h"
00041 #include "K3dOptionsData.h"
00042 #include "K3dVertexData.h"
00043 #include "K3dPolyPlaneData.h"
00044 #include "K3dRayData.h"
00045 
00046 
00047 class K3dAddress
00048 {
00049                 TVoidArray m_tAddressArray;     
00050                 TVoidArray::iterator m_it;              
00051 
00052         public:
00053                 K3dAddress();
00054                 ~K3dAddress();
00055 
00056                 void AddAddress ( void* _pAddress );
00057                 void *GetAddress ( const int _iId );
00058                 int GetNumAddresses();
00059                 bool FindAddress ( void* _pAddress );
00060                 void DeleteAddress ( void* _pAddress );
00061                 void DeleteAddressArray();
00062                 void ShowAddressArray();
00063 };
00064 
00065 class K3dPlaneObj;
00066 class K3dPlane;
00067 class K3dVector2;
00068 class K3dVector3Obj;
00069 class K3dPolyObj;
00070 class K3dPoly;
00071 class K3dVertexObj;
00072 class K3dRay;
00073 class K3dRayObj;
00074 class K3dLineObj;
00075 class K3dColor3;
00076 class K3dColor4;
00077 class K3dMatrix;
00078 class K3dSphereObj;
00079 class K3dFaceObj;
00080 class K3dVorBsp;
00081 class K3dCutPoly;
00082 class K3dTriangle;
00083 class K3dTriangleObj;
00084 class K3dTriangulation;
00085 class K3dTimer;
00086 class K3dKeyMap;
00087 class K3dMouse;
00088 class K3dLua;
00089 class K3dIntrLinePlane;
00090 class K3dIntrLinePlane;
00091 class K3dBoxBuild;
00092 struct TVertsOnPlane;
00093 class K3dVorLeafObj;
00094 class K3dPolyPlane;
00095 class K3dTextureObj;
00096 class K3dBmpFontObj;
00097 class K2dImageObj;
00098 class K3dBlockObj;
00099 class K3dCameraObj;
00100 
00101 template <class _T> class K3dSafePointer
00102 {
00103                 K3dAddress m_kAddress;
00104         public:
00105                 K3dSafePointer() {}
00106                 ~K3dSafePointer() {}
00107 
00109                 _T* New()
00110                 {
00111                         _T* ptr = NULL;
00112                         try
00113                         {
00114                                 ptr = new _T;
00115                         }
00116                         catch ( ... )
00117                         {
00118                                 cerr << "Error -- K3dSafePointer::SafeNew() -- Pointer doesn`t allocated !!!" << endl;
00119                         }
00120                         // Add address to the array and set true (pointer to array)
00121                         m_kAddress.AddAddress ( ptr );
00122                         return ptr;
00123                 }
00124 
00126                 void Add ( _T* _ptr )
00127                 {
00128                         if ( _ptr != NULL )
00129                         {
00130                                 // Add address to the array and set false (simple pointer)
00131                                 m_kAddress.AddAddress ( _ptr );
00132                         }
00133                 }
00134 
00136                 _T* Delete ( _T* _ptr )
00137                 {
00138                         if ( _ptr != NULL )
00139                         {
00140                                 if ( m_kAddress.FindAddress ( _ptr ) )
00141                                 {
00142                                         delete _ptr;
00143                                         // Delete address from array
00144                                         m_kAddress.DeleteAddress ( _ptr );
00145                                         _ptr = NULL;
00146                                 }
00147                         }
00148                         return _ptr;
00149                 }
00150 
00152                 bool FindPointer ( _T* _ptr )
00153                 {
00154                         return m_kAddress.FindAddress ( _ptr );
00155                 }
00156 
00158                 _T* Get ( const int _iId )
00159                 {
00160                         return ( _T* ) m_kAddress.GetAddress ( _iId );
00161                 }
00162 
00164                 int GetNum()
00165                 {
00166                         return m_kAddress.GetNumAddresses();
00167                 }
00168 
00170                 int DeleteAll()
00171                 {
00172                         return m_kAddress.DeleteAddressArray();
00173                 }
00174 };
00175 
00176 class K3dGameData:
00177                         public K3dSystemData,
00178                         public K3dConfData,
00179                         public K3dOptionsData,
00180                         public K3dCameraData,
00181                         public K3dRayData,
00182                         public K3dSceneData
00183 {
00184                 K3dSafePointer<int> m_Int;
00185                 K3dSafePointer<K3dVector2> m_Vector2;
00186                 K3dSafePointer<K3dVector3Obj> m_Vector3;
00187                 K3dSafePointer<K3dPlaneObj> m_PlaneObj;
00188                 K3dSafePointer<K3dPlane> m_Plane;
00189                 K3dSafePointer<K3dPolyObj> m_PolyObj;
00190                 K3dSafePointer<K3dPoly> m_Poly;
00191                 K3dSafePointer<K3dVertexObj> m_VertexObj;
00192                 K3dSafePointer<K3dRay> m_Ray;
00193                 K3dSafePointer<K3dRayObj> m_RayObj;
00194                 K3dSafePointer<K3dLineObj> m_LineObj;
00195                 K3dSafePointer<K3dColor3> m_Color3;
00196                 K3dSafePointer<K3dColor4> m_Color4;
00197                 K3dSafePointer<K3dMatrix> m_Matrix;
00198                 K3dSafePointer<K3dSphereObj> m_SphereObj;
00199                 K3dSafePointer<K3dFaceObj> m_FaceObj;
00200                 K3dSafePointer<TIntArray> m_VertexArray;
00201                 K3dSafePointer<K3dVorBsp> m_VorBsp;
00202                 K3dSafePointer<K3dCutPoly> m_CutPoly;
00203                 K3dSafePointer<K3dTriangle> m_Triangle;
00204                 K3dSafePointer<K3dTriangleObj> m_TriangleObj;
00205                 K3dSafePointer<K3dTriangulation> m_Triangulation;
00206                 K3dSafePointer<K3dTimer> m_Timer;
00207                 K3dSafePointer<K3dKeyMap> m_KeyMap;
00208                 K3dSafePointer<K3dMouse> m_Mouse;
00209                 K3dSafePointer<K3dLua> m_Lua;
00210                 K3dSafePointer<K3dIntrLinePlane> m_IntrLinePlane;
00211                 K3dSafePointer<K3dBoxBuild> m_BoxBuild;
00212                 K3dSafePointer<TVertsOnPlane> m_PlaneVerts;
00213                 K3dSafePointer<K3dVorLeafObj> m_VorLeafObj;
00214                 K3dSafePointer<K3dPolyPlane> m_PolyPlane;
00215                 K3dSafePointer<K3dTextureObj> m_TextureObj;
00216                 K3dSafePointer<K3dBmpFontObj> m_BmpFontObj;
00217                 K3dSafePointer<K2dImageObj> m_2dImageObj;
00218                 K3dSafePointer<K3dBlockObj> m_BlockObj;
00219                 K3dSafePointer<K3dCameraObj> m_CameraObj;
00220 
00221 
00222         public:
00223                 K3dGameData ( void );
00224                 ~K3dGameData ( void );
00225 
00226                 K3dSafePointer<int> &GetIntSP()
00227                 {
00228                         return m_Int;
00229                 }
00230 
00231                 K3dSafePointer<K3dVector2> &GetVector2SP()
00232                 {
00233                         return m_Vector2;
00234                 }
00235 
00236                 K3dSafePointer<K3dVector3Obj> &GetVector3SP()
00237                 {
00238                         return m_Vector3;
00239                 }
00240 
00241                 K3dSafePointer<K3dPlaneObj> &GetPlaneObjSP()
00242                 {
00243                         return m_PlaneObj;
00244                 }
00245 
00246                 K3dSafePointer<K3dPolyObj> &GetPolyObjSP()
00247                 {
00248                         return m_PolyObj;
00249                 }
00250 
00251                 K3dSafePointer<K3dPoly> &GetPolySP()
00252                 {
00253                         return m_Poly;
00254                 }
00255 
00256                 K3dSafePointer<K3dVertexObj> &GetVertexObjSP()
00257                 {
00258                         return m_VertexObj;
00259                 }
00260 
00261                 K3dSafePointer<K3dRay> &GetRaySP()
00262                 {
00263                         return m_Ray;
00264                 }
00265 
00266                 K3dSafePointer<K3dRayObj> &GetRayObjSP()
00267                 {
00268                         return m_RayObj;
00269                 }
00270 
00271                 K3dSafePointer<K3dLineObj> &GetLineObjSP()
00272                 {
00273                         return m_LineObj;
00274                 }
00275 
00276                 K3dSafePointer<K3dColor3> &GetColor3SP()
00277                 {
00278                         return m_Color3;
00279                 }
00280 
00281                 K3dSafePointer<K3dColor4> &GetColor4SP()
00282                 {
00283                         return m_Color4;
00284                 }
00285 
00286                 K3dSafePointer<K3dMatrix> &GetMatrixSP()
00287                 {
00288                         return m_Matrix;
00289                 }
00290 
00291                 K3dSafePointer<K3dSphereObj> &GetSphereObjSP()
00292                 {
00293                         return m_SphereObj;
00294                 }
00295 
00296                 K3dSafePointer<K3dFaceObj> &GetFaceObjSP()
00297                 {
00298                         return m_FaceObj;
00299                 }
00300 
00301                 K3dSafePointer<TIntArray> &GetVertexArraySP()
00302                 {
00303                         return m_VertexArray;
00304                 }
00305 
00306                 K3dSafePointer<K3dVorBsp> &GetVorBspSP()
00307                 {
00308                         return m_VorBsp;
00309                 }
00310 
00311                 K3dSafePointer<K3dCutPoly> &GetCutPolySP()
00312                 {
00313                         return m_CutPoly;
00314                 }
00315 
00316                 K3dSafePointer<K3dTriangle> &GetTriangleSP()
00317                 {
00318                         return m_Triangle;
00319                 }
00320 
00321                 K3dSafePointer<K3dTriangleObj> &GetTriangleObjSP()
00322                 {
00323                         return m_TriangleObj;
00324                 }
00325 
00326                 K3dSafePointer<K3dTriangulation> &GetTriangulationSP()
00327                 {
00328                         return m_Triangulation;
00329                 }
00330 
00331                 K3dSafePointer<K3dTimer> &GetTimerSP()
00332                 {
00333                         return m_Timer;
00334                 }
00335 
00336                 K3dSafePointer<K3dKeyMap> &GetKeyMapSP()
00337                 {
00338                         return m_KeyMap;
00339                 }
00340 
00341                 K3dSafePointer<K3dMouse> &GetMouseSP()
00342                 {
00343                         return m_Mouse;
00344                 }
00345 
00346                 K3dSafePointer<K3dLua> &GetLuaSP()
00347                 {
00348                         return m_Lua;
00349                 }
00350 
00351                 K3dSafePointer<K3dIntrLinePlane> &GetIntrLinePlaneSP()
00352                 {
00353                         return m_IntrLinePlane;
00354                 }
00355 
00356                 K3dSafePointer<K3dBoxBuild> &GetBoxBuildSP()
00357                 {
00358                         return m_BoxBuild;
00359                 }
00360 
00361                 K3dSafePointer<TVertsOnPlane> &GetPlaneVertsSP()
00362                 {
00363                         return m_PlaneVerts;
00364                 }
00365 
00366                 K3dSafePointer<K3dVorLeafObj> &GetVorLeafObjSP()
00367                 {
00368                         return m_VorLeafObj;
00369                 }
00370 
00371                 K3dSafePointer<K3dPolyPlane> &GetPolyPlaneSP()
00372                 {
00373                         return m_PolyPlane;
00374                 }
00375 
00376                 K3dSafePointer<K3dTextureObj> &GetTextureObjSP()
00377                 {
00378                         return m_TextureObj;
00379                 }
00380 
00381                 K3dSafePointer<K3dBmpFontObj> &GetBmpFontObjSP()
00382                 {
00383                         return m_BmpFontObj;
00384                 }
00385 
00386                 K3dSafePointer<K2dImageObj> &Get2dImageObjSP()
00387                 {
00388                         return m_2dImageObj;
00389                 }
00390 
00391                 K3dSafePointer<K3dBlockObj> &GetBlockObjSP()
00392                 {
00393                         return m_BlockObj;
00394                 }
00395 
00396                 K3dSafePointer<K3dCameraObj> &GetCameraObjSP()
00397                 {
00398                         return m_CameraObj;
00399                 }
00400 };
00401 
00402 

Generated on Thu Aug 16 23:53:28 2007 for K3dEngine by  doxygen 1.5.0