From c19d8b71d88206e99fa2c987d369ac713c275d41 Mon Sep 17 00:00:00 2001 From: Josef Date: Sun, 19 May 2024 17:48:01 +0200 Subject: [PATCH] TimeLines, VirtualCameras --- RJTimeLine.cpp | 70 ++++++++++++++++++ RJTimeLine.h | 39 +++++++++++ RJTimeLineManager.cpp | 36 ++++++++++ RJTimeLineManager.h | 44 ++++++++++++ RJUpdatable.cpp | 6 +- RJUpdatable.h | 2 + RJVirtualCamera3D.cpp | 25 +++++++ RJVirtualCamera3D.h | 33 +++++++++ RJVirtualCamera3DManager.cpp | 45 ++++++++++++ RJVirtualCamera3DManager.h | 38 ++++++++++ icons/RJTimeLine.svg | 81 +++++++++++++++++++++ icons/RJTimeLineManager.svg | 109 +++++++++++++++++++++++++++++ icons/RJVirtualCamera3D.svg | 87 +++++++++++++++++++++++ icons/RJVirtualCamera3DManager.svg | 101 ++++++++++++++++++++++++++ register_types.cpp | 8 +++ 15 files changed, 722 insertions(+), 2 deletions(-) create mode 100644 RJTimeLine.cpp create mode 100644 RJTimeLine.h create mode 100644 RJTimeLineManager.cpp create mode 100644 RJTimeLineManager.h create mode 100644 RJVirtualCamera3D.cpp create mode 100644 RJVirtualCamera3D.h create mode 100644 RJVirtualCamera3DManager.cpp create mode 100644 RJVirtualCamera3DManager.h create mode 100644 icons/RJTimeLine.svg create mode 100644 icons/RJTimeLineManager.svg create mode 100644 icons/RJVirtualCamera3D.svg create mode 100644 icons/RJVirtualCamera3DManager.svg diff --git a/RJTimeLine.cpp b/RJTimeLine.cpp new file mode 100644 index 0000000..29a2bcd --- /dev/null +++ b/RJTimeLine.cpp @@ -0,0 +1,70 @@ + +/* RJTimeLine.cpp */ + +#include "RJTimeLine.h" + + +void RJTimeLine::_bind_methods() +{ + /* isLooping: bool */ + ClassDB::bind_method(D_METHOD("get_isLooping"), &RJTimeLine::get_isLooping); + ClassDB::bind_method(D_METHOD("set_isLooping"), &RJTimeLine::set_isLooping); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "isLooping"), "set_isLooping", "get_isLooping"); + + /* loopStart: float */ + ClassDB::bind_method(D_METHOD("get_loopStart"), &RJTimeLine::get_loopStart); + ClassDB::bind_method(D_METHOD("set_loopStart"), &RJTimeLine::set_loopStart); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "loopStart"), "set_loopStart", "get_loopStart"); + + /* loopEnd: float */ + ClassDB::bind_method(D_METHOD("get_loopEnd"), &RJTimeLine::get_loopEnd); + ClassDB::bind_method(D_METHOD("set_loopEnd"), &RJTimeLine::set_loopEnd); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "loopEnd"), "set_loopEnd", "get_loopEnd"); + + /* startSpeed: float */ + ClassDB::bind_method(D_METHOD("get_startSpeed"), &RJTimeLine::get_startSpeed); + ClassDB::bind_method(D_METHOD("set_startSpeed"), &RJTimeLine::set_startSpeed); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "startSpeed"), "set_startSpeed", "get_startSpeed"); + + /* autoStart: bool */ + ClassDB::bind_method(D_METHOD("get_autoStart"), &RJTimeLine::get_autoStart); + ClassDB::bind_method(D_METHOD("set_autoStart"), &RJTimeLine::set_autoStart); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autoStart"), "set_autoStart", "get_autoStart"); + +} + +RJTimeLine::RJTimeLine() +{ + isLooping = false; + loopStart = 0; + loopEnd = 16; + startSpeed = 1; + autoStart = false; +} + +RJTimeLine::~RJTimeLine() +{ + +} + +/* isLooping: bool */ +bool RJTimeLine::get_isLooping() { return isLooping; } +void RJTimeLine::set_isLooping( bool p_isLooping ) { isLooping = p_isLooping; } + +/* loopStart: float */ +float RJTimeLine::get_loopStart() { return loopStart; } +void RJTimeLine::set_loopStart( float p_loopStart ) { loopStart = p_loopStart; } + +/* loopEnd: float */ +float RJTimeLine::get_loopEnd() { return loopEnd; } +void RJTimeLine::set_loopEnd( float p_loopEnd ) { loopEnd = p_loopEnd; } + +/* startSpeed: float */ +float RJTimeLine::get_startSpeed() { return startSpeed; } +void RJTimeLine::set_startSpeed( float p_startSpeed ) { startSpeed = p_startSpeed; } + +/* autoStart: bool */ +bool RJTimeLine::get_autoStart() { return autoStart; } +void RJTimeLine::set_autoStart( bool p_autoStart ) { autoStart = p_autoStart; } + + diff --git a/RJTimeLine.h b/RJTimeLine.h new file mode 100644 index 0000000..8ea309f --- /dev/null +++ b/RJTimeLine.h @@ -0,0 +1,39 @@ + +/* RJTimeLine.h */ + +#ifndef ROKOJORI__TIME_LINE_H +#define ROKOJORI__TIME_LINE_H + + +#include "core/io/resource.h" + + +class RJTimeLine : public Resource +{ + GDCLASS(RJTimeLine, Resource); + +protected: + static void _bind_methods(); + + + bool isLooping; + float loopStart; + float loopEnd; + float startSpeed; + bool autoStart; + +public: + + bool get_isLooping(); void set_isLooping( bool p_isLooping ); + float get_loopStart(); void set_loopStart( float p_loopStart ); + float get_loopEnd(); void set_loopEnd( float p_loopEnd ); + float get_startSpeed(); void set_startSpeed( float p_startSpeed ); + bool get_autoStart(); void set_autoStart( bool p_autoStart ); + + RJTimeLine(); + + ~RJTimeLine(); +}; + + +#endif // ROKOJORI__TIME_LINE_H diff --git a/RJTimeLineManager.cpp b/RJTimeLineManager.cpp new file mode 100644 index 0000000..9ac9fa1 --- /dev/null +++ b/RJTimeLineManager.cpp @@ -0,0 +1,36 @@ + +/* RJTimeLineManager.cpp */ + +#include "RJTimeLineManager.h" + + +void RJTimeLineManager::_bind_methods() +{ + GDVIRTUAL_BIND( getTimeLineIndex, "timeLine" ); + GDVIRTUAL_BIND( getTimeLineSize ); + GDVIRTUAL_BIND( createID ); + GDVIRTUAL_BIND( getLastPosition, "timeLineIndex" ); + GDVIRTUAL_BIND( getPosition, "timeLineIndex" ); + GDVIRTUAL_BIND( setPosition, "timeLineIndex", "position" ); + GDVIRTUAL_BIND( getSpeed, "timeLineIndex" ); + GDVIRTUAL_BIND( setSpeed, "timeLineIndex", "speed" ); + GDVIRTUAL_BIND( getPlayState, "timeLineIndex" ); + GDVIRTUAL_BIND( setPlayState, "timeLineIndex", "playState" ); + GDVIRTUAL_BIND( scheduleEvent, "timeLineIndex", "position", "callbackID", "isPersistent" ); + GDVIRTUAL_BIND( scheduleSpan, "timeLineIndex", "startPosition", "endPosition", "callbackID", "isPersistent" ); + ADD_SIGNAL (MethodInfo( "onEvent" , PropertyInfo(Variant::INT, "callbackID")) ); + ADD_SIGNAL (MethodInfo( "onSpan" , PropertyInfo(Variant::INT, "callbackID"), PropertyInfo(Variant::INT, "spanType")) ); +} + +RJTimeLineManager::RJTimeLineManager() +{ + +} + +RJTimeLineManager::~RJTimeLineManager() +{ + +} + + + diff --git a/RJTimeLineManager.h b/RJTimeLineManager.h new file mode 100644 index 0000000..7e382f0 --- /dev/null +++ b/RJTimeLineManager.h @@ -0,0 +1,44 @@ + +/* RJTimeLineManager.h */ + +#ifndef ROKOJORI__TIME_LINE_MANAGER_H +#define ROKOJORI__TIME_LINE_MANAGER_H + +#include "./RJTimeLine.h" +#include "./RJNetworkNode.h" + + +class RJTimeLineManager : public RJNetworkNode +{ + GDCLASS(RJTimeLineManager, RJNetworkNode); + +protected: + static void _bind_methods(); + + + + +public: + + GDVIRTUAL1R( int, getTimeLineIndex, Ref ); + GDVIRTUAL0R( int, getTimeLineSize ); + GDVIRTUAL0R( int, createID ); + GDVIRTUAL1R( double, getLastPosition, int ); + GDVIRTUAL1R( double, getPosition, int ); + GDVIRTUAL2( setPosition, int, double ); + GDVIRTUAL1R( double, getSpeed, int ); + GDVIRTUAL2( setSpeed, int, double ); + GDVIRTUAL1R( bool, getPlayState, int ); + GDVIRTUAL2( setPlayState, int, bool ); + GDVIRTUAL4( scheduleEvent, int, double, int, bool ); + GDVIRTUAL5( scheduleSpan, int, double, double, int, bool ); + /* signal onEvent */ + /* signal onSpan */ + + RJTimeLineManager(); + + ~RJTimeLineManager(); +}; + + +#endif // ROKOJORI__TIME_LINE_MANAGER_H diff --git a/RJUpdatable.cpp b/RJUpdatable.cpp index 5bd86ca..da617a2 100644 --- a/RJUpdatable.cpp +++ b/RJUpdatable.cpp @@ -6,12 +6,12 @@ void RJUpdatable::_bind_methods() { - GDVIRTUAL_BIND( update ); + GDVIRTUAL_BIND( update, "delta" ); } RJUpdatable::RJUpdatable() { - + } RJUpdatable::~RJUpdatable() @@ -19,3 +19,5 @@ RJUpdatable::~RJUpdatable() } + + diff --git a/RJUpdatable.h b/RJUpdatable.h index 3a487af..0640545 100644 --- a/RJUpdatable.h +++ b/RJUpdatable.h @@ -16,6 +16,8 @@ protected: static void _bind_methods(); + + public: GDVIRTUAL1( update, double ); diff --git a/RJVirtualCamera3D.cpp b/RJVirtualCamera3D.cpp new file mode 100644 index 0000000..739af88 --- /dev/null +++ b/RJVirtualCamera3D.cpp @@ -0,0 +1,25 @@ + +/* RJVirtualCamera3D.cpp */ + +#include "RJVirtualCamera3D.h" + + +void RJVirtualCamera3D::_bind_methods() +{ + GDVIRTUAL_BIND( getCameraPosition ); + GDVIRTUAL_BIND( getCameraRotation ); + GDVIRTUAL_BIND( getCameraFOV ); +} + +RJVirtualCamera3D::RJVirtualCamera3D() +{ + +} + +RJVirtualCamera3D::~RJVirtualCamera3D() +{ + +} + + + diff --git a/RJVirtualCamera3D.h b/RJVirtualCamera3D.h new file mode 100644 index 0000000..60859ee --- /dev/null +++ b/RJVirtualCamera3D.h @@ -0,0 +1,33 @@ + +/* RJVirtualCamera3D.h */ + +#ifndef ROKOJORI__VIRTUAL_CAMERA_3_D_H +#define ROKOJORI__VIRTUAL_CAMERA_3_D_H + + +#include "scene/3d/node_3d.h" + + +class RJVirtualCamera3D : public Node3D +{ + GDCLASS(RJVirtualCamera3D, Node3D); + +protected: + static void _bind_methods(); + + + + +public: + + GDVIRTUAL0R( Vector3, getCameraPosition ); + GDVIRTUAL0R( Quaternion, getCameraRotation ); + GDVIRTUAL0R( float, getCameraFOV ); + + RJVirtualCamera3D(); + + ~RJVirtualCamera3D(); +}; + + +#endif // ROKOJORI__VIRTUAL_CAMERA_3_D_H diff --git a/RJVirtualCamera3DManager.cpp b/RJVirtualCamera3DManager.cpp new file mode 100644 index 0000000..af43552 --- /dev/null +++ b/RJVirtualCamera3DManager.cpp @@ -0,0 +1,45 @@ + +/* RJVirtualCamera3DManager.cpp */ + +#include "RJVirtualCamera3DManager.h" + + +void RJVirtualCamera3DManager::_bind_methods() +{ + GDVIRTUAL_BIND( getCamera, "cameraIndex" ); + GDVIRTUAL_BIND( getCameraIndex, "timeLine" ); + GDVIRTUAL_BIND( getCameraSize ); + GDVIRTUAL_BIND( getCameraPriority, "cameraIndex" ); + GDVIRTUAL_BIND( setCameraPriority, "cameraIndex", "priority" ); + /* cameraPrioritySmoothingCoefficient: float */ + ClassDB::bind_method(D_METHOD("get_cameraPrioritySmoothingCoefficient"), &RJVirtualCamera3DManager::get_cameraPrioritySmoothingCoefficient); + ClassDB::bind_method(D_METHOD("set_cameraPrioritySmoothingCoefficient"), &RJVirtualCamera3DManager::set_cameraPrioritySmoothingCoefficient); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "cameraPrioritySmoothingCoefficient"), "set_cameraPrioritySmoothingCoefficient", "get_cameraPrioritySmoothingCoefficient"); + + /* cameraPrioritySmoothingStepFPS: float */ + ClassDB::bind_method(D_METHOD("get_cameraPrioritySmoothingStepFPS"), &RJVirtualCamera3DManager::get_cameraPrioritySmoothingStepFPS); + ClassDB::bind_method(D_METHOD("set_cameraPrioritySmoothingStepFPS"), &RJVirtualCamera3DManager::set_cameraPrioritySmoothingStepFPS); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "cameraPrioritySmoothingStepFPS"), "set_cameraPrioritySmoothingStepFPS", "get_cameraPrioritySmoothingStepFPS"); + +} + +RJVirtualCamera3DManager::RJVirtualCamera3DManager() +{ + cameraPrioritySmoothingCoefficient = 0.5; + cameraPrioritySmoothingStepFPS = 120; +} + +RJVirtualCamera3DManager::~RJVirtualCamera3DManager() +{ + +} + +/* cameraPrioritySmoothingCoefficient: float */ +float RJVirtualCamera3DManager::get_cameraPrioritySmoothingCoefficient() { return cameraPrioritySmoothingCoefficient; } +void RJVirtualCamera3DManager::set_cameraPrioritySmoothingCoefficient( float p_cameraPrioritySmoothingCoefficient ) { cameraPrioritySmoothingCoefficient = p_cameraPrioritySmoothingCoefficient; } + +/* cameraPrioritySmoothingStepFPS: float */ +float RJVirtualCamera3DManager::get_cameraPrioritySmoothingStepFPS() { return cameraPrioritySmoothingStepFPS; } +void RJVirtualCamera3DManager::set_cameraPrioritySmoothingStepFPS( float p_cameraPrioritySmoothingStepFPS ) { cameraPrioritySmoothingStepFPS = p_cameraPrioritySmoothingStepFPS; } + + diff --git a/RJVirtualCamera3DManager.h b/RJVirtualCamera3DManager.h new file mode 100644 index 0000000..efe6d34 --- /dev/null +++ b/RJVirtualCamera3DManager.h @@ -0,0 +1,38 @@ + +/* RJVirtualCamera3DManager.h */ + +#ifndef ROKOJORI__VIRTUAL_CAMERA_3_D_MANAGER_H +#define ROKOJORI__VIRTUAL_CAMERA_3_D_MANAGER_H + +#include "./RJVirtualCamera3D.h" +#include "./RJNetworkNode.h" + + +class RJVirtualCamera3DManager : public RJNetworkNode +{ + GDCLASS(RJVirtualCamera3DManager, RJNetworkNode); + +protected: + static void _bind_methods(); + + + float cameraPrioritySmoothingCoefficient; + float cameraPrioritySmoothingStepFPS; + +public: + + GDVIRTUAL1R( Ref, getCamera, int ); + GDVIRTUAL1R( int, getCameraIndex, Ref ); + GDVIRTUAL0R( int, getCameraSize ); + GDVIRTUAL1R( float, getCameraPriority, int ); + GDVIRTUAL2( setCameraPriority, int, float ); + float get_cameraPrioritySmoothingCoefficient(); void set_cameraPrioritySmoothingCoefficient( float p_cameraPrioritySmoothingCoefficient ); + float get_cameraPrioritySmoothingStepFPS(); void set_cameraPrioritySmoothingStepFPS( float p_cameraPrioritySmoothingStepFPS ); + + RJVirtualCamera3DManager(); + + ~RJVirtualCamera3DManager(); +}; + + +#endif // ROKOJORI__VIRTUAL_CAMERA_3_D_MANAGER_H diff --git a/icons/RJTimeLine.svg b/icons/RJTimeLine.svg new file mode 100644 index 0000000..b011c4a --- /dev/null +++ b/icons/RJTimeLine.svg @@ -0,0 +1,81 @@ + + diff --git a/icons/RJTimeLineManager.svg b/icons/RJTimeLineManager.svg new file mode 100644 index 0000000..f1d4c61 --- /dev/null +++ b/icons/RJTimeLineManager.svg @@ -0,0 +1,109 @@ + + diff --git a/icons/RJVirtualCamera3D.svg b/icons/RJVirtualCamera3D.svg new file mode 100644 index 0000000..c3175f6 --- /dev/null +++ b/icons/RJVirtualCamera3D.svg @@ -0,0 +1,87 @@ + + diff --git a/icons/RJVirtualCamera3DManager.svg b/icons/RJVirtualCamera3DManager.svg new file mode 100644 index 0000000..c22199a --- /dev/null +++ b/icons/RJVirtualCamera3DManager.svg @@ -0,0 +1,101 @@ + + diff --git a/register_types.cpp b/register_types.cpp index 1f81461..ed0e40c 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -10,6 +10,10 @@ #include "./RJSensor.h" #include "./RJSequenceAction.h" #include "./RJUpdatable.h" +#include "./RJTimeLine.h" +#include "./RJTimeLineManager.h" +#include "./RJVirtualCamera3D.h" +#include "./RJVirtualCamera3DManager.h" void initialize_rokojori_action_library_module( ModuleInitializationLevel p_level ) { @@ -24,6 +28,10 @@ void initialize_rokojori_action_library_module( ModuleInitializationLevel p_leve ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); } void uninitialize_rokojori_action_library_module( ModuleInitializationLevel p_level )