NDEVR
API Documentation
ShapeConstructors.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Design
28File: ShapeConstructors
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/BaseValues.h>
35#include <NDEVR/Matrix.h>
36#include <NDEVR/Vertex.h>
37#include <NDEVR/Bounds.h>
38namespace NDEVR
39{
40 class Geometry;
41 class Scene;
42
48 {
54 : size(width, height)
55 {}
56 Vector<2, uint04> size = Vector <2, uint04>(44, 32);
59
65
71
77 private:
82 Vector<2, Angle<fltp08>> _vertexIndexToAngle(uint04 index) const;
83
88 uint04 _angleToVertexIndex(Vector<2, Angle<fltp08>> angle) const;
89
90 };
91
98 class NDEVR_DESIGN_API ShapeConstructors
99 {
100 public:
105 static Geometry StaticLine(Scene& parent);
106
112
118
124
130
140
154 static void Rectangle(Geometry& mesh, const Matrix<fltp08>& trans = Matrix<fltp08>(1), fltp08 top_length = 2.0, fltp08 bottom_length = 2.0, fltp08 left_length = 2.0, fltp08 right_length = 2.0, fltp08 vertical_skew = 0.0, fltp08 horizontal_skew = 0.0);
155
160 static void RectangularPrism(Geometry& mesh, const Matrix<fltp08>& trans = Matrix<fltp08>(1));
161
171 static void Circle(Geometry& mesh, const Matrix<fltp08>& trans = Matrix<fltp08>(1), uint04 width_segments = 128, fltp08 radius = 1.0f, Angle<fltp08> phi_start = Angle<fltp08>(DEGREES, 0.0f), Angle<fltp08> phi_length = Angle<fltp08>(DEGREES, 360.0f), bool join = true);
172
185 static void Cylinder(Geometry& mesh, const Matrix<fltp08>& trans = Matrix<fltp08>(1), uint04 width_segments = 44, fltp08 top_radius = 1.0f, fltp08 bottom_radius = 1.0, fltp08 height = 1.0, Angle<fltp08> phi_start = Angle<fltp08>(DEGREES, 0.0f), Angle<fltp08> phi_length = Angle<fltp08>(DEGREES, 360.0f), bool draw_top_circle = true, bool draw_bottom_circle = true);
186
197 static void Cone(Geometry& mesh, const Matrix<fltp08>& trans = Matrix<fltp08>(1), uint04 width_segments = 44, fltp08 bottom_radius = 1.0, fltp08 height = 1.0, Angle<fltp08> phi_start = Angle<fltp08>(DEGREES, 0.0f), Angle<fltp08> phi_length = Angle<fltp08>(DEGREES, 360.0f), bool draw_bottom_circle = true);
198
208 static void Sphere(Geometry& mesh, uint04 width_segments = 44, uint04 height_segments = 32, Angle<fltp08> phi_start = Angle<fltp08>(DEGREES, 0.0f), Angle<fltp08> phi_length = Angle<fltp08>(DEGREES, 360.0f), Angle<fltp08> theta_start = Angle<fltp08>(DEGREES, 0.0f), Angle<fltp08> theta_length = Angle<fltp08>(DEGREES, 180.0f));
209
215 static void ZippedRadialMesh(Geometry& mesh, const ZippedRadialMeshOptions& options);
216
222 static void ZippedTorus(Geometry& mesh, uint04 width_segments = 44, uint04 height_segments = 32);
223 protected:
227 static void SetupStaticGeometry(Geometry& geo);
228 };
229}
230
231
232
Stores an angle in an optimized internal format with support for efficient trigonometric operations.
Definition Angle.h:83
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:54
A core class within the model hierarchy containing vertex-based data (Usually 3D data) within a set c...
Definition Geometry.h:143
Templated logic for doing matrix multiplication.
Definition Matrix.hpp:182
The root Model that is responsible for storing the underlying data for all Scene Models.
Definition Scene.h:52
Logic for writing various basic shapes to a Geometry object.
static Geometry StaticRectangularPrismFilled(Scene &parent)
Creates a reusable static filled rectangular prism Geometry within the given Scene.
static Geometry StaticCircleOutline(Scene &parent)
Creates a reusable static circle outline Geometry within the given Scene.
static void ZippedTorus(Geometry &mesh, uint04 width_segments=44, uint04 height_segments=32)
Appends a torus to the mesh using the zipped radial mesh construction pattern.
static void Cone(Geometry &mesh, const Matrix< fltp08 > &trans=Matrix< fltp08 >(1), uint04 width_segments=44, fltp08 bottom_radius=1.0, fltp08 height=1.0, Angle< fltp08 > phi_start=Angle< fltp08 >(DEGREES, 0.0f), Angle< fltp08 > phi_length=Angle< fltp08 >(DEGREES, 360.0f), bool draw_bottom_circle=true)
Appends a cone to the mesh.
static void Quad(Geometry &mesh, const Matrix< fltp08 > &trans, Vertex< 3, fltp08 > p1, Vertex< 3, fltp08 > p2, Vertex< 3, fltp08 > p3, Vertex< 3, fltp08 > p4)
Appends a quad (two-triangle face) defined by four vertices to the mesh.
static Geometry StaticRectangularPrismOutline(Scene &parent)
Creates a reusable static rectangular prism outline Geometry within the given Scene.
static void Circle(Geometry &mesh, const Matrix< fltp08 > &trans=Matrix< fltp08 >(1), uint04 width_segments=128, fltp08 radius=1.0f, Angle< fltp08 > phi_start=Angle< fltp08 >(DEGREES, 0.0f), Angle< fltp08 > phi_length=Angle< fltp08 >(DEGREES, 360.0f), bool join=true)
Appends a circle (filled disc or arc) to the mesh.
static void ZippedRadialMesh(Geometry &mesh, const ZippedRadialMeshOptions &options)
Appends a radial mesh to the Geometry using the "zipped" construction pattern, where adjacent latitud...
static void Cylinder(Geometry &mesh, const Matrix< fltp08 > &trans=Matrix< fltp08 >(1), uint04 width_segments=44, fltp08 top_radius=1.0f, fltp08 bottom_radius=1.0, fltp08 height=1.0, Angle< fltp08 > phi_start=Angle< fltp08 >(DEGREES, 0.0f), Angle< fltp08 > phi_length=Angle< fltp08 >(DEGREES, 360.0f), bool draw_top_circle=true, bool draw_bottom_circle=true)
Appends a cylinder to the mesh with configurable radii and caps.
static void SetupStaticGeometry(Geometry &geo)
Configures a Geometry object with default settings for static (reusable) shapes.
static Geometry StaticLine(Scene &parent)
Creates a reusable static line Geometry within the given Scene.
static void Sphere(Geometry &mesh, uint04 width_segments=44, uint04 height_segments=32, Angle< fltp08 > phi_start=Angle< fltp08 >(DEGREES, 0.0f), Angle< fltp08 > phi_length=Angle< fltp08 >(DEGREES, 360.0f), Angle< fltp08 > theta_start=Angle< fltp08 >(DEGREES, 0.0f), Angle< fltp08 > theta_length=Angle< fltp08 >(DEGREES, 180.0f))
Appends a sphere to the mesh using longitude/latitude segmentation.
static Geometry StaticRectangleFilled(Scene &parent)
Creates a reusable static filled rectangle Geometry within the given Scene.
static void RectangularPrism(Geometry &mesh, const Matrix< fltp08 > &trans=Matrix< fltp08 >(1))
Appends a rectangular prism (box) to the mesh.
static void Rectangle(Geometry &mesh, const Matrix< fltp08 > &trans=Matrix< fltp08 >(1), fltp08 top_length=2.0, fltp08 bottom_length=2.0, fltp08 left_length=2.0, fltp08 right_length=2.0, fltp08 vertical_skew=0.0, fltp08 horizontal_skew=0.0)
Appends a rectangle to the mesh with configurable edge lengths and skew.
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Definition Vector.hpp:62
A point in N-dimensional space, used primarily for spatial location information.
Definition Vertex.hpp:44
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
@ DEGREES
Angle measured in degrees (0 to 360 for a full circle).
Definition Angle.h:58
Logic for setting up a mesh that is broken apart by latitude and longitude lines with a set angle dif...
Vector< 2, Angle< fltp08 > > vertexIndexToAngle(uint04 index) const
Converts a linear vertex index to its corresponding [phi, theta] angles.
Vector< 2, fltp08 > angleToTextureCoord(Vector< 2, Angle< fltp08 > > angle) const
Converts a [phi, theta] angle pair to normalized texture coordinates.
Bounds< 2, Angle< fltp08 > > radial_bounds
The angular bounds of the radial mesh in [phi, theta].
ZippedRadialMeshOptions(uint04 width, uint04 height)
Constructs mesh options with the given segment counts.
uint04 angleToVertexIndex(Vector< 2, Angle< fltp08 > > angle) const
Converts a [phi, theta] angle pair to the nearest vertex index.
Vector< 2, Angle< fltp08 > > span
The angular span covered by the mesh in [phi, theta].
Vector< 2, uint04 > size
The number of segments in [longitude, latitude] (width, height).