Skyscraper 2.0
polygon.h
Go to the documentation of this file.
1/*
2 Scalable Building Simulator - Polygon Object
3 The Skyscraper Project - Version 2.0
4 Copyright (C)2004-2024 Ryan Thoryk
5 https://www.skyscrapersim.net
6 https://sourceforge.net/projects/skyscraper/
7 Contact - ryan@skyscrapersim.net
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22*/
23
24#ifndef _SBS_POLYGON_H
25#define _SBS_POLYGON_H
26
27#include <OgrePlane.h>
28#include <OgreMatrix3.h>
29#include "mesh.h"
30#include "triangle.h"
31
32namespace SBS {
33
35{
36public:
37 struct Geometry
38 {
39 //basic 3D geometry
43 };
44 typedef std::vector<std::vector<Geometry> > GeometrySet;
45
47 GeometrySet geometry; //mesh geometry (vertices/texels/normals) container
49 std::vector<Triangle> triangles;
50 Plane plane; //plane in remote (Ogre) form, relative positioning
51
52 //texture mapping matrix and vector
55
56 std::string material; //polygon material
57
58 size_t size; //size in bytes of polygon
59
60 Polygon(Object *parent, const std::string &name, MeshObject *meshwrapper, GeometrySet &geometry, std::vector<Triangle> &triangles, Matrix3 &tex_matrix, Vector3 &tex_vector, const std::string &material, Plane &plane);
61 ~Polygon();
62 void GetTextureMapping(Matrix3 &t_matrix, Vector3 &t_vector);
63 bool IntersectSegment(const Vector3 &start, const Vector3 &end, Vector3 &isect, Real *pr, Vector3 &normal);
64 bool IntersectRay(const Vector3 &start, const Vector3 &end);
65 bool IntersectSegmentPlane(const Vector3 &start, const Vector3 &end, Vector3 &isect, Real *pr, Vector3 &normal);
66 void Move(const Vector3 &vector, Real speed = 1.0);
67 Plane GetAbsolutePlane();
68 Vector2 GetExtents(int coord);
69 void ChangeHeight(Real newheight);
70 bool ReplaceTexture(const std::string &oldtexture, const std::string &newtexture);
71 bool ChangeTexture(const std::string &texture, bool matcheck = true);
72 Vector3 GetVertex(int index);
73};
74
75}
76
77#endif
std::vector< Triangle > triangles
Definition polygon.h:49
size_t size
Definition polygon.h:58
int vertex_count
Definition polygon.h:48
Vector3 t_vector
Definition polygon.h:54
std::vector< std::vector< Geometry > > GeometrySet
Definition polygon.h:44
std::string material
Definition polygon.h:56
GeometrySet geometry
Definition polygon.h:47
Matrix3 t_matrix
Definition polygon.h:53
MeshObject * mesh
Definition polygon.h:46
Plane plane
Definition polygon.h:50
Ogre::Matrix3 Matrix3
Definition globals.h:64
Ogre::Vector3 Vector3
Definition globals.h:58
Ogre::Real Real
Definition globals.h:57
Ogre::Plane Plane
Definition globals.h:65
Ogre::Vector2 Vector2
Definition globals.h:59
#define SBSIMPEXP
Definition globals.h:53