scg3  0.6
scg::GeometryCoreFactory Class Reference

A factory to create geometry cores. More...

#include "GeometryCoreFactory.h"

Collaboration diagram for scg::GeometryCoreFactory:
[legend]

Classes

struct  Face
 
struct  FaceEntry
 
struct  OBJModel
 

Public Member Functions

 GeometryCoreFactory ()
 
 GeometryCoreFactory (const std::string &filePath)
 
virtual ~GeometryCoreFactory ()
 
void addFilePath (const std::string &filePath)
 
GeometryCoreSP createModelFromOBJFile (const std::string &fileName)
 
GeometryCoreSP createRectangle (glm::vec2 sizeXY)
 
GeometryCoreSP createCube (GLfloat size)
 
GeometryCoreSP createCuboid (glm::vec3 sizeXYZ)
 
GeometryCoreSP createSphere (GLfloat radius, int nSlices, int nStacks)
 
GeometryCoreSP createCone (GLfloat radius, GLfloat height, int nSlices, int nStacks, bool hasCap=true)
 
GeometryCoreSP createCylinder (GLfloat radius, GLfloat height, int nSlices, int nStacks, bool hasCaps=true)
 
GeometryCoreSP createConicalFrustum (GLfloat baseRadius, GLfloat topRadius, GLfloat height, int nSlices, int nStacks, bool hasCaps=true)
 
GeometryCoreSP createTeapot (GLfloat size)
 
GeometryCoreSP createTeapotFlat (GLfloat size)
 
GeometryCoreSP createXYZAxes (GLfloat size)
 
GeometryCoreSP createRGBCube (GLfloat size)
 

Protected Member Functions

int loadOBJFile_ (const std::string &fileName, OBJModel &model) const
 

Protected Attributes

std::vector< std::string > filePaths_
 

Detailed Description

A factory to create geometry cores.

Examples
scg3_minimal_example.cpp, and scg3_table_scene_example.cpp.

Definition at line 40 of file GeometryCoreFactory.h.

Constructor & Destructor Documentation

◆ GeometryCoreFactory() [1/2]

scg::GeometryCoreFactory::GeometryCoreFactory ( )

Constructor.

◆ GeometryCoreFactory() [2/2]

scg::GeometryCoreFactory::GeometryCoreFactory ( const std::string &  filePath)

Constructor with one or more file paths to be searched for model files. More than one file paths can be defined using ';' or ',' as delimiter.

Example: addFilePath("../models1;../models2")

◆ ~GeometryCoreFactory()

virtual scg::GeometryCoreFactory::~GeometryCoreFactory ( )
virtual

Destructor.

Member Function Documentation

◆ addFilePath()

void scg::GeometryCoreFactory::addFilePath ( const std::string &  filePath)

Add one or more file paths to be searched for model files. More than one file paths can be defined using ';' or ',' as delimiter.

Example: addFilePath("../textures1;../textures2")

◆ createCone()

GeometryCoreSP scg::GeometryCoreFactory::createCone ( GLfloat  radius,
GLfloat  height,
int  nSlices,
int  nStacks,
bool  hasCap = true 
)

Create cone along z axis and centered at origin with normals, tangents, binormals, and texture coordinates (2 * nSlices * nStacks triangles for lateral surface plus nSlices triangles for cap).

Parameters
radiusbase radius in xy plane
heightheight in z direction
nSlicesnumber of slices, i.e., rectangular faces in circumference direction
nStacksnumber of stacks, i.e., rectangular faces in height direction
hasCaptrue if base cap shall be modeled (default: true)

◆ createConicalFrustum()

GeometryCoreSP scg::GeometryCoreFactory::createConicalFrustum ( GLfloat  baseRadius,
GLfloat  topRadius,
GLfloat  height,
int  nSlices,
int  nStacks,
bool  hasCaps = true 
)

Create conical frustum (or cylinder for baseRadius = topRadius) along z axis and centered at origin with normals, tangents, binormals, and texture coordinates (2 * nSlices * nStacks triangles for lateral surface plus nSlices triangles per cap). Called by createCone() and createCylinder().

Parameters
baseRadiusbase radius in x and y direction
topRadiustop radius in x and y direction (must be <= baseRadius)
heightheight in z direction
nSlicesnumber of slices, i.e., rectangular faces in circumference direction
nStacksnumber of stacks, i.e., rectangular faces in height direction
hasCapstrue if base and top caps shall be modeled (default: true)

