Workspace 6.21.5
Public Member Functions | Protected Member Functions | List of all members
Transform Class Reference

Provides a transformable item to be placed in a Scene. More...

#include <Rendering/SceneComponents/transform.h>

Inheritance diagram for Transform:
[legend]

Public Member Functions

 Transform (const QString &id="")
 
 ~Transform () override
 
bool addChild (SceneItem &item)
 
void clearChildren ()
 
Transformclone () const override
 
SceneItemgetChild (unsigned i)
 
const SceneItemgetChild (unsigned i) const
 
Mesh::TransformMatrixgetMatrix ()
 
const Mesh::TransformMatrixgetMatrix () const
 
Mesh::TransformMatrix getMatrixGlobal () const override
 
Mesh::TransformMatrix getMatrixLocal () const override
 
virtual ScenegetScene ()
 
ShadergetSymbolShader () const
 
bool isSymbolVisible () const
 
unsigned numChildren () const
 
void removeChild (SceneItem &item)
 
void setMatrix (const Mesh::TransformMatrix &matrix)
 
void setSymbolShader (Shader *shader)
 
void setSymbolVisible (bool b)
 
const TransformtoTransform () const override
 
TransformtoTransform () override
 
void updateGlobalMatrix () override
 
bool visit (SceneProcessor &processor) override
 
- Public Member Functions inherited from SceneItem
 ~SceneItem () override
 
SceneItemclone () const override=0
 
bool getEnabled () const
 
const QString & getId () const
 
const Mesh::BoundingBoxMinimalgetLocalBoundingBox () const
 
virtual Mesh::TransformMatrix getMatrixGlobal () const
 
virtual Mesh::TransformMatrix getMatrixLocal () const
 
const QString & getName () const
 
Mesh::TransformMatrix getParentMatrixGlobal () const
 
TransformgetParentTransform ()
 
void setEnabled (bool b)
 
void setId (const QString &itemId)
 
virtual void setLocalBoundingBox (const Mesh::BoundingBoxMinimal &bb)
 
void setName (const QString &name)
 
virtual TransformtoTransform ()
 
virtual const TransformtoTransform () const
 
virtual void updateGlobalMatrix ()
 
virtual bool visit (SceneProcessor &processor)=0
 
- Public Member Functions inherited from Observable
virtual ~Observable ()
 
void attachObserver (Observer &observer)
 
void destroy ()
 
void detachObserver (Observer &observer)
 
void notifyEvent (const ObservableEvent &event)
 
- Public Member Functions inherited from Clonable
virtual ~Clonable ()=default
 
virtual Clonableclone () const =0
 

Protected Member Functions

 Transform (const Transform &t)
 
- Protected Member Functions inherited from SceneItem
 SceneItem (const QString &id)
 
 SceneItem (const SceneItem &item)
 
virtual void addToScene (Scene &scene, const QString &opIdPath="")
 
bool isTransformModified () const
 
SceneItemoperator= (const SceneItem &item)
 
void setTransformModified (bool b)
 
- Protected Member Functions inherited from Observable
 Observable ()
 
 Observable (const Observable &)
 

Detailed Description

Transform objects are a fundamental part of any Scene. They can be used to position and orientate objects, including other transforms, so that any SceneItem can be added to a Scene and moved relative to other objects in the scene. Transforms provide a heirarchical tree structure for organizing parent-child relationships between objects.

Some items can only be added to a scene as a child of a Transform. The MeshModelInstance class is a prime example. Other objects might not normally be added as a child of a transform (such as lights or cameras), but doing so can allow interesting effects such as a light or camera which follows the movement of some object. A car headlight would be a perfect application for adding a light as a child of a transform to ensure that the light stays with a MeshModelInstance of the car body.

Constructor & Destructor Documentation

◆ Transform() [1/2]

Transform ( const Transform t)
protected

◆ Transform() [2/2]

Transform ( const QString &  id = "")

◆ ~Transform()

~Transform ( )
override

Member Function Documentation

◆ addChild()

bool addChild ( SceneItem item)
Parameters
itemThe item we wish to add to the transform as a child.

◆ clearChildren()

void clearChildren ( )

All children will be removed from the transform. No children will be deleted, they are simply removed from this transform and made parentless.

◆ clone()

Transform * clone ( ) const
overridevirtual
Returns
A clone of this object.
Note
Subclasses would normally return their own type rather than the Clonable type. The C++ language rules allow a more derived type to be returned from a virtual function and the compiler will still treat it as a valid override.

Implements SceneItem.

◆ getChild() [1/2]

SceneItem & getChild ( unsigned  i)
Parameters
i
Returns

◆ getChild() [2/2]

const SceneItem & getChild ( unsigned  i) const
Parameters
i
Returns

◆ getMatrix() [1/2]

Mesh::TransformMatrix & getMatrix ( )
Returns
The local co-ordinate transform provided by this object only. It does not include the effect of it's parent (if present).
See also
getGlobalMatrix(), setMatrix()

◆ getMatrix() [2/2]

const Mesh::TransformMatrix & getMatrix ( ) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ getMatrixGlobal()

Mesh::TransformMatrix getMatrixGlobal ( ) const
overridevirtual
Returns
The transform matrix in global (world) coordinates. Equivalent to all of this transform's parent transforms' transform matrices multiplied together with this transform's transform matrix.

Reimplemented from SceneItem.

◆ getMatrixLocal()

Mesh::TransformMatrix getMatrixLocal ( ) const
overridevirtual
Returns

Reimplemented from SceneItem.

◆ getScene()

Scene * getScene ( )
virtual
Returns
The scene to which this transform belongs, or a null pointer if it is not part of a scene.

If this transform is added as a child to another transform, the getScene() function will automatically return the scene of the parent by querying the parent for its scene. This sequence continues until the top level transform is reached. If the top level transform is part of a scene, it will know the scene to which it belongs and return that.

◆ getSymbolShader()

Shader * getSymbolShader ( ) const
Returns

◆ isSymbolVisible()

bool isSymbolVisible ( ) const
Returns
True if the transform's symbol and should be visually represented in output scenes when symbols are displayed.

◆ numChildren()

unsigned numChildren ( ) const
Returns

◆ removeChild()

void removeChild ( SceneItem item)
Parameters
itemThe item to remove. It will not be deleted.

◆ setMatrix()

void setMatrix ( const Mesh::TransformMatrix matrix)
Parameters
matrixThe new matrix to assign to this transform.
See also
getMatrix()

◆ setSymbolShader()

void setSymbolShader ( Shader shader)
Parameters
shaderSets the shader for the transform.

◆ setSymbolVisible()

void setSymbolVisible ( bool  b)
Parameters
bControls the visibility of the transform (whether to display it).

◆ toTransform() [1/2]

const Transform * toTransform ( ) const
overridevirtual

Reimplemented from SceneItem.

◆ toTransform() [2/2]

Transform * toTransform ( )
overridevirtual
Returns
This SceneItem as a Transform or null if it's not a type of Transform

Reimplemented from SceneItem.

◆ updateGlobalMatrix()

void updateGlobalMatrix ( )
overridevirtual

Reimplemented from SceneItem.

◆ visit()

bool visit ( SceneProcessor processor)
overridevirtual
Parameters
processor
Returns

Implements SceneItem.