Kale
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
Kale::PathNode< T > Class Template Reference

#include <PathNodeGL.hpp>

+ Inheritance diagram for Kale::PathNode< T >:

Classes

struct  BezierWeights
 

Public Types

enum class  StrokeStyle { Neither = 0 , Both = 1 , Inside = 2 , Outside = 3 }
 

Public Member Functions

 PathNode ()
 
 PathNode (const JSON &json)
 
 PathNode (const Path &path, bool fill=true, StrokeStyle stroke=StrokeStyle::Neither)
 
- Public Member Functions inherited from Kale::Transformable
Transform getFullTransform () const
 
- Public Member Functions inherited from Kale::Collidable
Rect getBoundingBox () const
 

Public Attributes

std::optional< StateAnimatable< Path > > pathFSM
 
std::shared_ptr< SkeletalAnimatableskeletalAnimatable
 
std::optional< std::vector< BezierWeights > > skeletalWeights
 
std::optional< PathbasePath
 
float zPosition = 1.0f
 
bool fill = true
 
StrokeStyle stroke = StrokeStyle::Neither
 
float strokeRadius = 20.0f
 
Color color = Color(0x333333)
 
Color strokeColor = Color(0x555555)
 
- Public Attributes inherited from Kale::Node
std::string name
 
const float updateTime = 100.0f
 
const float preUpdateTime = 100.0f
 
- Public Attributes inherited from Kale::Transformable
std::optional< StateAnimatable< Transform > > transformFSM
 
Transform transform
 

Protected Member Functions

virtual void begin (const Scene &scene) override
 
virtual void preUpdate (size_t threadNum, const Scene &scene, float deltaTime) override
 
virtual void render (const Camera &camera, float deltaTime) const override
 
virtual void end (const Scene &scene) override
 
virtual void begin (const Scene &scene) override
 
virtual void render (const Camera &camera, float deltaTime) const override
 
virtual void end (const Scene &scene) override
 
- Protected Member Functions inherited from Kale::Node
virtual void update (size_t threadNum, const Scene &scene, float deltaTime)
 
 Node ()
 
 Node (float preUpdateTime, float updateTime)
 
- Protected Member Functions inherited from Kale::Transformable
void updateTransform (float deltaTime)
 

Private Member Functions

void updateBoundingBox ()
 

Static Private Member Functions

static void setup ()
 
static void cleanup ()
 

Private Attributes

std::unique_ptr< OpenGL::VertexArray< Vector2f, 2 > > vertexArray
 
Path path
 

Static Private Attributes

static std::unique_ptr< const OpenGL::Shadershader = nullptr
 
static unsigned int cameraUniform
 
static unsigned int localUniform
 
static unsigned int vertexColorUniform
 
static unsigned int zPositionUniform
 
static unsigned int beziersUniform
 
static unsigned int numBeziersUniform
 
static unsigned int strokeUniform
 
static unsigned int fillUniform
 
static unsigned int strokeRadiusUniform
 
static unsigned int strokeColorUniform
 
static unsigned int posAttribute
 

Friends

class Application
 

Additional Inherited Members

- Protected Attributes inherited from Kale::Node
std::optional< std::mutex > mutex
 
- Protected Attributes inherited from Kale::Transformable
std::optional< TransformstateTransform
 
- Protected Attributes inherited from Kale::Collidable
Rect boundingBox
 

Detailed Description

template<typename T>
class Kale::PathNode< T >

Used for rendering filled bezier paths

Used for rendering filled bezier paths

Template Parameters
Anenum class containing all the animation states

Definition at line 50 of file PathNodeGL.hpp.

Member Enumeration Documentation

◆ StrokeStyle

Styles of rendering strokes on a path

Note
Inside and Outside only work when the path is closed. For an open path, this is undefined behavior.
Enumerator
Neither 
Both 
Inside 
Outside 

Definition at line 57 of file PathNodeGL.hpp.

Constructor & Destructor Documentation

◆ PathNode() [1/3]

template<typename T >
PathNode::PathNode ( )

Creates a blank pathnode with nothing to render

Definition at line 203 of file PathNodeGL.cpp.

◆ PathNode() [2/3]

template<typename T >
PathNode::PathNode ( const JSON & json)

Creates a path node based on the json saved values

Parameters
jsonThe json saved values

Definition at line 211 of file PathNodeGL.cpp.

◆ PathNode() [3/3]

