ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

sector.h

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the AUTHORS
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program 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
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef GRIM_WALKPLANE_H
00024 #define GRIM_WALKPLANE_H
00025 
00026 #include "common/str.h"
00027 #include "common/list.h"
00028 
00029 #include "math/vector3d.h"
00030 #include "math/line3d.h"
00031 
00032 namespace Common {
00033     class SeekableReadStream;
00034 }
00035 
00036 namespace Grim {
00037 
00038 class SaveGame;
00039 class TextSplitter;
00040 
00041 class Sector {
00042 public:
00043     enum SectorType {
00044         NoneType = 0,
00045         WalkType = 0x1000,
00046         FunnelType = 0x1100,
00047         CameraType = 0x2000,
00048         SpecialType = 0x4000,
00049         HotType = 0x8000
00050     };
00051 
00052     Sector();
00053     Sector(const Sector &other);
00054     virtual ~Sector();
00055 
00056     void saveState(SaveGame *savedState) const;
00057     bool restoreState(SaveGame *savedState);
00058 
00059     void load(TextSplitter &ts);
00060     void loadBinary(Common::SeekableReadStream *data);
00061     void setVisible(bool visible);
00062     void shrink(float radius);
00063     void unshrink();
00064 
00065     Common::String getName() const { return _name; }
00066     int getSectorId() const { return _id; }
00067     SectorType getType() const { return _type; } // FIXME: Implement type de-masking
00068     bool isVisible() const { return _visible && !_invalid; }
00069     bool isPointInSector(const Math::Vector3d &point) const;
00070     float distanceToPoint(const Math::Vector3d &point) const;
00071     Common::List<Math::Line3d> getBridgesTo(Sector *sector) const;
00072 
00073     Math::Vector3d getProjectionToPlane(const Math::Vector3d &point) const;
00074     Math::Vector3d getProjectionToPuckVector(const Math::Vector3d &v) const;
00075 
00076     Math::Vector3d getClosestPoint(const Math::Vector3d &point) const;
00077 
00078     // Interface to trace a ray to its exit from the polygon
00079     struct ExitInfo {
00080         Math::Vector3d exitPoint;
00081         Math::Angle angleWithEdge;
00082         Math::Vector3d edgeDir;
00083         int edgeVertex;
00084     };
00085     void getExitInfo(const Math::Vector3d &start, const Math::Vector3d &dir, struct ExitInfo *result) const;
00086 
00087     int getNumSortplanes() { return _numSortplanes; }
00088     int getSortplane(int setup) { return _sortplanes[setup]; }
00089     int getNumVertices() { return _numVertices; }
00090     Math::Vector3d *getVertices() const { return _vertices; }
00091     Math::Vector3d getNormal() const { return _normal; }
00092 
00093     Sector &operator=(const Sector &other);
00094     bool operator==(const Sector &other) const;
00095 
00096 private:
00097     int _numVertices;
00098     int _id;
00099     int _numSortplanes;
00100     int *_sortplanes;
00101 
00102     Common::String _name;
00103     SectorType _type;
00104     bool _visible;
00105     bool _invalid;
00106     Math::Vector3d *_vertices;
00107     Math::Vector3d *_origVertices;
00108     float _height;
00109     float _shrinkRadius;
00110 
00111     Math::Vector3d _normal;
00112 };
00113 
00114 } // end of namespace Grim
00115 
00116 #endif


Generated on Sat Mar 23 2019 05:02:10 for ResidualVM by doxygen 1.7.1
curved edge   curved edge