CMSC23740 Common Code Library
Support code for CS23740 programming projects
Loading...
Searching...
No Matches
cs237::gobj Namespace Reference

Classes

struct  Obj
 a geometric object More...
 

Enumerations

enum class  VertexAttrs : uint32_t { ePos = kVAttrPosBit , ePosNorm = kVAttrPosBit | kVAttrNormBit , ePosTex = kVAttrPosBit | kVAttrTCBit , ePosNormTex = kVAttrPosBit | kVAttrNormBit | kVAttrTCBit }
 specifying the attributes of the generated object More...
 

Functions

bool hasNormals (VertexAttrs attrs)
 Does a vertex attribute specification include normals?
 
bool hasTextureCoords (VertexAttrs attrs)
 Does a vertex attribute specification include texture coordinates?
 
Objcube (VertexAttrs attrs, glm::vec3 center, float width)
 
Objsphere (VertexAttrs attrs, glm::vec3 center, float radius, uint32_t slices, uint32_t stacks)
 
Objcone (VertexAttrs attrs, glm::vec3 pos, glm::vec3 dir, float radius, float height, uint32_t slices, uint32_t stacks)
 

Variables

constexpr uint32_t kVAttrPosBit = (1 << 0)
 bit mask for the various vertex attributes
 
constexpr uint32_t kVAttrNormBit = (1 << 1)
 normal vector attribute
 
constexpr uint32_t kVAttrTCBit = (1 << 2)
 texture coordinate attribute
 
constexpr uint32_t kVAttrTanBit = (1 << 3)
 tangent vector attribute
 

Enumeration Type Documentation

◆ VertexAttrs

enum class cs237::gobj::VertexAttrs : uint32_t
strong

specifying the attributes of the generated object

Enumerator
ePos 

position

ePosNorm 

position+normal

ePosTex 

position+texture coord

ePosNormTex 

all attributes

Function Documentation

◆ cone()

Obj * cs237::gobj::cone ( VertexAttrs attrs,
glm::vec3 pos,
glm::vec3 dir,
float radius,
float height,
uint32_t slices,
uint32_t stacks )

creates a cone shaped triange mesh

Parameters
attrsspecify the attributes of the cones's vertices
posthe apex of the cone
dirthe direction in which the cone is pointing (from the apex to the center of the base)
radiusthe radius of the cone's base
heightthe height of the cone (distance from base to apex)
slicesthe number slices around the sides of the cone; must be at least 6
stacksthe number of segments between the base and the apex of the cone
Returns
a OBJ::Group object that holds the vertex data for the cone. Returns nullptr if the radius or height is not greater than zero.

Note that the vertices of the mesh lie on the surface of the cone. To produce a mesh that contains the cone, you need to scale the radius by $\frac{1}{\cos(\frac{2\pi}{\mathit{slices}})}$.

◆ cube()

Obj * cs237::gobj::cube ( VertexAttrs attrs,
glm::vec3 center,
float width )

construct an axis-aligned cube centered at the origin

Parameters
attrsspecify the attributes of the sphere's vertices
centerthe cube's center
widththe width of a side
Returns
a OBJ::Group object that holds the vertex data for the cube. Returns nullptr if the width is not greater than zero.

◆ hasNormals()

bool cs237::gobj::hasNormals ( VertexAttrs attrs)
inline

Does a vertex attribute specification include normals?

◆ hasTextureCoords()

bool cs237::gobj::hasTextureCoords ( VertexAttrs attrs)
inline

Does a vertex attribute specification include texture coordinates?

◆ sphere()

Obj * cs237::gobj::sphere ( VertexAttrs attrs,
glm::vec3 center,
float radius,
uint32_t slices,
uint32_t stacks )

create a mesh to represent a sphere centered at the origin

Parameters
attrsspecify the attributes of the sphere's vertices
centerthe sphere's center
radiusthe sphere's radius
slicesthe number of horizontal triangles around a band; must be at least 5.
stacksthe number of horizontal bands around the sphere; must be at least 5.
Returns
a OBJ::Group object that holds the vertex data for the sphere. Returns nullptr if the radius is not greater than zero.

Note that the vertices of the mesh lie on the surface of the sphere.

Variable Documentation

◆ kVAttrNormBit

uint32_t cs237::gobj::kVAttrNormBit = (1 << 1)
constexpr

normal vector attribute

◆ kVAttrPosBit

uint32_t cs237::gobj::kVAttrPosBit = (1 << 0)
constexpr

bit mask for the various vertex attributes

vertex position (required)

◆ kVAttrTanBit

uint32_t cs237::gobj::kVAttrTanBit = (1 << 3)
constexpr

tangent vector attribute

◆ kVAttrTCBit

uint32_t cs237::gobj::kVAttrTCBit = (1 << 2)
constexpr

texture coordinate attribute