Repository navigation
Expand file tree
/
Copy pathphysics_sample.h
More file actions
108 lines (90 loc) · 2.65 KB
/
Copy pathphysics_sample.h
File metadata and controls
108 lines (90 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
////////////////////////////////////////////////////////////////////////////////
// Distributed under the Boost Software License, Version 1.0. //
// (See accompanying file LICENSE or copy at //
// https://www.boost.org/LICENSE_1_0.txt) //
////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <cstddef>
#include <map>
#include <string>
#include <core/camera.h>
#include <core/context.h>
#include <core/transform.h>
#include <events/event.h>
#include <graphics/cube_map.h>
#include <graphics/lights/point_light.h>
#include <graphics/render_entity.h>
#include <graphics/render_graph/render_graph.h>
#include <graphics/render_pipeline.h>
#include <graphics/single_entity.h>
#include <graphics/window.h>
#include <physics/character_controller.h>
#include <physics/physics_system.h>
#include <physics/rigid_body.h>
#include "sample.h"
/**
* Sample showcasing the physics engine.
*/
class PhysicsSample : public Sample
{
public:
/**
* Create a new PhysicsSample.
*
* @param window
* Window to render with.
*
* @param render_pipeline
* Render pipeline to use for sample.
*
* @param context
* Engine context object.
*/
PhysicsSample(iris::Window *window, iris::RenderPipeline &render_pipeline, iris::Context &context);
/**
* Fixed rate update function.
*/
void fixed_update() override;
/**
* Variable rate update function.
*/
void variable_update() override;
/**
* Handle a user input.
*
* @param event
* User input event.
*/
void handle_input(const iris::Event &event) override;
/**
* Title of sample.
*
* @returns
* Sample title.
*/
std::string title() const override;
/**
* Get the target the sample will render to.
*
* @returns
* Sample render target.
*/
const iris::RenderTarget *target() const override;
private:
/** Render target for sample. */
const iris::RenderTarget *render_target_;
/** Physics system */
iris::PhysicsSystem *physics_;
/** Transform for moving light. */
iris::Transform light_transform_;
/** Scene light */
iris::PointLight *light_;
/** Render camera. */
iris::Camera camera_;
/** User input key map. */
std::map<iris::Key, iris::KeyState> key_map_;
/** Collection of render entity and rigid body pairs. */
std::vector<std::tuple<iris::SingleEntity *, iris::RigidBody *>> boxes_;
/** Character controller. */
iris::CharacterController *character_controller_;
};