Skyscraper
2.0
src
sbs
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
32
namespace
SBS
{
33
34
class
SBSIMPEXP
Polygon
:
public
ObjectBase
35
{
36
public
:
37
struct
Geometry
38
{
39
//basic 3D geometry
40
Vector3
vertex
;
41
Vector2
texel
;
42
Vector3
normal
;
43
};
44
typedef
std::vector<std::vector<Geometry> >
GeometrySet
;
45
46
MeshObject
*
mesh
;
47
GeometrySet
geometry
;
//mesh geometry (vertices/texels/normals) container
48
int
vertex_count
;
49
std::vector<Triangle>
triangles
;
50
Plane
plane
;
//plane in remote (Ogre) form, relative positioning
51
52
//texture mapping matrix and vector
53
Matrix3
t_matrix
;
54
Vector3
t_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
SBS::MeshObject
Definition
mesh.h:44
SBS::ObjectBase
Definition
object.h:33
SBS::Object
Definition
object.h:56
SBS::Polygon
Definition
polygon.h:35
SBS::Polygon::triangles
std::vector< Triangle > triangles
Definition
polygon.h:49
SBS::Polygon::size
size_t size
Definition
polygon.h:58
SBS::Polygon::vertex_count
int vertex_count
Definition
polygon.h:48
SBS::Polygon::t_vector
Vector3 t_vector
Definition
polygon.h:54
SBS::Polygon::GeometrySet
std::vector< std::vector< Geometry > > GeometrySet
Definition
polygon.h:44
SBS::Polygon::material
std::string material
Definition
polygon.h:56
SBS::Polygon::geometry
GeometrySet geometry
Definition
polygon.h:47
SBS::Polygon::t_matrix
Matrix3 t_matrix
Definition
polygon.h:53
SBS::Polygon::mesh
MeshObject * mesh
Definition
polygon.h:46
SBS::Polygon::plane
Plane plane
Definition
polygon.h:50
Matrix3
Ogre::Matrix3 Matrix3
Definition
globals.h:64
Vector3
Ogre::Vector3 Vector3
Definition
globals.h:58
Real
Ogre::Real Real
Definition
globals.h:57
Plane
Ogre::Plane Plane
Definition
globals.h:65
Vector2
Ogre::Vector2 Vector2
Definition
globals.h:59
SBSIMPEXP
#define SBSIMPEXP
Definition
globals.h:53
mesh.h
SBS
Definition
skyscraper.h:45
SBS::Polygon::Geometry
Definition
polygon.h:38
SBS::Polygon::Geometry::vertex
Vector3 vertex
Definition
polygon.h:40
SBS::Polygon::Geometry::texel
Vector2 texel
Definition
polygon.h:41
SBS::Polygon::Geometry::normal
Vector3 normal
Definition
polygon.h:42
triangle.h
Generated by
1.11.0