Cogs.Core
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
Cogs::Core::AxisCubeComponent Struct Reference

A cube with grids on the side faces. More...

#include <AxisCubeComponent.h>

Inheritance diagram for Cogs::Core::AxisCubeComponent:
Cogs::Core::DynamicComponent Cogs::ComponentModel::Component

Classes

struct  PerEdgeData
 
struct  PerFaceData
 

Public Member Functions

void initialize (Context *context)
 
void update ()
 
- Public Member Functions inherited from Cogs::ComponentModel::Component
class EntitygetContainer () const
 Get the container currently owning this component instance.
 
void setContainer (class Entity *container)
 Set the container owning this component instance.
 
template<typename ComponentType >
ComponentType * getComponent () const
 
COGSFOUNDATION_API ComponentgetComponent (const Reflection::Name &name) const
 
COGSFOUNDATION_API ComponentgetComponent (const Reflection::TypeId &id) const
 
template<typename ComponentType >
ComponentHandle getComponentHandle () const
 
COGSFOUNDATION_API ComponentHandle getComponentHandle (const Reflection::Name &name) const
 
COGSFOUNDATION_API ComponentHandle getComponentHandle (const Reflection::TypeId &id) const
 
void setActive ()
 Sets the component to the ComponentFlags::Active state.
 
bool isActive () const
 Gets if the component is currently set to the ComponentFlags::Active state.
 
void setChanged ()
 Sets the component to the ComponentFlags::Changed state with carry.
 
void setChangedTransient ()
 Sets the component to the ComponentFlags::Changed state without carry.
 
void setFieldChanged (const Reflection::FieldId fieldId)
 Sets the component to the ComponentFlags::Changed state without carry.
 
template<typename ClassType , typename FieldType >
void setFieldChanged (FieldType ClassType::*field)
 Sets a flag indicating that the given field has changed.
 
void setFieldChangedTransient (const Reflection::FieldId fieldId)
 Sets the component to the ComponentFlags::Changed state without carry.
 
bool hasChanged () const
 
bool hasAnyfieldChanged () const
 Gets if any fields have been changed.
 
bool hasFieldChanged (const Reflection::FieldId fieldId) const
 Gets if the field with the given id on this component instance has changed.
 
template<typename ClassType , typename FieldType >
bool hasFieldChanged (FieldType ClassType::*field) const
 Gets if the given field has changed.
 
void resetCarryChanged ()
 Reset the CarryChanged flag. Called at start of redraw. See ComponentFlags::CarryChanged.
 
void resetChanged ()
 Resets the changed state of the component, respecting any carry state set.
 
template<typename ClassType , typename FieldType >
Reflection::FieldId getFieldId (FieldType ClassType::*field) const
 Gets field ID of the given field.
 
void resetFieldsChanged ()
 Resets the state of all changed field flags.
 
void resetFieldChanged (const Reflection::FieldId fieldId)
 Resets the changed state of the given fieldId.
 
template<typename ClassType , typename FieldType >
void resetFieldChanged (FieldType ClassType::*field)
 Resets the changed state of the given field.
 
constexpr void setFlags (const uint32_t flags)
 Override all flags of the Component, setting the given flags.
 
constexpr void setFlag (const uint32_t flag)
 Set the given flags. Does not override the currently set flags.
 
constexpr void unsetFlag (const uint32_t flag)
 Unset the given flag. Does not remove the status of other than the given flags.
 
constexpr bool isSet (const uint32_t flag) const
 Checks if the given flag is set. Requires exact bit match if test of several bits.
 
constexpr void setTypeId (const Reflection::TypeId typeId)
 Set the Reflection::TypeId of the component.
 
constexpr Reflection::TypeId getTypeId () const
 Get the Reflection::TypeId of the component.
 
COGSFOUNDATION_API const Reflection::TypegetType () const
 Get the full Reflection::Type of the component.
 
constexpr void setIndex (const ComponentIndex index)
 Set the components pool index. For internal use only.
 
constexpr ComponentIndex getIndex () const
 Get the components pool index. For internal use only.
 
constexpr void setGeneration (uint16_t generation)
 Sets the component generation.
 
constexpr uint16_t getGeneration () const
 Gets the component generation.
 
size_t hash (size_t hashValue=Cogs::hash()) const
 Calculates a hash of this component's members.
 

Static Public Member Functions

static void registerType ()
 
- Static Public Member Functions inherited from Cogs::Core::DynamicComponent
static COGSCORE_DLL_API void registerType ()
 Register the type in the type system.
 
template<typename T >
static Reflection::TyperegisterDerivedType ()
 Convenience method for registering the type of a derived component.
 
- Static Public Member Functions inherited from Cogs::ComponentModel::Component
static COGSFOUNDATION_API void registerType ()
 Register the Component type in the global type database.
 
