NDEVR
API Documentation
Effect.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Design
28File: Effect
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/DesignObject.h>
35#include <NDEVR/BaseValues.h>
36#include <NDEVR/TimeSpan.h>
37namespace NDEVR
38{
40
62 template<> struct PropertySpec<NDPE::is_active> { using type = bool; };
63 template<> struct PropertySpec<NDPE::start_time> { using type = Time; };
64 template<> struct PropertySpec<NDPE::end_time> { using type = Time; };
65 template<> struct PropertySpec<NDPE::frequency> { using type = fltp08; };
66 template<> struct PropertySpec<NDPE::destroy_when_finished> { using type = bool; };
67 template<> struct PropertySpec<NDPE::extra_transform> { using type = Matrix<fltp08>; };
68 template<> struct PropertySpec<NDPE::target_value_a> { using type = StringView; };
69 template<> struct PropertySpec<NDPE::target_value_b> { using type = StringView; };
70
77 template<>
79 {
80 public:
87 template<class t_value_type>
88 static void Set(DesignInfo* object, NDPE property, const t_value_type& value)
89 {
90 object->m_base->effect_properties[eint01(property)]->set(object->m_design_index, value);
91 }
92
97 template<NDPE t_property, class t_value_type>
98 static void Set(DesignInfo* object, const t_value_type& value)
99 {
100 object->m_base->effect_properties[eint01(t_property)]->set(object->m_design_index, value);
101 }
102
108 template<class t_value_type>
109 static decltype(auto) Get(const DesignInfo* object, NDPE property)
110 {
111 return object->m_base->effect_properties[eint01(property)]->get<t_value_type>(object->m_design_index);
112 }
113
118 template<NDPE t_property, class t_value_type>
119 static decltype(auto) Get(const DesignInfo* object)
120 {
121 return object->m_base->effect_properties[eint01(t_property)]->get<t_value_type>(object->m_design_index);
122 }
123
129 template<NDPE t_property>
130 static decltype(auto) Get(const DesignInfo* object)
131 {
132 return object->m_base->effect_properties[eint01(t_property)]->get<typename PropertySpec<t_property>::type>(object->m_design_index);
133 }
134
141 static bool IsSame(const DesignInfo* object, NDPE property, const StringView& value)
142 {
143 return object->m_base->effect_properties[eint01(property)]->isSame(object->m_design_index, value);
144 }
145 };
146
157 class NDEVR_DESIGN_API Effect : public DesignObject
158 {
159 public:
184 public:
199 Effect(DesignObjectBase* property_table);
204 explicit Effect(const DesignObject& object);
208 void cleanup();
213 void setupAsLight(fltp04 intensity = 1.0);
221 void setupAsMotion(const Vector<3, fltp08>& speed, const Vector<3, fltp08>& acceleration, const Vector<3, Angle<fltp08>>& rotation_speed, const Vector<3, Angle<fltp08>>& rotation_acc);
226 void setupAsBlinking(fltp04 frequency);
231 void setupAsBoundingBox(const Model& bounds);
237 void setupAsBoundingBox(const Model& bounds, const Model& target);
243 void setupAsBoundingBox(const Model& bounds, const ModelBuffer& targets);
248 void setBoundsRotation(bool bounds_can_rotate);
253 bool getBoundsRotation() const;
254#if NDEVR_STATION_MODEL
259 void setupAsStation(const Model& station);
260#endif
265 void copyFrom(const Effect& effect);
270 void setupAsModelTile(const Model& model_tile);
271#if NDEVR_CALIBRATION
276 void setupAsCalibration(const Model& calibration);
277#endif
278#if NDEVR_SCAN
283 void setupAsScan(const Model& scan);
284#endif
289 void setupAsLocationOperations(const Model& reference);
297 void setupAsTransformAnimation(const Model& target, const Matrix<fltp08>& transform, const TimeSpan& span = TimeSpan(1.0), bool hide_at_end = false);
314 void update(Time current_time, DesignObjectLookup* lock_ptr);
315
321 template<class t_type>
322 void setTargetProperty(uint04 property_name, t_type value)
323 {
324 set(NDPE::target_property, property_name);
326 }
327
333 template<class t_type>
334 void setTargetProperty(uint04 property_name, t_type value_a, t_type value_b)
335 {
336 set(NDPE::target_property, property_name);
337 set(NDPE::target_value_a, value_a);
338 set(NDPE::target_value_b, value_b);
339 }
340
353 void setTargets(const Buffer<DesignObject>& targets);
364 void setTarget(uint04 index, const DesignObject& target);
370 void addTarget(uint04 index, const DesignObject& target);
375 void addTarget(const DesignObject& target);
393 void activate();
403 bool operator==(const Effect& mat) const
404 {
405 return mat.index() == index();
406 }
407
412 bool operator!=(const Effect& effect) const
413 {
414 return effect.index() != index();
415 }
416 private:
423 void _updateBoundingBox(Buffer<DesignObject>& targets, const Time& update_time, const void* lock_ptr = nullptr);
431 void _updateTargetProperty(EffectType effect_type, Buffer<DesignObject>& targets, const StringView& value, const void* lock_ptr = nullptr);
432#if NDEVR_STATION_MODEL
439 void _updateStation(Buffer<DesignObject>& targets, const Time& update_time, DesignObjectLookup* lookup);
440#endif
447 void _updateAzimuth(Buffer<DesignObject>& targets, const Time& update_time, DesignObjectLookup* lookup);
454 void _updateLocation(Buffer<DesignObject>& targets, const Time& update_time, DesignObjectLookup* lookup);
461 void _updateMotion(Buffer<DesignObject>& targets, const Time& update_time, DesignObjectLookup* lookup);
468 void _updateTileModel(Buffer<DesignObject>& targets, const Time& update_time, DesignObjectLookup* lookup);
469#if NDEVR_SCAN
476 void _updateScan(Buffer<DesignObject>& targets, const Time& update_time, const void* lock_ptr);
477#endif
478 };
479
485 template<>
486 struct ObjectInfo<Effect, false, false>
487 {
488 static const uint01 Dimensions = 0;
489 static const bool Vector = false;
490 static const bool Buffer = false;
491 static const bool Primitive = true;
492 static const bool Pointer = false;
493 static const bool Unsigned = false;
494 static const bool Float = false;
495 static const bool Integer = false;
496 static const bool Number = false;
497 static const bool Enum = false;
498 static const bool String = false;
499 static const bool Color = false;
500 static const bool Boolean = false;
506 };
507}
508
509
510
Stores an angle in an optimized internal format with support for efficient trigonometric operations.
Definition Angle.h:83
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
Base information class for all design objects in the NDEVR property database.
uint04 m_design_index
Index of the parent design that owns this object.
Provides the underlying data storage for the NDEVR Scene Model hierarchy.
A core class where all Design Objects including models, materials, and geometries are stored.
DesignObject()=default
Creates an "invalid" design object.
uint04 index() const
Returns the primary row index of this object within the DesignObjectBase property table.
void set(t_property_type property, const t_type &value)
Sets a property value in the database.
A core class that provides a dynamic effect to an object in a model hierarchy.
Definition Effect.h:158
void clearTargets()
Removes all targets from this effect.
void setTargetProperty(uint04 property_name, t_type value)
Sets a single target property value on this effect.
Definition Effect.h:322
Effect(uint04 index, DesignObjectBase *property_table)
Constructs an Effect referencing an existing entry in the property table.
void activate()
Activates this effect so it applies during updates.
Effect()
Default constructor.
uint04 targetCount() const
Returns the number of targets this effect operates on.
bool operator==(const Effect &mat) const
Checks equality by comparing effect indices.
Definition Effect.h:403
void addTarget(uint04 index, const DesignObject &target)
Inserts a target at a specific index.
void setupAsTransformAnimation(const Model &target, const Matrix< fltp08 > &transform, const TimeSpan &span=TimeSpan(1.0), bool hide_at_end=false)
Configures this effect as a transform animation over a time span.
void deactivate()
Deactivates this effect so it no longer applies during updates.
Buffer< DesignObject > getTargets() const
Retrieves all targets of this effect.
EffectType effectType() const
Returns the type of this effect.
Effect(DesignObjectBase *property_table)
Constructs a new Effect and appends it to the given property table.
void setupAsBoundingBox(const Model &bounds)
Configures this effect to draw a bounding box around the given model.
void setupAsLocationOperations(const Model &reference)
Configures this effect to perform location-based operations.
void setEffectType(EffectType type)
Sets the type of this effect.
void setupAsModelTile(const Model &model_tile)
Configures this effect to tile a model to fit an object.
void deleteEffect()
Deletes this effect from the design database.
void update(Time current_time, DesignObjectLookup *lock_ptr)
Updates this effect based on the current time, applying changes to all targets.
bool getBoundsRotation() const
Gets whether the bounding box is allowed to rotate with its target.
void setupAsBlinking(fltp04 frequency)
Configures this effect as a blinking effect.
EffectType
Enumerates the available effect types.
Definition Effect.h:164
@ e_motion
Applies continuous motion (velocity and acceleration).
Definition Effect.h:182
@ e_material_uv_color
Modifies material UV color on the target.
Definition Effect.h:178
@ e_light
Light source effect with configurable intensity.
Definition Effect.h:173
@ e_scan
Scan-related effect (e.g., point cloud processing).
Definition Effect.h:172
@ e_3D_fade_out
Gradually fades a 3D object out.
Definition Effect.h:168
@ e_none
No effect.
Definition Effect.h:165
@ e_azimuth_operations
Performs azimuth-based operations on the target.
Definition Effect.h:180
@ e_material_property
Modifies a material-level property on the target.
Definition Effect.h:176
@ e_placeholder
Placeholder effect.
Definition Effect.h:166
@ e_tile_model_to_object
Tiles a model to fit an object.
Definition Effect.h:181
@ e_draw_bounding_box
Draws a bounding box around target objects.
Definition Effect.h:169
@ e_model_property
Modifies a model-level property on the target.
Definition Effect.h:175
@ e_design_property
Modifies a design-level property on the target.
Definition Effect.h:174
@ e_geometry_property
Modifies a geometry-level property on the target.
Definition Effect.h:177
@ e_station
Station-based effect for survey/positioning.
Definition Effect.h:170
@ e_3D_fade_in
Gradually fades a 3D object in.
Definition Effect.h:167
@ e_location_operations
Performs location-based operations on the target.
Definition Effect.h:179
@ e_set_transform
Applies a transformation matrix to the target.
Definition Effect.h:171
void addTarget(const DesignObject &target)
Appends a target to the end of the target list.
void removeTarget(uint04 index)
Removes a target at the given index.
void setTargetProperty(uint04 property_name, t_type value_a, t_type value_b)
Sets a target property with two values (e.g., for interpolation between value_a and value_b).
Definition Effect.h:334
void setupAsBoundingBox(const Model &bounds, const ModelBuffer &targets)
Configures this effect to draw a bounding box with multiple targets.
void setTarget(uint04 index, const DesignObject &target)
Sets a specific target at the given index.
void setupAsMotion(const Vector< 3, fltp08 > &speed, const Vector< 3, fltp08 > &acceleration, const Vector< 3, Angle< fltp08 > > &rotation_speed, const Vector< 3, Angle< fltp08 > > &rotation_acc)
Configures this effect as a motion effect with velocity and acceleration.
bool operator!=(const Effect &effect) const
Checks inequality by comparing effect indices.
Definition Effect.h:412
DesignObject getTarget(uint04 target) const
Retrieves a specific target design object by index.
Effect(const DesignObject &object)
Constructs an Effect from an existing DesignObject.
void copyFrom(const Effect &effect)
Copies all effect properties from another Effect into this one.
void setTargets(const Buffer< DesignObject > &targets)
Replaces the entire target list with the given buffer of design objects.
void setupAsBoundingBox(const Model &bounds, const Model &target)
Configures this effect to draw a bounding box with a specific target model.
void setBoundsRotation(bool bounds_can_rotate)
Sets whether the bounding box is allowed to rotate with its target.
void setupAsLight(fltp04 intensity=1.0)
Configures this effect as a light source.
void cleanup()
Cleans up resources and state associated with this effect.
Templated logic for doing matrix multiplication.
Definition Matrix.hpp:182
static decltype(auto) Get(const DesignInfo *object)
Gets an effect property value using compile-time property index, with the type deduced from PropertyS...
Definition Effect.h:130
static void Set(DesignInfo *object, NDPE property, const t_value_type &value)
Sets an effect property value on the given object using a runtime property index.
Definition Effect.h:88
static void Set(DesignInfo *object, const t_value_type &value)
Sets an effect property value on the given object using a compile-time property index.
Definition Effect.h:98
static decltype(auto) Get(const DesignInfo *object, NDPE property)
Gets an effect property value from the given object using a runtime property index.
Definition Effect.h:109
static bool IsSame(const DesignInfo *object, NDPE property, const StringView &value)
Checks whether an effect property matches a given string value.
Definition Effect.h:141
static decltype(auto) Get(const DesignInfo *object)
Gets an effect property value using compile-time property index and explicit value type.
Definition Effect.h:119
Typed interface for getting and setting design object properties by enum.
The core String View class for the NDEVR API.
Definition StringView.h:58
Stores a time span, or difference between two times, with an optional start time.
Definition TimeSpan.h:46
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:62
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Definition Vector.hpp:62
The primary namespace for the NDEVR SDK.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
NDPE
NDPE - NDEVR Design Property Effect: Values stored in the effect database.
Definition Effect.h:49
@ target_value_b
The second target property value (string-encoded), used for interpolation.
Definition Effect.h:60
@ extra_size
An additional size parameter for the effect.
Definition Effect.h:55
@ end_time
The time at which the effect ends.
Definition Effect.h:53
@ is_active
Whether the effect is currently active.
Definition Effect.h:51
@ target_value_a
The first target property value (string-encoded).
Definition Effect.h:59
@ target_property
The property index on the target to modify.
Definition Effect.h:58
@ effect_type
The type of effect (maps to Effect::EffectType).
Definition Effect.h:50
@ extra_transform
An additional transformation matrix applied by the effect.
Definition Effect.h:56
@ start_time
The time at which the effect begins.
Definition Effect.h:52
@ destroy_when_finished
Whether to destroy the effect when it completes.
Definition Effect.h:57
@ frequency
The frequency of the effect cycle (e.g., blink rate in Hz).
Definition Effect.h:54
PrimitiveAlignedBuffer< Model, 16 > ModelBuffer
Aligned buffer of Model objects with 16-byte alignment.
static const uint01 Dimensions
Number of dimensional components (0 for scalar-like types).
Definition Effect.h:488
static const bool String
Whether the type is a string.
Definition Effect.h:498
static const bool Enum
Whether the type is an enum.
Definition Effect.h:497
static const bool Boolean
Whether the type is a boolean.
Definition Effect.h:500
static const bool Primitive
Whether the type is considered primitive.
Definition Effect.h:491
static const bool Unsigned
Whether the type is unsigned.
Definition Effect.h:493
static const bool Buffer
Whether the type is a Buffer.
Definition Effect.h:490
static const bool Vector
Whether the type is a Vector.
Definition Effect.h:489
static const bool Float
Whether the type is a floating-point number.
Definition Effect.h:494
static const bool Integer
Whether the type is an integer.
Definition Effect.h:495
static const bool Number
Whether the type is numeric.
Definition Effect.h:496
static constexpr ObjectInfo< Effect, false, false > VectorSub()
Returns the ObjectInfo for the sub-element type when treated as a vector.
Definition Effect.h:505
static const bool Color
Whether the type is a color.
Definition Effect.h:499
static const bool Pointer
Whether the type is a pointer.
Definition Effect.h:492
Information about the object.
Definition ObjectInfo.h:55
Maps a compile-time property enum value to its corresponding C++ storage type.