Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

cybworldc.h

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 1999-2003  Carsten Winkelholz, Malte Weiß
00003 
00004 Malte Weiß, 09.04.2003: Added pointer for font manager.
00005 
00006 Address:  FGAN Forschungsgesellschaft fuer Angewandte Naturwissenschaften e. V.
00007       Neuenahrer Str. 20
00008       D - 53343 Wachtberg
00009       
00010 Email:    winkelholz@fgan.de
00011 
00012 This program is free software; you can redistribute it and/or
00013 modify it under the terms of the GNU General Public License
00014 as published by the Free Software Foundation; either version 2
00015 of the License, or (at your option) any later version.
00016 
00017 This program is distributed in the hope that it will be useful,
00018 but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 GNU General Public License for more details.
00021 
00022 You should have received a copy of the GNU General Public License
00023 along with this program; if not, write to the Free Software
00024 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00025 */
00026 
00027 
00028 #ifndef CYBWORLD_HC
00029 #define CYBWORLD_HC
00030 
00031 
00032 #include "oaw/misc/matrixc.h"
00033 #include "oaw/ctk/cybnodec.h"
00034 #include "oaw/ctk/cybtransformc.h"
00035 #include "oaw/misc/modelc.h"
00036 #include "oaw/misc/vectorc.h"
00037 #include "oaw/misc/stringc.h"
00038 #include "oaw/misc/arrayc.h"
00039 #include "oaw/misc/urlc.h"
00040 #include "oaw/misc/timec.h"
00041 #include "oaw/pdtk/dismodelc.h"
00042 #include "oaw/ctk/cybinterfacec.h"
00043 #include "oaw/ctk/cybwrlfields.h"
00044 #include "oaw/ctk/cybviewpointc.h"
00045 #include "oaw/ctk/cybtexturec.h"
00046 #include "oaw/ctk/ctkutils.h"
00047 #include "oaw/misc/mapc.h"
00048 #include "../oawconfig.h"
00049 
00050 
00051 OAW_BEGIN_NAMESPACE
00052 
00053 
00054 //#define TRUE 1
00055 //#define FALSE 0
00056 
00057 class CybGLViewC;
00058 class CybViewC;
00059 class CybChannelC;
00060 class CybNodeC;
00061 class CybTimeSensorC;
00062 class CybTimeC;
00063 class CybViewpointSensorC;
00064 class CybSixDOFSensorC;
00065 class CybProtoC;
00066 class CybViewpointC;
00067 class CybPointingDeviceC;
00068 class CybScriptC;
00069 class CybUserC;
00070 class CybProxyC;
00071 class CybFogC;
00072 class CybBackgroundC;
00073 class CybTextureManagerC;
00074 class CybSoundManagerC;
00075 class CybFontManagerC;
00076 class CybSoundC;
00077 class CybJSEngineC;
00078 
00079 struct FV_DataStruct{
00080   float* data;
00081   long len;
00082 };
00083 
00084 
00085 struct LV_DataStruct{
00086   long* data;
00087   long len;
00088 };
00089 
00090 
00091 struct Pixelmap_DataStruct{
00092   unsigned char* pixel;
00093   long width;
00094   long height;
00095   long channel;
00096 };
00097 
00098 class DefUseC
00099 {
00100 public:
00101   DefUseC(){pRef=0;}
00102   int operator == (const DefUseC&);
00103 public:
00104   StringC DefName;
00105   CybNodeC* pRef;
00106 };
00107 
00108 typedef KetteC<StringC> StringListC ;
00109 
00110 
00112 // cybworldc.h : interface of the CybWorldC class  //////
00114 
00115 class OAW_DLLMAPPING CybWorldC : public DisModelC, public SharedObjectC
00116 {
00117   friend class CybShapeC;
00118   friend class CybViewpointC;
00119 public:
00120   struct IsectResultS{
00121     SFVec3f hitPoint;
00122     SFFloat hitMinZ;
00123     CybNodeC* pNode;
00124     SFInt32 nodeType;
00125   };
00126   CybWorldC();
00127   virtual ~CybWorldC();
00128   inline CybGroupC* GetGroup() const {return m_pGroup;}
00129   virtual void* GetImpl(){return this;}
00130   inline virtual SFVec3f GetScale()const{ return m_pGroup->GetScale(); }
00131 
00132 
00133   virtual void LoadFromFile(const StringC&);
00134   virtual void Unload();
00135   virtual void* Malloc(long);
00136   virtual void* Realloc(void *buf, long size);
00137   virtual void Free(void*);
00138   virtual short isectSceneWithNode(SFNode*, IsectResultS&){return 0;}
00139 
00140   virtual void Update();
00141   virtual void UpdateAllViews(int);
00142   virtual void FinishInit();
00143 
00144   virtual void ToChannel(CybChannelC*,long);
00145 
00146   virtual void SetEventBroker(EventBrokerC*);
00147   virtual void AddInterface(const StringC&, InterfaceC*);
00148   virtual void AddSensor(CybSensorC*);
00149   virtual void AddPointingDevice(CybPointingDeviceC*);
00150   virtual void RemoveInterface(InterfaceC*);
00151 
00152   virtual CybNodeC* CreateNode(long);
00153   virtual void LoadVRML(char*&, const char*,long&);
00154 
00155   virtual void TravApp();
00156 
00157   //void InlineNodeLoadBegin();
00158   //void InlineNodeLoadEnd();
00159   void ProtoLoadBegin(CybProtoC*);
00160   void ProtoLoadEnd(CybProtoC*);
00161   void ProtoCreateBegin(CybProtoC*);
00162   void ProtoCreateEnd(CybProtoC*);
00163   CybProtoC* GetCurrentProto();
00164   
00165   bool CreateRoute(const StringC&,const StringC&,const StringC&,const StringC&);
00166   
00167   StringC GetDefNodeName(CybNodeC*);
00168   CybNodeC* GetDefNode(const StringC&);
00169   void DefineNode(CybNodeC*, const StringC&);
00170   //void UndefineNode(CybNodeC*);
00171 
00172   NodeInfo *GetNodeInfo(const StringC& strName);
00173   
00174   ArrayC<CybNodeC*> CreateVrmlFromString(const char*);
00175   const char* GetWrlMainUrl();
00176   const StringC& GetHomePath();
00177   const StringC& GetCurrentFilepath();
00178   const StringC& GetCurrentFilename();
00179   void ChangeToAbsUrlPath(MFString& urlList);
00180   void SetCurrentFilename(const StringC&);
00181 
00182   inline CybViewpointSensorC* GetViewpointSensor(){return m_pViewpointSensor;}
00183   void SetViewpointSensor(CybViewpointSensorC* p){m_pViewpointSensor = p;}
00184   CybUserC* GetUser();
00185   void SetUser(CybUserC*);
00186 
00187   VectorC GetViewpointPosA();
00188   VectorC GetViewpointNormA();
00189   double GetViewpointRolA();
00190   
00191   const CybViewpointC* GetActiveViewpoint(){return m_pActiveViewpoint;}
00192   short SetActiveViewpoint(long n);
00193 
00194   // Fog control
00195   void AddFog(CybFogC *pFog);           
00196   // Set active fog for rendering
00197   inline void SetActiveFog(CybFogC *pFog){m_pActiveFog = pFog;}
00198   // Get active fog for rendering
00199   inline CybFogC *GetActiveFog(){return m_pActiveFog;}
00200   
00201   // Background administration
00202   void AddBackground(CybBackgroundC *pBackground);           
00203   inline void SetActiveBackground(CybBackgroundC *pBackground){ m_pActiveBackground = pBackground; }
00204   inline CybBackgroundC *GetActiveBackground(){return m_pActiveBackground;}
00205 
00206   // Texture control
00207   TEXTURE LoadTexture(const char *pUrl);
00208   char SetTexture(const TEXTURE &pTexture);
00209   void UnloadTexture(TEXTURE &pTexture);
00210 
00211 
00212   CybProtoC* GetProto(const StringC&);
00213   void AddNewProtoName(const StringC&,CybProtoC* pP);
00214   
00215   const TimeC& GetSystemTime();
00216   const TimeC& GetSystemTimeLastFrame(){return m_timeLastFrame;}
00217   
00218   ArrayC<CybNodeC*> GetRouteList();
00219   long GetNodeID(CybNodeC*);
00220   void FreeNodeID(CybNodeC*,long);
00221   CybNodeC* GetNodeOfID(long);
00222   void SetMaxTexDim(long n){m_maxTexDim = n;}
00223   long GetMaxTexDim(){return m_maxTexDim;}
00224   const KetteC<NodeInfo>& GetVRMLNodeKeys();
00225   
00226   inline void EnableNavigation(short bNavigationEnabled)  { m_bNavigationEnabled = bNavigationEnabled; }
00227   inline short IsNavigationEnabled() { return m_bNavigationEnabled; }
00228   inline void SetArgv(const MFString& vstr){m_vstrArgv=vstr;}
00229   inline const MFString& GetArgv(){return m_vstrArgv;}
00230 
00231   
00232 public:
00233   CybTextureManagerC* m_pTexManager;
00234   CybSoundManagerC* m_pSoundManager;
00235   CybFontManagerC* m_pFontManager;
00236   CybJSEngineC* m_pJSEngine;
00237 
00238 protected:
00239   //CybTextureManagerC* m_pDefaultTexManager;
00240   CybSoundManagerC* m_pDefaultSoundManager;
00241   CybFontManagerC*  m_pDefaultFontManager;
00242 
00243   
00244 protected:
00245   /*Serialization*/
00246   void InitKeyList();
00247   long AddViewpoint(CybViewpointC* p);
00248   
00249   void RouteSensorData();
00250   void RouteInterfaceScriptData();
00251   void RoutePointingDeviceData();
00252   void ProcessInterfaceScript();
00253 protected:
00254 
00255   CybTransformC* m_pGroup;
00256   
00257   KetteC<DefUseC> m_DEFList;
00258   ArrayC<CybSensorC*> m_pSensor;
00259   ArrayC<CybInterfaceC*> m_pScript;
00260   ArrayC<CybProtoC*> m_pCurrentProto;
00261   ArrayC<CybProtoC*> m_pProto;
00262   ArrayC<StringListC> m_protoNodeNames;
00263   MapC<StringC,CybProtoC*> m_protoNodeMap;
00264   ArrayC<CybViewpointC*> m_viewpointList;
00265   ArrayC<CybPointingDeviceC*> m_pPointingDevice;
00266   ArrayC<CybFogC*> m_pFogs;   // List of available fogs
00267   ArrayC<CybBackgroundC*> m_pBackgrounds;   // List of available backgrounds
00268   
00269   TimeC m_lastUpdateAllViews;
00270   UrlC m_url;
00271   StringC m_homePath;
00272   StringC m_currentFilename;
00273   StringC m_currentFilepath;
00274 
00275   CybTimeC* m_pSystemTime;
00276 
00277   CybViewpointSensorC* m_pViewpointSensor;
00278   CybFogC* m_pActiveFog;   // Selected fog for rendering
00279   CybBackgroundC *m_pActiveBackground;  
00280 
00281   //User
00282   CybUserC* m_pUser; 
00283   VectorC m_vScale;
00284   //ArrayC<CybNodeC*>* m_pCreateVrmlNodeList;
00285   long m_nNumTouchSensors, m_nNumDragSensors;
00286 
00287   ArrayC<CybNodeC*> m_pNodeList;
00288   ArrayC<long> m_freeNodeIDList;
00289   CybViewpointC* m_pDefaultViewpoint;
00290   CybViewpointC* m_pActiveViewpoint;
00291 
00292   TimeC m_timeLastFrame;
00293 
00294   long m_maxTexDim;
00295 
00296   short m_bNavigationEnabled;
00297   MFString m_vstrArgv;
00298 
00299 public:
00300   KetteC<NodeInfo> kVRMLKeyInfo;
00301 protected:
00302   KetteC<NodeInfo> m_kVRMLNodeKeyInfo;
00303   KetteC<NodeInfo> m_kVRMLNodeKeyInfoCompl;
00304         long m_nNativeNodeKeys;
00305 };
00306 
00307 OAW_END_NAMESPACE
00308 
00309 
00310 #endif
00311 
00313 

Generated on Tue Jul 29 14:24:14 2003 for Open ActiveWrl by doxygen1.3-rc2