interreality.org [VOS]
[Home] [About]
[Screenshots]
[Download]
[News]
[Community]
[Documentation] [Manual]
[Bugs & Requests] [Wiki]

/home/tetron/hack/vos/libs/vos/csplugin/vossector.hh

Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002    $Id: vossector.h,v 1.20 2006/05/07 23:01:24 reed Exp $
00003 
00004     This file is part of Crystal Space Virtual Object System Abstract
00005     3D Layer plugin (csvosa3dl).
00006 
00007     Copyright (C) 2004-2005 Peter Amstutz
00008 
00009     This program is free software; you can redistribute it and/or modify
00010     it under the terms of the GNU Lesser General Public License as published by
00011     the Free Software Foundation; either version 2 of the License, or
00012     (at your option) any later version.
00013 
00014     This library is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017     GNU Lesser General Public License for more details.
00018 
00019     You should have received a copy of the GNU Lesser General Public License
00020     along with this program; if not, write to the Free Software
00021     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 */
00023 #ifndef _VOSSECTOR_H_
00024 #define _VOSSECTOR_H_
00025 
00026 #include <vos/metaobjects/a3dl/a3dl.hh>
00027 #include "ivosa3dl.hh"
00028 
00029 class csMetaSector;
00030 
00031 class csVosSector : public iVosSector, public iVosApi,
00032                     public VOS::ChildChangeListener,
00033                     public VOS::PropertyListener
00034 {
00035 private:
00036   bool didLoad;
00037   iObjectRegistry* objreg;
00038   csRef<iEngine> engine;
00039   csRef<iSector> sector;
00040   csVosA3DL* vosa3dl;
00041   csRef<iProgressMeter> meter;
00042   VUtil::vRef<csMetaSector> sectorvobj;
00043   csRef<iDynamicSystem> dynsys;
00044   csRef<iCollideSystem> colsys;
00045 
00046   csSet < csPtrKey<iVosObject3D> > loadedObjects;
00047 
00048   bool isLit;
00049   int waitingForChildren;
00050 
00051   float gravity;
00052   bool collisionDetection;
00053 
00054   virtual void notifyChildInserted (VOS::VobjectEvent &event);
00055   virtual void notifyChildRemoved (VOS::VobjectEvent &event);
00056   virtual void notifyChildReplaced (VOS::VobjectEvent &event);
00057 
00058 public:
00059   SCF_DECLARE_IBASE;
00060 
00061   csVosSector(iObjectRegistry *o, csVosA3DL* vosa3dl, csMetaSector* sec);
00062   virtual ~csVosSector();
00063 
00064   virtual void Load(iProgressMeter* progress = 0);
00065   virtual csRef<iSector> GetSector();
00066 
00067   virtual VUtil::vRef<VOS::Vobject> GetVobject();
00068 
00069   virtual const csSet< csPtrKey<iVosObject3D> > &GetObject3Ds();
00070 
00071   void addObject3D (iVosObject3D *obj);
00072   void removeObject3D (iVosObject3D *obj);
00073 
00074   csRef<iDynamicSystem> GetDynSys() { return dynsys; }
00075 
00076   csRef<iCollideSystem> GetCollideSystem() { return colsys; }
00077 
00078   virtual void CacheLightmaps();
00079 
00080   virtual void notifyPropertyChange(const VOS::PropertyEvent &event);
00081 
00082   virtual float getGravity();
00083   virtual bool getCollisionDetection();
00084 
00085   //void addLight (iVosLight *light);
00086   //void removeLight (iVosLight *light);
00087 
00088   friend class LoadSectorTask;
00089   friend class RelightTask;
00090 };
00091 
00092 class csMetaSector : public virtual A3DL::Sector
00093 {
00094 private:
00095   csRef<csVosSector> csvossector;
00096 
00097 public:
00098   csMetaSector(VOS::VobjectBase* superobject);
00099   virtual ~csMetaSector() { }
00100 
00101   static VOS::MetaObject* new_csMetaSector(VOS::VobjectBase* superobject,
00102     const std::string& type);
00103 
00104   csRef<csVosSector> GetCsVosSector() { return csvossector; }
00105   void SetCsVosSector(csRef<csVosSector> s) { csvossector = s; }
00106 };
00107 
00108 
00109 class csVosProgressTask : public VUtil::Task
00110 {
00111 private:
00112   csRef<iProgressMeter> meter;
00113   std::string action;
00114   unsigned int step;
00115   unsigned int total;
00116 
00117 public:
00118   csVosProgressTask(iProgressMeter* m, const std::string& a, unsigned int t)
00119     : meter(m), action(a), total(t)
00120     {
00121     }
00122 
00123   csVosProgressTask(iProgressMeter* m, unsigned int s)
00124     : meter(m), step(s)
00125     {
00126     }
00127 
00128   virtual void doTask()
00129     {
00130       if (action != "") {
00131         meter->SetProgressDescription("crystalspace.network.vos.a3dl.progress", action.c_str());
00132         meter->SetTotal(total);
00133         meter->SetGranularity(1);
00134       }
00135       else
00136       {
00137         meter->Step(step);
00138       }
00139     }
00140 };
00141 
00142 
00143 #endif