static COGSFOUNDATION_API Reflection::TypeId getComponentTypeId (const StringView &name)
 Get the type id of the component type with the given name.
 

Public Attributes

Contextcontext = nullptr
 
glm::vec3 minCorner = glm::vec3(-1.f)
 Minimum corner of the cube.
 
glm::vec3 maxCorner = glm::vec3(1.f)
 Maximum corner of the cube.
 
float zScale = 1.f
 Amount to scale the z-axis.
 
int maxAxisValues = 10
 The maximum number of axis annotation values to use.
 
std::vector< std::string > axisTitles
 Titles for the x,y,z-axises.
 
std::vector< std::string > unitNames
 Name of the x,y,z-axis units.
 
glm::vec3 unitScales = glm::vec3(1.f)
 Size of unit coordinate axis in unitname-units.
 
bool useAxisAnnotations = true
 If the axis cube should create axis annotation text.
 
bool autoAdjustToLargestDimension = false
 If the auto adjustment should make the box equal in size along all axes.
 
float tickSizeOffset = 0.05f
 
glm::vec4 textColor = glm::vec4(1.f)
 Color of text, to be forwarded to children.
 
float annotationGap = 100.0f
 Distance between axis annotations.
 
std::vector< WeakEntityPtrautoNodes
 Entities(Nodes) that are to be encased by this AxisCube.
 
glm::vec3 autoAdjustMargin = glm::vec3(0.1f)
 A margin applied to the bounding box of the encased Entity, this property only works alongside autoNodes.
 
EntityPtr topQuadMaterial
 
EntityPtr bottomQuadMaterial
 
EntityPtr frontQuadMaterial
 
EntityPtr backQuadMaterial
 
EntityPtr rightQuadMaterial
 
EntityPtr leftQuadMaterial
 
glm::vec3 adjustedMinCorner
 Minimum corner of the cube.
 
glm::vec3 adjustedMaxCorner
 Maximum corner of the cube.
 
glm::bvec3 markerFaces
 False if wall-marker should lie on min-face, true if max-face.
 
glm::mat4 worldToLocal
 Cached inverted local to world matrix.
 
- Public Attributes inherited from Cogs::Core::DynamicComponent
void * messageCallback = nullptr
 
void * userData = nullptr
 
size_t dynamicTypeInfoIndex = static_cast<size_t>(-1)
 

Private Member Functions

void updateQuadGeometry (int face, EntityPtr material)
 
void updateCorners ()
 
void updateAdjustedMinAndMax (const glm::vec3 &minCorner, const glm::vec3 &maxCorner)
 
void updateTickSizes ()
 
void updateFaceVisibilites (bool forceUpdate)
 
void updateEdgeVisibilites (bool forceUpdate)
 
void updateAxisLabels (bool forceUpdate)
 
void updateGridGeometry (int face)
 
void updateAnnotationAxes ()
 

Private Attributes

bool initialUpdate = true
 
glm::vec3 corners [8]
 Local-space positions of the eight corners.
 
glm::vec3 tickSizes
 Size of axis ticks (in unit-units):
 
float tickProtrusion = 0.0f
 Distance the grid lines protrude through the edge.
 
MaterialInstanceHandle gridMatInstH
 
MaterialInstanceHandle edgeMatInstH
 
std::vector< EntityPtrunprocessedAutoNodes
 
PerFaceData faces [6]
 
EntityPtr axisTitlesRightEntity
 
EntityPtr axisTitlesLeftEntity
 
PerEdgeData edges [12]
 

Detailed Description

A cube with grids on the side faces.

Coordinate systems

Local coordinate system is the coordinate system used by the rendering system, and minCorner and maxCorner are specified using this system. The unit coordinate system is the coordinate system used for grid lines and annotations. Local and unit coords are linked through zScale and unitScales,

unit.x = local.x*unitScales.x, unit.y = local.y*unitScales.y, and unit.z = (local.z/zScale)*unitScales.z.

Thus, zScale is the amount of exaggeration that has been applied to the underlying data before rendering (a zScale of 10 means that local coord z is 10 times larger than an un-exaggerated local coord z would have been). Further, unitScales specifies the number of unit-units there is in a local scale unit. That is, if local coords are in meters, and we want to the grid to use feet, we set unitScales to 1.0/0.3048=3.2808.

Tick sizes

First, the distance between min and max in unit coordinates is divided by maxAxisValues. We allow this distance to grow until we get a distance that is a nice round number (i.e., a power of 10), by rounding the 10-logarithm of up of the distance and raising 10 to this number, that is,

distance = 10^( ceil( log10( (max-min)/maxAxisValues ) ) ).

This expression yields the smallest distance that is a power of 10 and results in no more than maxAxisValues grid-lines along that axis.


