8 #ifndef hifi_ParabolaPointer_h
9 #define hifi_ParabolaPointer_h
11 #include "PathPointer.h"
13 #include<EntityItemProperties.h>
15 #include <render/Item.h>
17 class ParabolaPointer :
public PathPointer {
18 using Parent = PathPointer;
20 class RenderState :
public StartEndRenderState {
22 class ParabolaRenderItem {
24 using Payload = render::Payload<ParabolaRenderItem>;
25 using Pointer = Payload::DataPointer;
27 ParabolaRenderItem(
const glm::vec3& color,
float alpha,
float width,
28 bool isVisibleInSecondaryCamera,
bool drawInFront,
bool enabled);
29 ~ParabolaRenderItem() {}
31 static std::map<std::pair<bool, bool>, gpu::PipelinePointer> _parabolaPipelines;
32 gpu::PipelinePointer getParabolaPipeline(
bool forward)
const;
34 void render(RenderArgs* args);
35 render::Item::Bound& editBound() {
return _bound; }
36 const render::Item::Bound& getBound(RenderArgs* args) {
return _bound; }
37 render::ItemKey getKey()
const {
return _key; }
39 void setVisible(
bool visible);
41 void updateUniformBuffer() { _uniformBuffer->setSubData(0, _parabolaData); }
44 void setColor(
const glm::vec3& color) { _parabolaData.color = glm::vec4(color, _parabolaData.color.a); }
45 void setAlpha(
const float& alpha) { _parabolaData.color.a = alpha; }
46 void setWidth(
const float& width) { _parabolaData.width = width; }
47 void setParabolicDistance(
const float& parabolicDistance) { _parabolaData.parabolicDistance = parabolicDistance; }
48 void setVelocity(
const glm::vec3& velocity) { _parabolaData.velocity = velocity; }
49 void setAcceleration(
const glm::vec3& acceleration) { _parabolaData.acceleration = acceleration; }
50 void setOrigin(
const glm::vec3& origin) { _origin = origin; }
51 void setIsVisibleInSecondaryCamera(
const bool& isVisibleInSecondaryCamera) { _isVisibleInSecondaryCamera = isVisibleInSecondaryCamera; }
52 void setDrawInFront(
const bool& drawInFront) { _drawInFront = drawInFront; }
53 void setEnabled(
const bool& enabled) { _enabled = enabled; }
55 static const glm::vec4 DEFAULT_PARABOLA_COLOR;
56 static const float DEFAULT_PARABOLA_WIDTH;
57 static const bool DEFAULT_PARABOLA_ISVISIBLEINSECONDARYCAMERA;
58 static const bool DEFAULT_PARABOLA_DRAWINFRONT;
61 render::Item::Bound _bound;
64 glm::vec3 _origin { 0.0f };
65 bool _isVisibleInSecondaryCamera { DEFAULT_PARABOLA_ISVISIBLEINSECONDARYCAMERA };
66 bool _drawInFront { DEFAULT_PARABOLA_DRAWINFRONT };
67 bool _visible {
false };
68 bool _enabled {
false };
71 glm::vec3 velocity { 0.0f };
72 float parabolicDistance { 0.0f };
73 vec3 acceleration { 0.0f };
74 float width { DEFAULT_PARABOLA_WIDTH };
75 vec4 color { vec4(DEFAULT_PARABOLA_COLOR)};
76 int numSections { 0 };
80 ParabolaData _parabolaData;
81 gpu::BufferPointer _uniformBuffer { std::make_shared<gpu::Buffer>() };
85 RenderState(
const QUuid& startID,
const QUuid& endID,
const glm::vec3& pathColor,
float pathAlpha,
float parentScale,
86 bool isVisibleInSecondaryCamera,
bool drawInFront,
bool pathEnabled);
88 void setPathWidth(
float width) { _pathWidth = width; }
89 float getPathWidth()
const {
return _pathWidth; }
91 void cleanup()
override;
92 void disable()
override;
93 void update(
const glm::vec3& origin,
const glm::vec3& end,
const glm::vec3& surfaceNormal,
float parentScale,
bool distanceScaleEnd,
bool centerEndY,
94 bool faceAvatar,
bool followNormal,
float followNormalStrength,
float distance,
const PickResultPointer& pickResult)
override;
96 void editParabola(
const glm::vec3& color,
float alpha,
float width,
bool isVisibleInSecondaryCamera,
bool drawInFront,
bool enabled);
103 ParabolaPointer(
const QVariant& rayProps,
const RenderStateMap& renderStates,
const DefaultRenderStateMap& defaultRenderStates,
bool hover,
const PointerTriggers& triggers,
104 bool faceAvatar,
bool followNormal,
float followNormalStrength,
bool centerEndY,
bool lockEnd,
bool distanceScaleEnd,
bool scaleWithAvatar,
bool enabled);
106 PickQuery::PickType getType()
const override;
108 QVariantMap toVariantMap()
const override;
110 static std::shared_ptr<StartEndRenderState> buildRenderState(
const QVariantMap& propMap,
const QList<EntityItemProperties> &entityProperties);
113 virtual PickResultPointer getPickResultCopy(
const PickResultPointer& pickResult)
const override;
115 void editRenderStatePath(
const std::string& state,
const QVariant& pathProps)
override;
117 glm::vec3 getPickOrigin(
const PickResultPointer& pickResult)
const override;
118 glm::vec3 getPickEnd(
const PickResultPointer& pickResult,
float distance)
const override;
119 glm::vec3 getPickedObjectNormal(
const PickResultPointer& pickResult)
const override;
120 IntersectionType getPickedObjectType(
const PickResultPointer& pickResult)
const override;
121 QUuid getPickedObjectID(
const PickResultPointer& pickResult)
const override;
122 void setVisualPickResultInternal(PickResultPointer pickResult, IntersectionType type,
const QUuid&
id,
123 const glm::vec3& intersection,
float distance,
const glm::vec3& surfaceNormal)
override;
125 PointerEvent buildPointerEvent(
const PickedObject& target,
const PickResultPointer& pickResult,
const std::string& button =
"",
bool hover =
true)
override;
128 static glm::vec3 findIntersection(
const PickedObject& pickedObject,
const glm::vec3& origin,
const glm::vec3& velocity,
const glm::vec3& acceleration);
132 template <>
const ItemKey payloadGetKey(
const ParabolaPointer::RenderState::ParabolaRenderItem::Pointer& payload);
133 template <>
const Item::Bound payloadGetBound(
const ParabolaPointer::RenderState::ParabolaRenderItem::Pointer& payload, RenderArgs* args);
134 template <>
void payloadRender(
const ParabolaPointer::RenderState::ParabolaRenderItem::Pointer& payload, RenderArgs* args);
135 template <>
const ShapeKey shapeGetShapeKey(
const ParabolaPointer::RenderState::ParabolaRenderItem::Pointer& payload);
Represents a 2D or 3D pointer to the scripting engine. Exposed as PointerEvent
Definition: PointerEvent.h:30