-
Notifications
You must be signed in to change notification settings - Fork 1
/
math_pivot.h
56 lines (38 loc) · 2.17 KB
/
math_pivot.h
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
/* Cute3D, a simple opengl based framework for writing interactive realtime applications */
/* Copyright (C) 2013-2017 Andreas Raster */
/* This file is part of Cute3D. */
/* Cute3D is free software: you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation, either version 3 of the License, or */
/* (at your option) any later version. */
/* Cute3D is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* You should have received a copy of the GNU General Public License */
/* along with Cute3D. If not, see <http://www.gnu.org/licenses/>. */
#ifndef MATH_PIVOT_H
#define MATH_PIVOT_H
#include "math_types.h"
#include "math_matrix.h"
struct Pivot {
Vec4f position;
Quat orientation;
float eye_distance;
const struct Pivot* parent;
};
extern struct Pivot global_null_pivot;
void pivot_create(Vec3f position, Quat orientation, struct Pivot* pivot);
void pivot_attach(struct Pivot* child, const struct Pivot* parent);
int32_t pivot_lookat(struct Pivot* pivot, const Vec3f target);
MatP* pivot_world_transform(const struct Pivot* pivot, Mat world_transform);
MatP* pivot_local_transform(const struct Pivot* pivot, Mat local_transform);
// - so this computes a transform from pivot1 coords to pivot2 coords, in other words,
// the resulting transform of this function, applied to vertices of pivot1, would move
// them to where they should be if pivot2 was at the origin (0,0,0)
// - between_transform moves pivot1 vertices to where they should be relative to pivot2
MatP* pivot_between_transform(const struct Pivot* pivot1, const struct Pivot* pivot2, Mat between_transform);
QuatP* pivot_between_orientation(const struct Pivot* pivot1, const struct Pivot* pivot2, Quat between_rotation);
VecP* pivot_between_translation(const struct Pivot* pivot1, const struct Pivot* pivot2, Vec3f between_translation);
struct Pivot* pivot_combine(const struct Pivot* pivot1, const struct Pivot* pivot2, struct Pivot* r);
#endif