Cogs.Core
PickingBeamComponent.h
1
2#include "../Core/DynamicComponent.h"
3
4#include "../../Context.h"
5#include "../../EntityDefinition.h"
6
7#include <glm/vec3.hpp>
8#include <glm/fwd.hpp>
9
10namespace Cogs
11{
12 namespace Core
13 {
15 {
16 public:
17 static void registerType();
18 void initialize(Cogs::Core::Context * context);
19 void update();
20
21 //std::shared_ptr<ComponentModel::Entity> aimEntity; //use parent entity
22
24 glm::vec3 beamOffset = glm::vec3(0, 0, 0);
25
27 glm::quat beamRotation = glm::quat();
28
30 glm::vec4 diffuseColor = glm::vec4(0, 0, 0.7, 0.5f);
31
33 glm::vec4 emissiveColor = glm::vec4(0, 0, 0.3, 1);
34
36 bool active = false;
37
38 bool enableDepthTest = false;
39
40 int32_t transparencyLayer = 30;
41
43 EntityId lastPickedEntity = NoEntity;
44
46 glm::dvec3 lastPickedPos = glm::dvec3(0);
47
50
51 private:
52 Context * context = nullptr;
53 bool wasActive = false;
54
55 //Beam entity created as a child entity of the component owner
56 EntityPtr beam;
57
58 //Destination entity created as a separate entity
59 EntityPtr destinationMarker;
60
61 //cache component handles used:
66 Cogs::ComponentModel::ComponentHandle destinationTransform;
67 Cogs::ComponentModel::ComponentHandle beamGeometryTransform;
69 };
70 }
71}
72
73template<> inline Cogs::StringView getName<Cogs::Core::PickingBeamComponent>() { return "PickingBeamComponent"; }
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Definition: Context.h:83
Base class for components implementing dynamic behavior.
glm::quat beamRotation
Rotation of the beam relative to the parent transform.
glm::dvec3 lastPickedPos
World coordinates of the last raypick hit.
bool active
whether the beam is active and should be visible and update the picked position each frame
glm::vec4 diffuseColor
diffuse color of the beam and marker
EntityId lastPickedEntity
Last entity picked.
glm::vec4 emissiveColor
emissive color of the beam and marker
glm::vec3 beamOffset
Offset of the beam starting point relative to the parent transform.
float defaultPickingRadius
Default distance an object can be from a ray to be considered hit.
Provides a weakly referenced view over the contents of a string.
Definition: StringView.h:24
std::shared_ptr< ComponentModel::Entity > EntityPtr
Smart pointer for Entity access.
Definition: EntityPtr.h:12
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
Handle to a Component instance.
Definition: Component.h:67