template<typename T >
PathNode::PathNode ( const Path & path,
bool fill = true,
StrokeStyle stroke = StrokeStyle::Neither )

Creates a path node given the path to use

Parameters
pathThe path to use
fillWhether or not to fill the node
strokeWhether or not to stroke the node

Definition at line 237 of file PathNodeGL.cpp.

Member Function Documentation

◆ begin() [1/2]

template<typename T >
void PathNode::begin ( const Scene & scene)
overrideprotectedvirtual

Called when the node is added to the scene, guaranteed to be called before any updates & renders and from the main thread.

Parameters
sceneThe scene the node has been added to

Reimplemented from Kale::Node.

Definition at line 97 of file PathNodeGL.cpp.

◆ begin() [2/2]

template<typename T >
virtual void Kale::PathNode< T >::begin ( const Scene & scene)
inlineoverrideprotectedvirtual

Called when the node is added to the scene, guaranteed to be called before any updates & renders and from the main thread.

Parameters
sceneThe scene the node has been added to

Reimplemented from Kale::Node.

Definition at line 40 of file PathNodeVK.hpp.

◆ cleanup()

template<typename T >
void PathNode::cleanup ( )
staticprivate

Deletes shaders/cleans up

Definition at line 64 of file PathNodeGL.cpp.

◆ end() [1/2]

template<typename T >
void PathNode::end ( const Scene & scene)
overrideprotectedvirtual

Called when the node is removed from the scene, guaranteed to be called from the main thread

Reimplemented from Kale::Node.

Definition at line 196 of file PathNodeGL.cpp.

◆ end() [2/2]

template<typename T >
virtual void Kale::PathNode< T >::end ( const Scene & scene)
inlineoverrideprotectedvirtual

Called when the node is removed from the scene, guaranteed to be called from the main thread

Reimplemented from Kale::Node.

Definition at line 55 of file PathNodeVK.hpp.

◆ preUpdate()

template<typename T >
void PathNode::preUpdate ( size_t threadNum,
const Scene & scene,
float deltaTime )
overrideprotectedvirtual

Called prior to update, perfect place to do things such as updating the bounding box, etc

Parameters
threadNumthe index of the thread this update is called on
sceneThe scene being updated to
deltaTimeThe duration of the last frame in microseconds

Reimplemented from Kale::Node.

Definition at line 125 of file PathNodeGL.cpp.

◆ render() [1/2]

template<typename T >
void PathNode::render ( const Camera & camera,
float deltaTime ) const
overrideprotectedvirtual

Renders the node

Parameters
cameraThe camera to render with

Reimplemented from Kale::Node.

Definition at line 171 of file PathNodeGL.cpp.

◆ render() [2/2]

template<typename T >
virtual void Kale::PathNode< T >::render ( const Camera & camera,
float deltaTime ) const
inlineoverrideprotectedvirtual

Renders the node

Parameters
cameraThe camera to render with

Reimplemented from Kale::Node.

Definition at line 48 of file PathNodeVK.hpp.

◆ setup()

template<typename T >
void PathNode::setup ( )
staticprivate

Creates and compiles shaders

Creates and compiles shaders if not already compiled/created

Definition at line 31 of file PathNodeGL.cpp.

◆ updateBoundingBox()

template<typename T >
void PathNode::updateBoundingBox ( )
private

Updates the bounding box accounting for stroke

Definition at line 71 of file PathNodeGL.cpp.

Friends And Related Symbol Documentation

◆ Application

template<typename T >
friend class Application
friend

Definition at line 130 of file PathNodeGL.hpp.

Member Data Documentation

◆ basePath

template<typename T >
std::optional<Path> Kale::PathNode< T >::basePath

An optional path to be used for skeletal rigging. If a skeletal rig is provided, then this base path must be the path where all vertices are aligned with the skeleton's base form

Definition at line 183 of file PathNodeGL.hpp.

◆ beziersUniform

template<typename T >
unsigned int Kale::PathNode< T >::beziersUniform
staticprivate

Definition at line 108 of file PathNodeGL.hpp.

◆ cameraUniform

template<typename T >
unsigned int Kale::PathNode< T >::cameraUniform
inlinestaticprivate

The location of the uniform within the shader for rendering this node

Definition at line 107 of file PathNodeGL.hpp.

◆ color

template<typename T >
Color Kale::PathNode< T >::color = Color(0x333333)

The color of this path node

