Cogs.Core
Source
Components
Behavior
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
10
namespace
Cogs
11
{
12
namespace
Core
13
{
14
class
PickingBeamComponent
:
public
Cogs::Core::DynamicComponent
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
49
float
defaultPickingRadius
= 4.0f;
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:
62
Cogs::ComponentModel::ComponentHandle
mainCamera;
63
Cogs::ComponentModel::ComponentHandle
beamCamera;
64
Cogs::ComponentModel::ComponentHandle
beamScene;
65
Cogs::ComponentModel::ComponentHandle
destinationScene;
66
Cogs::ComponentModel::ComponentHandle
destinationTransform;
67
Cogs::ComponentModel::ComponentHandle
beamGeometryTransform;
68
Cogs::ComponentModel::ComponentHandle
aimTransform;
69
};
70
}
71
}
72
73
template
<>
inline
Cogs::StringView
getName<Cogs::Core::PickingBeamComponent>() {
return
"PickingBeamComponent"
; }
Cogs::Core::Context
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Definition:
Context.h:83
Cogs::Core::DynamicComponent
Base class for components implementing dynamic behavior.
Definition:
DynamicComponent.h:31
Cogs::Core::PickingBeamComponent
Definition:
PickingBeamComponent.h:15
Cogs::Core::PickingBeamComponent::beamRotation
glm::quat beamRotation
Rotation of the beam relative to the parent transform.
Definition:
PickingBeamComponent.h:27
Cogs::Core::PickingBeamComponent::lastPickedPos
glm::dvec3 lastPickedPos
World coordinates of the last raypick hit.
Definition:
PickingBeamComponent.h:46
Cogs::Core::PickingBeamComponent::active
bool active
whether the beam is active and should be visible and update the picked position each frame
Definition:
PickingBeamComponent.h:36
Cogs::Core::PickingBeamComponent::diffuseColor
glm::vec4 diffuseColor
diffuse color of the beam and marker
Definition:
PickingBeamComponent.h:30
Cogs::Core::PickingBeamComponent::lastPickedEntity
EntityId lastPickedEntity
Last entity picked.
Definition:
PickingBeamComponent.h:43
Cogs::Core::PickingBeamComponent::emissiveColor
glm::vec4 emissiveColor
emissive color of the beam and marker
Definition:
PickingBeamComponent.h:33
Cogs::Core::PickingBeamComponent::beamOffset
glm::vec3 beamOffset
Offset of the beam starting point relative to the parent transform.
Definition:
PickingBeamComponent.h:24
Cogs::Core::PickingBeamComponent::defaultPickingRadius
float defaultPickingRadius
Default distance an object can be from a ray to be considered hit.
Definition:
PickingBeamComponent.h:49
Cogs::StringView
Provides a weakly referenced view over the contents of a string.
Definition:
StringView.h:24
Cogs::Core::EntityPtr
std::shared_ptr< ComponentModel::Entity > EntityPtr
Smart pointer for Entity access.
Definition:
EntityPtr.h:12
Cogs
Contains all Cogs related functionality.
Definition:
FieldSetter.h:23
Cogs::ComponentModel::ComponentHandle
Handle to a Component instance.
Definition:
Component.h:67
Generated by
1.9.6