IMS2  Pre-Alpha
An Orbiter add-on to allow on-runtime construction of spacecraft from predefined modules
SimpleShape Class Reference

Public Member Functions

UINT Size ()
 
void Merge (SimpleShape merger)
 merges another shape into this one. More...
 
void Translate (VECTOR3 offset)
 translates a shape by the demanded offset More...
 
void Rotate (MATRIX3 matrix)
 Rotates a shape by a matrix. More...
 
void Scale (VECTOR3 scale)
 Scales a shape in x y z. More...
 
void GetVertices (vector< VECTOR3 > &OUT_vertexlist)
 sets a reference to the shapes vertex list. More...
 
BoundingBoxGetBoundingBox ()
 returns an axis-aligned bounding box of the shape. More...
 

Static Public Member Functions

static SimpleShape Circle (double radius, UINT segments)
 
static SimpleShape Cylinder (double radius, double height, UINT segments)
 
static SimpleShape Rectangle (double width, double height)
 
static SimpleShape Box (double x, double y, double z)
 
static SimpleShape Sphere (double radius, UINT segments)
 

Private Member Functions

void createBoundingBox ()
 Creates the bounding box if the shape does not currently have one. More...
 
void destroyBoundingBox ()
 Destroys the bounding box if the shape currently has one. More...
 
bool mergeBoundingBox (BoundingBox *bb)
 Merges a bounding box with the bounding box of this. More...
 

Private Attributes

vector< VECTOR3 > vertices
 
BoundingBoxboundingbox = NULL
 

Detailed Description

Parameters
Asimple 3-dimensional geometric shape, with methods for shape manipulation and merging.
Note
Shapes produced by the factory functions will have orientation 0 0 1 0 1 0, with the origin of the coordinate system being at the center of the shape.

Member Function Documentation

SimpleShape SimpleShape::Box ( double  x,
double  y,
double  z 
)
static
Returns
A SimpleShape representing a Box.
Parameters
xThe dimension of the box in the x axis
yThe dimension of the box in the y axis
zThe dimension of the box in the z axis
Note
The origin (0,0,0) of the box represents its center.
SimpleShape SimpleShape::Circle ( double  radius,
UINT  segments 
)
static
Returns
A SimpleShape representing a circle.
Parameters
radiusthe radius of the circle
segmentsThe number of radial segments on the circle
void SimpleShape::createBoundingBox ( )
private

Creates the bounding box if the shape does not currently have one.

Note
To recreate a bounding box, call destroyBoundingBox() first.
See also
destroyBoundingBox()
SimpleShape SimpleShape::Cylinder ( double  radius,
double  height,
UINT  segments 
)
static
Returns
A SimpleShape representing a cylinder.
Parameters
radiusThe radius of the cylinder. The height of the cylinder.
segmentsThe number of radial segments to be generated.
void SimpleShape::destroyBoundingBox ( )
private

Destroys the bounding box if the shape currently has one.

See also
createBoundingBox()
BoundingBox * SimpleShape::GetBoundingBox ( )

returns an axis-aligned bounding box of the shape.

Note
bounding boxes are generated when this method is first called to avoid unnecessary calculations, since they have to be recalculated every time a shape is transformed. Even after generation bounding boxes are not regenerated until this method is called again, so you are guaranteed to get the currently valid bounding box with a minimum of overhead. Still, alternating boundingbox querying and transformation will result in siginificant cost increas and should be avoided!
void SimpleShape::GetVertices ( vector< VECTOR3 > &  OUT_vertexlist)
inline

sets a reference to the shapes vertex list.

Parameters
OUT_vertexlistvector reference that will be set to the shapes vertex list.
void SimpleShape::Merge ( SimpleShape  merger)

merges another shape into this one.

Note
Does not check for vertex overlap!
Parameters
mergerThe shape to be merged with this.
bool SimpleShape::mergeBoundingBox ( BoundingBox bb)
private

Merges a bounding box with the bounding box of this.

Returns
true if successful, false if not.
Note
In order to successfully merge a bounding box, this shape must already have calculated its bounding box.
SimpleShape SimpleShape::Rectangle ( double  width,
double  height 
)
static
Returns
A SimpleShape representing a rectangle.
Parameters
widthThe dimension of the rectangle in the z axis
hegtThe dimension of the rectangle in the x axis
Note
width and height will always be treated as positive, even if a negative value is passed!
Width of the rectangle is along the z axis, height along x.
void SimpleShape::Rotate ( MATRIX3  matrix)

Rotates a shape by a matrix.

Parameters
matrixrotation matrix containing the desired rotation
void SimpleShape::Scale ( VECTOR3  scale)

Scales a shape in x y z.

Note
0 0 0 is assumed as the origin of the scaling!
Parameters
scaleDefines the scale factors in x y z
UINT SimpleShape::Size ( )
inline
Returns
The number of vertices in the shape
SimpleShape SimpleShape::Sphere ( double  radius,
UINT  segments 
)
static
Returns
A SimpleShape representing a sphere.
Parameters
radiusThe radius of the sphere
segmentsNumber of radial segments on the sphere
Note
the poles of the sphere are aligned with the z-axis!
void SimpleShape::Translate ( VECTOR3  offset)

translates a shape by the demanded offset

Parameters
offsetThe offset by which the shape is to be translated

The documentation for this class was generated from the following files: