Skyscraper 2.0
geometry.cpp
Go to the documentation of this file.
1/*
2 Scalable Building Simulator - Geometry Controller
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#include <OgreProcedural/Procedural.h>
25#include "globals.h"
26#include "sbs.h"
27#include "texture.h"
28#include "mesh.h"
29#include "geometry.h"
30
31namespace SBS {
32
34{
35 //set up SBS object
36 SetValues("GeometryController", "Geometry Controller", true, false);
37}
38
43
44Ogre::MeshPtr GeometryController::CreatePlane(Object* parent, const std::string& name, Real size_x, Real size_y, unsigned int segments_x, unsigned int segments_y, Real utile, Real vtile)
45{
46 return Procedural::PlaneGenerator().setScale(1.0 / sbs->UnitScale).setNumSegX(segments_x).setNumSegY(segments_y).setSizeX(size_x).setSizeY(size_y).setUTile(utile).setVTile(vtile).realizeMesh(parent->GetNameBase() + name);
47}
48
49Ogre::MeshPtr GeometryController::CreateSphere(Object* parent, const std::string& name, Real radius, Real utile, Real vtile, unsigned int rings, unsigned int segments)
50{
51 return Procedural::SphereGenerator().setScale(1.0 / sbs->UnitScale).setRadius(radius).setUTile(utile).setVTile(vtile).setNumRings(rings).setNumSegments(segments).realizeMesh(parent->GetNameBase() + name);
52}
53
54Ogre::MeshPtr GeometryController::CreateCylinder(Object* parent, const std::string& name, Real radius, Real height, Real utile, Real vtile, unsigned int segments_base, unsigned int segments_height, bool capped)
55{
56 return Procedural::CylinderGenerator().setScale(1.0 / sbs->UnitScale).setHeight(height).setRadius(radius).setUTile(utile).setVTile(vtile).setNumSegBase(segments_base).setNumSegHeight(segments_height).setCapped(capped).realizeMesh(parent->GetNameBase() + name);
57}
58
59Ogre::MeshPtr GeometryController::CreateTorus(Object* parent, const std::string& name, Real radius, Real section_radius, Real utile, Real vtile)
60{
61 return Procedural::TorusGenerator().setScale(1.0 / sbs->UnitScale).setRadius(radius).setSectionRadius(section_radius).setUTile(utile).setVTile(vtile).realizeMesh(parent->GetNameBase() + name);
62}
63
64Ogre::MeshPtr GeometryController::CreateCone(Object* parent, const std::string& name, Real radius, Real height, Real utile, Real vtile, unsigned int segments_base, unsigned int segments_height)
65{
66 return Procedural::ConeGenerator().setScale(1.0 / sbs->UnitScale).setRadius(radius).setHeight(height).setNumSegBase(segments_base).setNumSegHeight(segments_height).setUTile(utile).setVTile(vtile).realizeMesh(parent->GetNameBase() + name);
67}
68
69Ogre::MeshPtr GeometryController::CreateTube(Object* parent, const std::string& name, Real inner_radius, Real outer_radius, Real height, Real utile, Real vtile, unsigned int segments_base, unsigned int segments_height)
70{
71 return Procedural::TubeGenerator().setScale(1.0 / sbs->UnitScale).setHeight(height).setUTile(utile).setVTile(vtile).setNumSegBase(segments_base).setNumSegHeight(segments_height).setInnerRadius(inner_radius).setOuterRadius(outer_radius).realizeMesh(parent->GetNameBase() + name);
72}
73
74Ogre::MeshPtr GeometryController::CreateBox(Object* parent, const std::string& name, Real size_x, Real size_y, Real size_z, Real utile, Real vtile, unsigned int segments_x, unsigned int segments_y, unsigned int segments_z)
75{
76 return Procedural::BoxGenerator().setScale(1.0 / sbs->UnitScale).setSizeX(size_x).setSizeY(size_y).setSizeZ(size_z).setNumSegX(segments_x).setNumSegY(segments_y).setNumSegZ(segments_z).setUTile(utile).setVTile(vtile).realizeMesh(parent->GetNameBase() + name);
77}
78
79Ogre::MeshPtr GeometryController::CreateCapsule(Object* parent, const std::string& name, Real radius, Real height, unsigned int rings, Real utile, Real vtile, unsigned int segments, unsigned int segments_height, bool capped)
80{
81 return Procedural::CapsuleGenerator().setScale(1.0 / sbs->UnitScale).setRadius(radius).setHeight(height).setNumRings(rings).setNumSegHeight(segments_height).setNumSegments(segments).setUTile(utile).setVTile(vtile).realizeMesh(parent->GetNameBase() + name);
82}
83
84Ogre::MeshPtr GeometryController::CreateTorusKnot(Object* parent, const std::string& name, Real radius, Real section_radius, Real utile, Real vtile, unsigned int segments_circle, unsigned int seg_section, int p, int q)
85{
86 return Procedural::TorusKnotGenerator().setScale(1.0 / sbs->UnitScale).setRadius(radius).setSectionRadius(section_radius).setUTile(utile).setVTile(vtile).setNumSegCircle(segments_circle).setNumSegSection(seg_section).setP(p).setQ(q).realizeMesh(parent->GetNameBase() + name);
87}
88
89Ogre::MeshPtr GeometryController::CreateIcoSphere(Object* parent, const std::string& name, Real radius, Real utile, Real vtile, unsigned int iterations)
90{
91 return Procedural::IcoSphereGenerator().setScale(1.0 / sbs->UnitScale).setRadius(radius).setNumIterations(iterations).setUTile(utile).setVTile(vtile).realizeMesh(parent->GetNameBase() + name);
92}
93
94Ogre::MeshPtr GeometryController::CreateRoundedBox(Object* parent, const std::string& name, Real size_x, Real size_y, Real size_z, Real chamfer_size, Real utile, Real vtile, unsigned int segments_x, unsigned int segments_y, unsigned int segments_z, bool capped)
95{
96 return Procedural::RoundedBoxGenerator().setScale(1.0 / sbs->UnitScale).setSizeX(size_x).setSizeY(size_y).setSizeZ(size_z).setChamferSize(chamfer_size).setNumSegX(segments_x).setNumSegY(segments_y).setNumSegZ(segments_z).setUTile(utile).setVTile(vtile).realizeMesh(parent->GetNameBase() + name);
97}
98
99Ogre::MeshPtr GeometryController::CreateSpring(Object* parent, const std::string& name, Real radius_circle, Real radius_helix, Real height, Real round, Real utile, Real vtile, unsigned int segments_circle, unsigned int segments_path, bool capped)
100{
101 return Procedural::SpringGenerator().setScale(1.0 / sbs->UnitScale).setHeight(height).setNumRound(round).setRadiusCircle(radius_circle).setRadiusHelix(radius_helix).setNumSegCircle(segments_circle).setNumSegPath(segments_path).setUTile(utile).setVTile(vtile).realizeMesh(parent->GetNameBase() + name);
102}
103
104Ogre::MeshPtr GeometryController::CreatePrism(Object* parent, const std::string& name, Real radius, Real height, unsigned int sides, unsigned int segments_height, bool capped)
105{
106 return Procedural::PrismGenerator().setScale(1.0 / sbs->UnitScale).setRadius(radius).setHeight(height).setNumSides(sides).setNumSegHeight(segments_height).setCapped(capped).realizeMesh(parent->GetNameBase() + name);
107}
108
109}
Ogre::MeshPtr CreatePrism(Object *parent, const std::string &name, Real radius, Real height, unsigned int sides, unsigned int segments_height, bool capped)
Definition geometry.cpp:104
Ogre::MeshPtr CreateCylinder(Object *parent, const std::string &name, Real radius, Real height, Real utile, Real vtile, unsigned int segments_base, unsigned int segments_height, bool capped)
Definition geometry.cpp:54
Ogre::MeshPtr CreatePlane(Object *parent, const std::string &name, Real size_x, Real size_y, unsigned int segments_x, unsigned int segments_y, Real utile, Real vtile)
Definition geometry.cpp:44
Ogre::MeshPtr CreateRoundedBox(Object *parent, const std::string &name, Real size_x, Real size_y, Real size_z, Real chamfer_size, Real utile, Real vtile, unsigned int segments_x, unsigned int segments_y, unsigned int segments_z, bool capped)
Definition geometry.cpp:94
Ogre::MeshPtr CreateSpring(Object *parent, const std::string &name, Real radius_circle, Real radius_helix, Real height, Real round, Real utile, Real vtile, unsigned int segments_circle, unsigned int segments_path, bool capped)
Definition geometry.cpp:99
Ogre::MeshPtr CreateTorus(Object *parent, const std::string &name, Real radius, Real section_radius, Real utile, Real vtile)
Definition geometry.cpp:59
Ogre::MeshPtr CreateBox(Object *parent, const std::string &name, Real size_x, Real size_y, Real size_z, Real utile, Real vtile, unsigned int segments_x, unsigned int segments_y, unsigned int segments_z)
Definition geometry.cpp:74
Ogre::MeshPtr CreateTube(Object *parent, const std::string &name, Real inner_radius, Real outer_radius, Real height, Real utile, Real vtile, unsigned int segments_base, unsigned int segments_height)
Definition geometry.cpp:69
Ogre::MeshPtr CreateIcoSphere(Object *parent, const std::string &name, Real radius, Real utile, Real vtile, unsigned int iterations)
Definition geometry.cpp:89
Ogre::MeshPtr CreateCapsule(Object *parent, const std::string &name, Real radius, Real height, unsigned int rings, Real utile, Real vtile, unsigned int segments, unsigned int segments_height, bool capped)
Definition geometry.cpp:79
GeometryController(Object *parent)
Definition geometry.cpp:33
Ogre::MeshPtr CreateCone(Object *parent, const std::string &name, Real radius, Real height, Real utile, Real vtile, unsigned int segments_base, unsigned int segments_height)
Definition geometry.cpp:64
Ogre::MeshPtr CreateSphere(Object *parent, const std::string &name, Real radius, Real utile, Real vtile, unsigned int rings, unsigned int segments)
Definition geometry.cpp:49
Ogre::MeshPtr CreateTorusKnot(Object *parent, const std::string &name, Real radius, Real section_radius, Real utile, Real vtile, unsigned int segments_circle, unsigned int seg_section, int p, int q)
Definition geometry.cpp:84
std::string GetNameBase()
Definition object.cpp:599
void SetValues(const std::string &type, const std::string &name, bool is_permanent, bool is_movable=true)
Definition object.cpp:144
Real UnitScale
Definition sbs.h:185
Ogre::Real Real
Definition globals.h:57