◆ createCube()

GeometryCoreSP scg::GeometryCoreFactory::createCube ( GLfloat  size)

Create cube with normals, tangents, binormals, and texture coordinates (12 triangles).

Parameters
sizeedge length

◆ createCuboid()

GeometryCoreSP scg::GeometryCoreFactory::createCuboid ( glm::vec3  sizeXYZ)

Create cuboid with normals, tangents, binormals, and texture coordinates (12 triangles).

Parameters
sizeXYZedge length in xyz directions
Examples
scg3_table_scene_example.cpp.

◆ createCylinder()

GeometryCoreSP scg::GeometryCoreFactory::createCylinder ( GLfloat  radius,
GLfloat  height,
int  nSlices,
int  nStacks,
bool  hasCaps = true 
)

Create cylinder along z axis and centered at origin with normals, tangents, binormals, and texture coordinates (2 * nSlices * nStacks triangles for lateral surface plus nSlices triangles per cap).

Parameters
radiusradius in xy plane
heightheight in z direction
nSlicesnumber of slices, i.e., rectangular faces in circumference direction
nStacksnumber of stacks, i.e., rectangular faces in height direction
hasCapstrue if base and top caps shall be modeled (default: true)

◆ createModelFromOBJFile()

GeometryCoreSP scg::GeometryCoreFactory::createModelFromOBJFile ( const std::string &  fileName)

Load model from OBJ Wavefront file.

Only the follwoing OBJ tags are used: v, vt, vn, f. If normals are not definied explicitly, they are created separately for each triangle (as in the case of flat shading); no smoothing of normals is applied.

Parameters
fileNamefile name to be searched for in known file paths

◆ createRectangle()

GeometryCoreSP scg::GeometryCoreFactory::createRectangle ( glm::vec2  sizeXY)

Create rectangle in xy plane with normals, tangents, binormals, and texture coordinates (2 triangles).

Parameters
sizeXYedge length in xy directions

◆ createRGBCube()

GeometryCoreSP scg::GeometryCoreFactory::createRGBCube ( GLfloat  size)

Create RGB cube with vertex colors (12 triangles).

Parameters
sizeedge length

◆ createSphere()

GeometryCoreSP scg::GeometryCoreFactory::createSphere ( GLfloat  radius,
int  nSlices,
int  nStacks 
)

Create sphere centered at origin with normals, tangents, binormals, and texture coordinates (2 * nSlices * nStacks triangles).

Parameters
radiussphere radius
nSlicesnumber of slices, i.e., rectangular faces in longitudinal direction
nStacksnumber of stacks, i.e., rectangular faces in latitudinal direction

◆ createTeapot()

GeometryCoreSP scg::GeometryCoreFactory::createTeapot ( GLfloat  size)

Create Utah teapot along z axis and centered at origin with normals, tangents, binormals, and texture coordinates (1024 triangles).

Data source: https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/sdk/demos/google/shiny-teapot/index.html

Parameters
sizeapproximate diameter
Examples
scg3_minimal_example.cpp, and scg3_table_scene_example.cpp.

◆ createTeapotFlat()

GeometryCoreSP scg::GeometryCoreFactory::createTeapotFlat ( GLfloat  size)

Create Utah teapot along z axis and centered at origin with normals and texture coordinates (1024 triangles), using a fixed normal per triangle optimal for flat shading.

Data source: https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/sdk/demos/google/shiny-teapot/index.html

Parameters
sizeapproximate diameter

◆ createXYZAxes()

GeometryCoreSP scg::GeometryCoreFactory::createXYZAxes ( GLfloat  size)

Create xyz coordinate axes with vertex colors (3 lines).

Parameters
sizeline length

◆ loadOBJFile_()

int scg::GeometryCoreFactory::loadOBJFile_ ( const std::string &  fileName,
OBJModel model 
) const
protected

Load and parse an OBJ Wavefront file and create a model.

Only the follwoing OBJ tags are used: v, vt, vn, f. If normals are not definied explicitly, they are created separately for each triangle (as in the case of flat shading); no smoothing of normals is applied.

Member Data Documentation

◆ filePaths_

std::vector<std::string> scg::GeometryCoreFactory::filePaths_
protected

Definition at line 248 of file GeometryCoreFactory.h.


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