Antkeeper
0.0.1
src
engine
scene
object.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2023 Christopher J. Howard
3
*
4
* This file is part of Antkeeper source code.
5
*
6
* Antkeeper source code is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* Antkeeper source code is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#include <
engine/scene/object.hpp
>
21
22
namespace
scene
{
23
24
std::size_t
object_base::next_object_type_id
()
25
{
26
static
std::atomic<std::size_t>
id
{0};
27
return
id
++;
28
}
29
30
void
object_base::look_at
(
const
vector_type
&
position
,
const
vector_type
&
target
,
const
vector_type
& up)
31
{
32
m_transform
.
translation
=
position
;
33
m_transform
.
rotation
=
math::look_rotation
(
math::normalize
(
math::sub
(
target
,
position
)), up);
34
transformed
();
35
}
36
37
}
// namespace scene
scene::object_base::next_object_type_id
static std::size_t next_object_type_id()
Definition:
object.cpp:24
scene::object_base::m_transform
transform_type m_transform
Definition:
object.hpp:162
scene::object_base::transformed
virtual void transformed()
Called every time the scene object's tranform is changed.
Definition:
object.hpp:159
scene::object_base::look_at
void look_at(const vector_type &position, const vector_type &target, const vector_type &up)
Definition:
object.cpp:30
math::normalize
quaternion< T > normalize(const quaternion< T > &q)
Normalizes a quaternion.
Definition:
quaternion.hpp:679
math::look_rotation
quaternion< T > look_rotation(const vec3< T > &forward, vec3< T > up)
Creates a unit quaternion rotation using forward and up vectors.
Definition:
quaternion.hpp:618
math::sub
constexpr matrix< T, N, M > sub(const matrix< T, N, M > &a, const matrix< T, N, M > &b) noexcept
Subtracts a matrix from another matrix.
Definition:
math/matrix.hpp:1167
render::vertex_attribute_location::target
@ target
Vertex morph target (vec3)
Definition:
vertex-attribute-location.hpp:57
render::vertex_attribute_location::position
@ position
Vertex position (vec3)
Definition:
vertex-attribute-location.hpp:33
scene
3D scene.
Definition:
context.hpp:28
object.hpp
math::transform::translation
vector_type translation
Translation vector.
Definition:
transform.hpp:50
math::transform::rotation
quaternion_type rotation
Rotation quaternion.
Definition:
transform.hpp:53
math::vector
n-dimensional vector.
Definition:
vector.hpp:44