Definition at line 58 of file AxisCubeComponent.h.

Member Function Documentation

◆ initialize()

void Cogs::Core::AxisCubeComponent::initialize ( Context context)

Definition at line 110 of file AxisCubeComponent.cpp.

◆ registerType()

void Cogs::Core::AxisCubeComponent::registerType ( )
static

Definition at line 74 of file AxisCubeComponent.cpp.

◆ update()

void Cogs::Core::AxisCubeComponent::update ( )

Definition at line 181 of file AxisCubeComponent.cpp.

◆ updateAdjustedMinAndMax()

void Cogs::Core::AxisCubeComponent::updateAdjustedMinAndMax ( const glm::vec3 &  minCorner,
const glm::vec3 &  maxCorner 
)
private

Definition at line 352 of file AxisCubeComponent.cpp.

◆ updateAnnotationAxes()

void Cogs::Core::AxisCubeComponent::updateAnnotationAxes ( )
private

Definition at line 276 of file AxisCubeComponent.cpp.

◆ updateAxisLabels()

void Cogs::Core::AxisCubeComponent::updateAxisLabels ( bool  forceUpdate)
private

Definition at line 421 of file AxisCubeComponent.cpp.

◆ updateCorners()

void Cogs::Core::AxisCubeComponent::updateCorners ( )
private

Definition at line 343 of file AxisCubeComponent.cpp.

◆ updateEdgeVisibilites()

void Cogs::Core::AxisCubeComponent::updateEdgeVisibilites ( bool  forceUpdate)
private

Definition at line 399 of file AxisCubeComponent.cpp.

◆ updateFaceVisibilites()

void Cogs::Core::AxisCubeComponent::updateFaceVisibilites ( bool  forceUpdate)
private

Definition at line 480 of file AxisCubeComponent.cpp.

◆ updateGridGeometry()

void Cogs::Core::AxisCubeComponent::updateGridGeometry ( int  face)
private

Definition at line 577 of file AxisCubeComponent.cpp.

◆ updateQuadGeometry()

void Cogs::Core::AxisCubeComponent::updateQuadGeometry ( int  face,
EntityPtr  material 
)
private

Definition at line 536 of file AxisCubeComponent.cpp.

◆ updateTickSizes()

void Cogs::Core::AxisCubeComponent::updateTickSizes ( )
private

Definition at line 366 of file AxisCubeComponent.cpp.

Member Data Documentation

◆ adjustedMaxCorner

glm::vec3 Cogs::Core::AxisCubeComponent::adjustedMaxCorner

Maximum corner of the cube.

Definition at line 87 of file AxisCubeComponent.h.

◆ adjustedMinCorner

glm::vec3 Cogs::Core::AxisCubeComponent::adjustedMinCorner

Minimum corner of the cube.

Definition at line 86 of file AxisCubeComponent.h.

◆ annotationGap

float Cogs::Core::AxisCubeComponent::annotationGap = 100.0f

Distance between axis annotations.

Definition at line 74 of file AxisCubeComponent.h.

◆ autoAdjustMargin

glm::vec3 Cogs::Core::AxisCubeComponent::autoAdjustMargin = glm::vec3(0.1f)

A margin applied to the bounding box of the encased Entity, this property only works alongside autoNodes.

Definition at line 77 of file AxisCubeComponent.h.

◆ autoAdjustToLargestDimension

bool Cogs::Core::AxisCubeComponent::autoAdjustToLargestDimension = false

If the auto adjustment should make the box equal in size along all axes.

Definition at line 71 of file AxisCubeComponent.h.

◆ autoNodes

std::vector<WeakEntityPtr> Cogs::Core::AxisCubeComponent::autoNodes

Entities(Nodes) that are to be encased by this AxisCube.

Definition at line 76 of file AxisCubeComponent.h.

◆ axisTitles

std::vector<std::string> Cogs::Core::AxisCubeComponent::axisTitles

Titles for the x,y,z-axises.

Definition at line 67 of file AxisCubeComponent.h.

◆ axisTitlesLeftEntity

EntityPtr Cogs::Core::AxisCubeComponent::axisTitlesLeftEntity
private

Definition at line 118 of file AxisCubeComponent.h.

◆ axisTitlesRightEntity

EntityPtr Cogs::Core::AxisCubeComponent::axisTitlesRightEntity
private

Definition at line 117 of file AxisCubeComponent.h.

◆ backQuadMaterial

EntityPtr Cogs::Core::AxisCubeComponent::backQuadMaterial

Definition at line 82 of file AxisCubeComponent.h.

◆ bottomQuadMaterial

EntityPtr Cogs::Core::AxisCubeComponent::bottomQuadMaterial

Definition at line 80 of file AxisCubeComponent.h.

