The small3d library
Public Member Functions | Public Attributes | Friends | List of all members
small3d::SceneObject Class Reference

An object that appears on the 3D scene. It is made up of a Model, together with information for positioning, rotation and collision detection. Skeletal animation is supported if contained in the Model. Otherwise, frame based animation can be used if the SceneObject is constructed with a vector of Models, each of which will be used as an animation frame. More...

#include <SceneObject.hpp>

Public Member Functions

 SceneObject (const std::string &name, const Model &model, const uint32_t boundingBoxSubdivisions=0)
 Model based constructor (skeletal animation) More...
 
 SceneObject (const std::string &name, const Model &&model, const uint32_t boundingBoxSubdivisions=0)
 Model based constructor (skeletal animation) More...
 
 SceneObject (const std::string &name, const std::vector< std::shared_ptr< Model >> &models, const uint32_t boundingBoxSubdivisions=0)
 Model vector based constructor (animation using frames) More...
 
 ~SceneObject ()=default
 Destructor.
 
ModelgetModel ()
 Get the object's model. More...
 
uint64_t getCurrentPose ()
 Get the current animation pose. More...
 
void setAnimation (uint32_t animationIdx)
 Set the current animation. More...
 
std::vector< ModelgetBoundingBoxSetModels ()
 Get the bounding box set as models (for debug-rendering) More...
 
std::vector< BoundingBoxSet::extremes > & getBoundingBoxSetExtremes ()
 Get the bounding box set extremes (min and max coords) More...
 
const std::string getName () const
 Get the name of the object. More...
 
void setRotation (const Vec3 &rotation)
 : Set the rotation of the object. (Overwrites transformation entered via setTransformation) More...
 
void rotate (const Vec3 &rotation)
 : Modify the rotation of the object More...
 
void setTransformation (const Mat4 &rotation)
 : Set the transformation matrix of the object. (Overwrites rotation entered via setRotation) More...
 
const Vec3 getOrientation () const
 : Get the orientation of the object More...
 
const Mat4getTransformation () const
 : Get the tranformation matrix of the object More...
 
const Vec3getRotationXYZ () const
 : Get the rotation of the object in x, y, z representation. This will NOT work if the rotation was set via the setTransformation function. More...
 
void startAnimating (bool repeat=true)
 Start animating the object. More...
 
void stopAnimating ()
 Stop animating the object.
 
void resetAnimation ()
 Reset the animation sequence (go to the first frame)
 
void setFrameDelay (const int delay)
 Set the animation speed. More...
 
void animate ()
 Process animation (progress current frame if necessary)
 
bool contains (const Vec3 &point) const
 Check if the bounding boxes of this object contain a given point. More...
 
bool containsCorners (const SceneObject &otherObject) const
 Check if the bounding boxes of this object contain a corner of the bounding boxes of another object. More...
 

Public Attributes

Vec3 position = Vec3(0.0f, 0.0f, 0.0f)
 

Friends

class Renderer
 

Detailed Description

An object that appears on the 3D scene. It is made up of a Model, together with information for positioning, rotation and collision detection. Skeletal animation is supported if contained in the Model. Otherwise, frame based animation can be used if the SceneObject is constructed with a vector of Models, each of which will be used as an animation frame.

Constructor & Destructor Documentation

◆ SceneObject() [1/3]

small3d::SceneObject::SceneObject ( const std::string &  name,
const Model model,
const uint32_t  boundingBoxSubdivisions = 0 
)

Model based constructor (skeletal animation)

Parameters
nameThe name of the object
modelThe Model for which to create the object (lvalue)
boundingBoxSubdivisionsHow many times to subdivide the initially created bounding box, getting more accurate collision detection at the expense of performance.

◆ SceneObject() [2/3]

small3d::SceneObject::SceneObject ( const std::string &  name,
const Model &&  model,
const uint32_t  boundingBoxSubdivisions = 0 
)

Model based constructor (skeletal animation)

