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

/home/tetron/hack/vos/libs/vos/metaobjects/a3dl/portal.hh

Go to the documentation of this file.
00001 /*
00002     This file is part of the Virtual Object System of
00003     the Interreality project (http://interreality.org).
00004 
00005     Copyright (C) 2003 Peter Amstutz
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00020 
00021     Peter Amstutz <http://www.interreality.org>
00022 */
00023 #ifndef _PORTAL_HH_
00024 #define _PORTAL_HH_
00025 
00026 #ifndef A3DL_EXPORTS
00027 IMPORT_METAOBJECT_FACTORIES(A3DL_Portal)
00028 #endif
00029 
00030 #include "a3dldefs.hh"
00031 #include <vos/vos/vos.hh>
00032 #include <vos/metaobjects/a3dl/texture.hh>
00033 #include <vos/metaobjects/a3dl/sector.hh>
00034 
00035 
00036 namespace A3DL
00037 {
00038     /** @class Portal portal.hh vos/metaobjects/a3dl/portal.hh
00039      *  @ingroup libmetaobject_a3dl
00040      *  A portal connects different sectors by presenting a polygonal region in
00041      *  space which is rendered
00042      *  as a "hole" through which the destination sector can be seen and
00043      *  entered.  The dimensions of the visible portal and the
00044      *  corresponding shape through which the destination sector is rendered
00045      *  is represented by a "warping" transformation matrix.
00046      */
00047     class A3DL_API Portal : public VOS::MetaObject
00048     {
00049     public:
00050         Portal(VOS::VobjectBase* superobject);
00051         virtual ~Portal();
00052 
00053         static VOS::MetaObject* new_Portal(VOS::VobjectBase* superobject, const std::string& type);
00054         virtual const std::string getVOSType();
00055 
00056         virtual void setTargetSector(Sector* sector);
00057         virtual VUtil::vRef<Sector> getTargetSector();
00058 
00059         virtual void setWarpingTransform(float m11, float m12, float m13,
00060                                          float m21, float m22, float m23,
00061                                          float m31, float m32, float m33,
00062                                          float tx,  float ty,  float tz);
00063 
00064         virtual void getWarpingTransform(float& m11, float& m12, float& m13,
00065                                          float& m21, float& m22, float& m23,
00066                                          float& m31, float& m32, float& m33,
00067                                          float& tx,  float& ty,  float& tz);
00068 
00069         /** Get material vobject. */
00070         virtual VUtil::vRef<Material> getMaterial(bool createIfNone = true);
00071 
00072         /** Set material vobject. */
00073         virtual void setMaterialObj(Material* material);
00074     };
00075 }
00076 
00077 namespace VUtil {
00078     template<> inline void iteratorReleaseItem(A3DL::Portal** v)
00079     {
00080         (*v)->release();
00081     }
00082 }
00083 
00084 namespace A3DL {
00085     class PortalIterator : public VUtil::Iterator<Portal*>
00086     {
00087     public:
00088         PortalIterator() : VUtil::Iterator<Portal*>() { }
00089         PortalIterator(const PortalIterator& i) : VUtil::Iterator<Portal*>(i) { }
00090         PortalIterator(std::vector<Portal*>& vec) {
00091             items->resize(vec.size());
00092             int c = 0;
00093             for(std::vector<Portal*>::const_iterator i = vec.begin();
00094                 i != vec.end();
00095                 i++)
00096             {
00097                 (*i)->acquire();
00098                 (*items)[c] = (*i);
00099                 c++;
00100             }
00101         }
00102         VUtil::vRef<Portal> operator*() {
00103             if(pos < items->size()) return VUtil::vRef<Portal>((*items)[pos], true);
00104             else return VUtil::vRef<Portal>();
00105         }
00106     };
00107 }
00108 
00109 #endif