◆ context

Context* Cogs::Core::AxisCubeComponent::context = nullptr

Definition at line 62 of file AxisCubeComponent.h.

◆ corners

glm::vec3 Cogs::Core::AxisCubeComponent::corners[8]
private

Local-space positions of the eight corners.

Definition at line 100 of file AxisCubeComponent.h.

◆ edgeMatInstH

MaterialInstanceHandle Cogs::Core::AxisCubeComponent::edgeMatInstH
private

Definition at line 105 of file AxisCubeComponent.h.

◆ edges

PerEdgeData Cogs::Core::AxisCubeComponent::edges[12]
private

Definition at line 125 of file AxisCubeComponent.h.

◆ faces

PerFaceData Cogs::Core::AxisCubeComponent::faces[6]
private

Definition at line 115 of file AxisCubeComponent.h.

◆ frontQuadMaterial

EntityPtr Cogs::Core::AxisCubeComponent::frontQuadMaterial

Definition at line 81 of file AxisCubeComponent.h.

◆ gridMatInstH

MaterialInstanceHandle Cogs::Core::AxisCubeComponent::gridMatInstH
private

Definition at line 104 of file AxisCubeComponent.h.

◆ initialUpdate

bool Cogs::Core::AxisCubeComponent::initialUpdate = true
private

Definition at line 98 of file AxisCubeComponent.h.

◆ leftQuadMaterial

EntityPtr Cogs::Core::AxisCubeComponent::leftQuadMaterial

Definition at line 84 of file AxisCubeComponent.h.

◆ markerFaces

glm::bvec3 Cogs::Core::AxisCubeComponent::markerFaces

False if wall-marker should lie on min-face, true if max-face.

Definition at line 89 of file AxisCubeComponent.h.

◆ maxAxisValues

int Cogs::Core::AxisCubeComponent::maxAxisValues = 10

The maximum number of axis annotation values to use.

Definition at line 66 of file AxisCubeComponent.h.

◆ maxCorner

glm::vec3 Cogs::Core::AxisCubeComponent::maxCorner = glm::vec3(1.f)

Maximum corner of the cube.

Definition at line 64 of file AxisCubeComponent.h.

◆ minCorner

glm::vec3 Cogs::Core::AxisCubeComponent::minCorner = glm::vec3(-1.f)

Minimum corner of the cube.

Definition at line 63 of file AxisCubeComponent.h.

◆ rightQuadMaterial

EntityPtr Cogs::Core::AxisCubeComponent::rightQuadMaterial

Definition at line 83 of file AxisCubeComponent.h.

◆ textColor

glm::vec4 Cogs::Core::AxisCubeComponent::textColor = glm::vec4(1.f)

Color of text, to be forwarded to children.

Definition at line 73 of file AxisCubeComponent.h.

◆ tickProtrusion

float Cogs::Core::AxisCubeComponent::tickProtrusion = 0.0f
private

Distance the grid lines protrude through the edge.

Definition at line 102 of file AxisCubeComponent.h.

◆ tickSizeOffset

float Cogs::Core::AxisCubeComponent::tickSizeOffset = 0.05f

Definition at line 72 of file AxisCubeComponent.h.

◆ tickSizes

glm::vec3 Cogs::Core::AxisCubeComponent::tickSizes
private

Size of axis ticks (in unit-units):

Definition at line 101 of file AxisCubeComponent.h.

◆ topQuadMaterial

EntityPtr Cogs::Core::AxisCubeComponent::topQuadMaterial

Definition at line 79 of file AxisCubeComponent.h.

◆ unitNames

std::vector<std::string> Cogs::Core::AxisCubeComponent::unitNames

Name of the x,y,z-axis units.

Definition at line 68 of file AxisCubeComponent.h.

◆ unitScales

glm::vec3 Cogs::Core::AxisCubeComponent::unitScales = glm::vec3(1.f)

Size of unit coordinate axis in unitname-units.

Definition at line 69 of file AxisCubeComponent.h.

◆ unprocessedAutoNodes

std::vector<EntityPtr> Cogs::Core::AxisCubeComponent::unprocessedAutoNodes
private

Definition at line 106 of file AxisCubeComponent.h.

◆ useAxisAnnotations

bool Cogs::Core::AxisCubeComponent::useAxisAnnotations = true

If the axis cube should create axis annotation text.

Definition at line 70 of file AxisCubeComponent.h.

◆ worldToLocal

glm::mat4 Cogs::Core::AxisCubeComponent::worldToLocal

Cached inverted local to world matrix.

Definition at line 90 of file AxisCubeComponent.h.

◆ zScale

float Cogs::Core::AxisCubeComponent::zScale = 1.f

Amount to scale the z-axis.

Definition at line 65 of file AxisCubeComponent.h.


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