vsg 1.1.10
VulkanSceneGraph library
 
Loading...
Searching...
No Matches
CameraAnimationHandler.h
1#pragma once
2
3/* <editor-fold desc="MIT License">
4
5Copyright(c) 2024 Robert Osfield
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
9The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
11THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
13</editor-fold> */
14
15#include <vsg/animation/CameraSampler.h>
16#include <vsg/core/Inherit.h>
17#include <vsg/maths/quat.h>
18#include <vsg/ui/KeyEvent.h>
19
20namespace vsg
21{
22
24 class VSG_DECLSPEC CameraAnimationHandler : public Inherit<Visitor, CameraAnimationHandler>
25 {
26 public:
27 CameraAnimationHandler();
28 CameraAnimationHandler(ref_ptr<Object> in_object, ref_ptr<Animation> in_animation, const Path& in_filename = "saved_animation.vsgt", ref_ptr<Options> in_options = {});
29 explicit CameraAnimationHandler(ref_ptr<Object> in_object, const Path& in_filename = "saved_animation.vsgt", ref_ptr<Options> in_options = {});
30
33
36 ref_ptr<Options> options;
37
38 // animation to play/record to
39 ref_ptr<Animation> animation;
40
41 // CameraSampler to play/record to
42 ref_ptr<CameraSampler> cameraSampler;
43
44 KeySymbol toggleRecordingKey = KEY_r;
45 KeySymbol togglePlaybackKey = KEY_p;
46
47 bool recording = false;
48 bool playing = false;
49 double simulationTime = 0.0;
50 double startTime = 0.0;
51
52 void play();
53 void record();
54 void stop();
55
56 public:
57 void apply(Camera& camera) override;
58 void apply(MatrixTransform& transform) override;
59
60 void apply(KeyPressEvent& keyPress) override;
61 void apply(FrameEvent& frame) override;
62
63 protected:
64 };
65 VSG_type_name(vsg::CameraAnimationHandler);
66
67 // fallback for naming prior to VulkanSceneGraph-1.1.9.
68 using CameraAnimation = vsg::CameraAnimationHandler;
69
70} // namespace vsg
event handler for controlling the playing and recording of camera animation paths
Definition CameraAnimationHandler.h:25
Path filename
file to read/write to
Definition CameraAnimationHandler.h:35
ref_ptr< Object > object
object to track/modify
Definition CameraAnimationHandler.h:32
Definition Camera.h:27
Definition ApplicationEvent.h:37
KeyPressEvent represents a key press event.
Definition KeyEvent.h:309
Definition MatrixTransform.h:24
Definition Path.h:34
Definition ref_ptr.h:22