Cogs.Core
|
A cube with grids on the side faces. More...
#include <AxisCubeComponent.h>
Classes | |
struct | PerEdgeData |
struct | PerFaceData |
Public Member Functions | |
void | initialize (Context *context) |
void | update () |
![]() | |
class Entity * | getContainer () 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 Component * | getComponent (const Reflection::Name &name) const |
COGSFOUNDATION_API Component * | getComponent (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::Type & | getType () 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 COGSCORE_DLL_API void | registerType () |
Register the type in the type system. | |
template<typename T > | |
static Reflection::Type & | registerDerivedType () |
Convenience method for registering the type of a derived 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 | |
Context * | context = 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< WeakEntityPtr > | autoNodes |
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. | |
![]() | |
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< EntityPtr > | unprocessedAutoNodes |
PerFaceData | faces [6] |
EntityPtr | axisTitlesRightEntity |
EntityPtr | axisTitlesLeftEntity |
PerEdgeData | edges [12] |
A cube with grids on the side faces.
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.
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.
void Cogs::Core::AxisCubeComponent::initialize | ( | Context * | context | ) |
Definition at line 110 of file AxisCubeComponent.cpp.
|
static |
Definition at line 74 of file AxisCubeComponent.cpp.
void Cogs::Core::AxisCubeComponent::update | ( | ) |
Definition at line 181 of file AxisCubeComponent.cpp.
|
private |
Definition at line 352 of file AxisCubeComponent.cpp.
|
private |
Definition at line 276 of file AxisCubeComponent.cpp.
|
private |
Definition at line 421 of file AxisCubeComponent.cpp.
|
private |
Definition at line 343 of file AxisCubeComponent.cpp.
|
private |
Definition at line 399 of file AxisCubeComponent.cpp.
|
private |
Definition at line 480 of file AxisCubeComponent.cpp.
|
private |
Definition at line 577 of file AxisCubeComponent.cpp.
|
private |
Definition at line 536 of file AxisCubeComponent.cpp.
|
private |
Definition at line 366 of file AxisCubeComponent.cpp.
glm::vec3 Cogs::Core::AxisCubeComponent::adjustedMaxCorner |
Maximum corner of the cube.
Definition at line 87 of file AxisCubeComponent.h.
glm::vec3 Cogs::Core::AxisCubeComponent::adjustedMinCorner |
Minimum corner of the cube.
Definition at line 86 of file AxisCubeComponent.h.
float Cogs::Core::AxisCubeComponent::annotationGap = 100.0f |
Distance between axis annotations.
Definition at line 74 of file AxisCubeComponent.h.
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.
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.
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.
std::vector<std::string> Cogs::Core::AxisCubeComponent::axisTitles |
Titles for the x,y,z-axises.
Definition at line 67 of file AxisCubeComponent.h.
|
private |
Definition at line 118 of file AxisCubeComponent.h.
|
private |
Definition at line 117 of file AxisCubeComponent.h.
EntityPtr Cogs::Core::AxisCubeComponent::backQuadMaterial |
Definition at line 82 of file AxisCubeComponent.h.
EntityPtr Cogs::Core::AxisCubeComponent::bottomQuadMaterial |
Definition at line 80 of file AxisCubeComponent.h.
Context* Cogs::Core::AxisCubeComponent::context = nullptr |
Definition at line 62 of file AxisCubeComponent.h.
|
private |
Local-space positions of the eight corners.
Definition at line 100 of file AxisCubeComponent.h.
|
private |
Definition at line 105 of file AxisCubeComponent.h.
|
private |
Definition at line 125 of file AxisCubeComponent.h.
|
private |
Definition at line 115 of file AxisCubeComponent.h.
EntityPtr Cogs::Core::AxisCubeComponent::frontQuadMaterial |
Definition at line 81 of file AxisCubeComponent.h.
|
private |
Definition at line 104 of file AxisCubeComponent.h.
|
private |
Definition at line 98 of file AxisCubeComponent.h.
EntityPtr Cogs::Core::AxisCubeComponent::leftQuadMaterial |
Definition at line 84 of file AxisCubeComponent.h.
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.
int Cogs::Core::AxisCubeComponent::maxAxisValues = 10 |
The maximum number of axis annotation values to use.
Definition at line 66 of file AxisCubeComponent.h.
glm::vec3 Cogs::Core::AxisCubeComponent::maxCorner = glm::vec3(1.f) |
Maximum corner of the cube.
Definition at line 64 of file AxisCubeComponent.h.
glm::vec3 Cogs::Core::AxisCubeComponent::minCorner = glm::vec3(-1.f) |
Minimum corner of the cube.
Definition at line 63 of file AxisCubeComponent.h.
EntityPtr Cogs::Core::AxisCubeComponent::rightQuadMaterial |
Definition at line 83 of file AxisCubeComponent.h.
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.
|
private |
Distance the grid lines protrude through the edge.
Definition at line 102 of file AxisCubeComponent.h.
float Cogs::Core::AxisCubeComponent::tickSizeOffset = 0.05f |
Definition at line 72 of file AxisCubeComponent.h.
|
private |
Size of axis ticks (in unit-units):
Definition at line 101 of file AxisCubeComponent.h.
EntityPtr Cogs::Core::AxisCubeComponent::topQuadMaterial |
Definition at line 79 of file AxisCubeComponent.h.
std::vector<std::string> Cogs::Core::AxisCubeComponent::unitNames |
Name of the x,y,z-axis units.
Definition at line 68 of file AxisCubeComponent.h.
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.
|
private |
Definition at line 106 of file AxisCubeComponent.h.
bool Cogs::Core::AxisCubeComponent::useAxisAnnotations = true |
If the axis cube should create axis annotation text.
Definition at line 70 of file AxisCubeComponent.h.
glm::mat4 Cogs::Core::AxisCubeComponent::worldToLocal |
Cached inverted local to world matrix.
Definition at line 90 of file AxisCubeComponent.h.
float Cogs::Core::AxisCubeComponent::zScale = 1.f |
Amount to scale the z-axis.
Definition at line 65 of file AxisCubeComponent.h.