Parameters
nameThe name of the object
modelThe Model for which to create the object (rvalue)
boundingBoxSubdivisionsHow many times to subdivide the initially created bounding box, getting more accurate collision detection at the expense of performance.

◆ SceneObject() [3/3]

small3d::SceneObject::SceneObject ( const std::string &  name,
const std::vector< std::shared_ptr< Model >> &  models,
const uint32_t  boundingBoxSubdivisions = 0 
)

Model vector based constructor (animation using frames)

Parameters
nameThe name of the object
modelsThe Model for which to create the object (rvalue)
boundingBoxSubdivisionsHow many times to subdivide the initially created bounding box, getting more accurate collision detection at the expense of performance.

Member Function Documentation

◆ contains()

bool small3d::SceneObject::contains ( const Vec3 point) const

Check if the bounding boxes of this object contain a given point.

Parameters
pointThe point
Returns
True if the point is contained in the bounding boxes of the object, False otherwise.

◆ containsCorners()

bool small3d::SceneObject::containsCorners ( const SceneObject otherObject) const

Check if the bounding boxes of this object contain a corner of the bounding boxes of another object.

Parameters
otherObjectThe other object.
Returns
True if the bounding boxes of this object contain a corner of the bounding boxes of another object, False otherwise.

◆ getBoundingBoxSetExtremes()

std::vector< BoundingBoxSet::extremes > & small3d::SceneObject::getBoundingBoxSetExtremes ( )

Get the bounding box set extremes (min and max coords)

Returns
The bounding box set extremes

◆ getBoundingBoxSetModels()

std::vector< Model > small3d::SceneObject::getBoundingBoxSetModels ( )

Get the bounding box set as models (for debug-rendering)

Returns
The bounding box set models

◆ getCurrentPose()

uint64_t small3d::SceneObject::getCurrentPose ( )

Get the current animation pose.

Returns
The current animation pose

◆ getModel()

Model & small3d::SceneObject::getModel ( )

Get the object's model.

Returns
The object's model

◆ getName()

const std::string small3d::SceneObject::getName ( ) const

Get the name of the object.

Returns
The name of the object

◆ getOrientation()

const Vec3 small3d::SceneObject::getOrientation ( ) const

: Get the orientation of the object

Returns
The orientation of the object

◆ getRotationXYZ()

const Vec3 & small3d::SceneObject::getRotationXYZ ( ) const

: Get the rotation of the object in x, y, z representation. This will NOT work if the rotation was set via the setTransformation function.

Returns
The rotation in x, y, z representation

◆ getTransformation()

const Mat4 & small3d::SceneObject::getTransformation ( ) const

: Get the tranformation matrix of the object

Returns
The tranformation matrix

◆ rotate()

void small3d::SceneObject::rotate ( const Vec3 rotation)

: Modify the rotation of the object

Parameters
rotationThe rotation to modify by (x, y, z)

◆ setAnimation()

void small3d::SceneObject::setAnimation ( uint32_t  animationIdx)

Set the current animation.

Parameters
animationIdxThe index of the current animation

◆ setFrameDelay()

void small3d::SceneObject::setFrameDelay ( const int  delay)

Set the animation speed.

Parameters
delayThe delay between each animation frame, expressed in number of game frames

◆ setRotation()

void small3d::SceneObject::setRotation ( const Vec3 rotation)

: Set the rotation of the object. (Overwrites transformation entered via setTransformation)

Parameters
rotationThe rotation (x, y, z)

◆ setTransformation()

void small3d::SceneObject::setTransformation ( const Mat4 rotation)

: Set the transformation matrix of the object. (Overwrites rotation entered via setRotation)

Parameters
rotationThe tranformation matrix

◆ startAnimating()

void small3d::SceneObject::startAnimating ( bool  repeat = true)

Start animating the object.

Parameters
repeatRepeat the animation after it has finished?

Member Data Documentation

◆ position

Vec3 small3d::SceneObject::position = Vec3(0.0f, 0.0f, 0.0f)

Position of the object


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