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

floor.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 STARK_RESOURCES_FLOOR_H
00024 #define STARK_RESOURCES_FLOOR_H
00025 
00026 #include "common/array.h"
00027 #include "common/str.h"
00028 
00029 #include "math/line3d.h"
00030 #include "math/ray.h"
00031 #include "math/vector3d.h"
00032 
00033 #include "engines/stark/resources/object.h"
00034 
00035 namespace Stark {
00036 
00037 namespace Formats {
00038 class XRCReadStream;
00039 }
00040 
00041 namespace Resources {
00042 
00043 class Floor;
00044 class FloorFace;
00045 class FloorField;
00046 
00052 class FloorEdge {
00053 public:
00054     FloorEdge(uint16 vertexIndex1, uint16 vertexIndex2, uint32 faceIndex1);
00055 
00057     void buildNeighbours(const Floor *floor);
00058 
00060     void computeMiddle(const Floor *floor);
00061 
00063     void setOtherFace(uint32 faceIndex);
00064 
00066     bool hasVertices(uint16 vertexIndex1, uint16 vertexIndex2) const;
00067 
00069     Common::Array<FloorEdge *> getNeighbours() const;
00070 
00077     float costTo(const FloorEdge *other) const;
00078 
00084     Math::Vector3d getPosition() const;
00085 
00087     bool isFloorBorder() const;
00088 
00090     bool intersectsSegment(const Floor *floor, const Math::Line3d &segment) const;
00091 
00092     int32 getFaceIndex1() const;
00093     int32 getFaceIndex2() const;
00094 
00096     void enable(bool enable);
00097 
00099     bool isEnabled() const;
00100 
00102     void saveLoad(ResourceSerializer *serializer);
00103 
00104 private:
00105     void addNeighboursFromFace(const FloorFace *face);
00106     static bool intersectLine2d(const Math::Line3d &s1, const Math::Line3d &s2);
00107 
00108     uint16 _vertexIndex1;
00109     uint16 _vertexIndex2;
00110     Math::Vector3d _middle;
00111     int32 _faceIndex1;
00112     int32 _faceIndex2;
00113 
00114     bool _enabled;
00115 
00116     Common::Array<FloorEdge *> _neighbours;
00117 };
00118 
00125 class Floor : public Object {
00126 public:
00127     static const Type::ResourceType TYPE = Type::kFloor;
00128 
00129     Floor(Object *parent, byte subType, uint16 index, const Common::String &name);
00130     virtual ~Floor();
00131 
00132     // Resource API
00133     void onAllLoaded() override;
00134     void saveLoad(ResourceSerializer *serializer) override;
00135 
00137     Math::Vector3d getVertex(uint32 index) const;
00138 
00145     int32 findFaceContainingPoint(const Math::Vector3d &point) const;
00146 
00148     void computePointHeightInFace(Math::Vector3d &point, uint32 faceIndex) const;
00149 
00159     int32 findFaceHitByRay(const Math::Ray &ray, Math::Vector3d &intersection) const;
00160 
00170     int32 findFaceClosestToRay(const Math::Ray &ray, Math::Vector3d &center) const;
00171 
00173     float getDistanceFromCamera(uint32 faceIndex) const;
00174 
00176     FloorFace *getFace(uint32 index) const;
00177 
00179     bool isSegmentInside(const Math::Line3d &segment) const;
00180 
00182     void enableFloorField(FloorField *floorfield, bool enable);
00183 
00184 protected:
00185     void readData(Formats::XRCReadStream *stream) override;
00186     void printData() override;
00187 
00188     void buildEdgeList();
00189     void addFaceEdgeToList(uint32 faceIndex, uint32 index1, uint32 index2);
00190 
00191     uint32 _facesCount;
00192     Common::Array<Math::Vector3d> _vertices;
00193     Common::Array<FloorFace *> _faces;
00194     Common::Array<FloorEdge> _edges;
00195 };
00196 
00197 } // End of namespace Resources
00198 } // End of namespace Stark
00199 
00200 #endif // STARK_RESOURCES_FLOOR_H


Generated on Sat Mar 16 2019 05:01:32 for ResidualVM by doxygen 1.7.1
curved edge   curved edge