Definition at line 209 of file PathNodeGL.hpp.

◆ fill

template<typename T >
bool Kale::PathNode< T >::fill = true

Whether or not to fill the path when rendering

Note
This must be false if the path is open. Filling an open path results in undefined behavior

Definition at line 194 of file PathNodeGL.hpp.

◆ fillUniform

template<typename T >
unsigned int Kale::PathNode< T >::fillUniform
staticprivate

Definition at line 108 of file PathNodeGL.hpp.

◆ localUniform

template<typename T >
unsigned int Kale::PathNode< T >::localUniform
staticprivate

Definition at line 107 of file PathNodeGL.hpp.

◆ numBeziersUniform

template<typename T >
unsigned int Kale::PathNode< T >::numBeziersUniform
staticprivate

Definition at line 108 of file PathNodeGL.hpp.

◆ path

template<typename T >
Path Kale::PathNode< T >::path
private

The path being rendered

Definition at line 97 of file PathNodeGL.hpp.

◆ pathFSM

template<typename T >
std::optional<StateAnimatable<Path> > Kale::PathNode< T >::pathFSM

The FSM used for path states. Path nodes support FSM based animations, to use the FSM simply set the value of this optional and fill the map. Access to the FSM must be externally synchronized if done from multiple threads.

Definition at line 166 of file PathNodeGL.hpp.

◆ posAttribute

template<typename T >
unsigned int Kale::PathNode< T >::posAttribute
inlinestaticprivate

The location of the attribute within the shader for rendering this node

Definition at line 113 of file PathNodeGL.hpp.

◆ shader

template<typename T >
std::unique_ptr<const OpenGL::Shader> Kale::PathNode< T >::shader = nullptr
inlinestaticprivate

The shader used for rendering

Definition at line 102 of file PathNodeGL.hpp.

◆ skeletalAnimatable

template<typename T >
std::shared_ptr<SkeletalAnimatable> Kale::PathNode< T >::skeletalAnimatable

A skeletal animatable to use for animating this path node. Both pathFSM and skeletalAnimatable cannot be set at the same time.

Definition at line 171 of file PathNodeGL.hpp.

◆ skeletalWeights

template<typename T >
std::optional<std::vector<BezierWeights> > Kale::PathNode< T >::skeletalWeights

A vector of the skeletal weights for skeletal animations. This must be the same length as the number of beziers in the path, and it must be set if skeletalAnimatable isn't nullptr.

Definition at line 177 of file PathNodeGL.hpp.

◆ stroke

Whether or not to stroke the path when rendering

Definition at line 199 of file PathNodeGL.hpp.

◆ strokeColor

template<typename T >
Color Kale::PathNode< T >::strokeColor = Color(0x555555)

The color to stroke this path node with

Definition at line 214 of file PathNodeGL.hpp.

◆ strokeColorUniform

template<typename T >
unsigned int Kale::PathNode< T >::strokeColorUniform
staticprivate

Definition at line 108 of file PathNodeGL.hpp.

◆ strokeRadius

template<typename T >
float Kale::PathNode< T >::strokeRadius = 20.0f

The radius of the stroke if stroke is true

Definition at line 204 of file PathNodeGL.hpp.

◆ strokeRadiusUniform

template<typename T >
unsigned int Kale::PathNode< T >::strokeRadiusUniform
staticprivate

Definition at line 108 of file PathNodeGL.hpp.

◆ strokeUniform

template<typename T >
unsigned int Kale::PathNode< T >::strokeUniform
staticprivate

Definition at line 108 of file PathNodeGL.hpp.

◆ vertexArray

template<typename T >
std::unique_ptr<OpenGL::VertexArray<Vector2f, 2> > Kale::PathNode< T >::vertexArray
private

The vertex array used for rendering

Definition at line 92 of file PathNodeGL.hpp.

◆ vertexColorUniform

template<typename T >
unsigned int Kale::PathNode< T >::vertexColorUniform
staticprivate

Definition at line 107 of file PathNodeGL.hpp.

◆ zPosition

template<typename T >
float Kale::PathNode< T >::zPosition = 1.0f

The z position of this node, setting this allows for rendering in front of or behind other nodes.

Definition at line 188 of file PathNodeGL.hpp.

◆ zPositionUniform

template<typename T >
unsigned int Kale::PathNode< T >::zPositionUniform
staticprivate

Definition at line 107 of file PathNodeGL.hpp.


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