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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
/*************************************************************************/
/* follow_camera.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission 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: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE 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. */
/*************************************************************************/
#ifndef FOLLOW_CAMERA_H
#define FOLLOW_CAMERA_H
#include "scene/3d/camera.h"
class FollowCamera : public Camera {
OBJ_TYPE( FollowCamera, Camera );
private:
//used for follow
Vector3 follow_pos;
//used for fixed
Vector2 initial_orbit;
Vector2 orbit;
float distance;
float height;
float target_width;
float min_distance;
float max_distance;
float max_orbit_x;
float min_orbit_x;
float inclination;
float extraclip;
bool fullclip;
bool clip;
bool autoturn;
float autoturn_tolerance;
float autoturn_speed;
bool smooth;
float smooth_rot_ratio;
float smooth_pos_ratio;
struct ClipRay {
RID query;
bool clipped;
Vector3 cast_pos;
Vector3 clip_pos;
};
ClipRay clip_ray[3];
Vector3 target_pos;
float clip_len;
Vector3 up_vector;
virtual RES _get_gizmo_geometry() const;
Transform ted;
Vector3 proposed_pos;
Transform accepted;
Transform final;
RID target_body;
bool use_lookat_target;
Vector3 lookat_target;
void _compute_camera();
bool queries_active;
void _clear_queries();
void _set_initial_orbit(const Vector2& p_orbit);
protected:
virtual void _request_camera_update() {} //ignore
void _notification(int p_what);
static void _bind_methods();
void _ray_collision(Vector3 p_point, Vector3 p_normal, int p_subindex, ObjectID p_against,int p_idx);
public:
void set_orbit(const Vector2& p_orbit);
void set_orbit_x(float p_x);
void set_orbit_y(float p_y);
Vector2 get_orbit() const;
void set_height(float p_height);
float get_height() const;
void set_inclination(float p_degrees);
float get_inclination() const;
void set_max_orbit_x(float p_max);
float get_max_orbit_x() const;
void set_min_orbit_x(float p_min);
float get_min_orbit_x() const;
void rotate_orbit(const Vector2& p_relative);
void set_distance(float p_distance);
float get_distance() const;
float get_min_distance() const;
float get_max_distance() const;
void set_min_distance(float p_min);
void set_max_distance(float p_max);
/** FINISH THIS AND CLEAN IT UP */
void set_clip(bool p_enabled);
bool has_clip() const;
void set_autoturn(bool p_enabled);
bool has_autoturn() const;
void set_autoturn_tolerance(float p_degrees);
float get_autoturn_tolerance() const;
void set_autoturn_speed(float p_speed);
float get_autoturn_speed() const;
void set_smoothing(bool p_enable);
bool has_smoothing() const;
void set_translation_smoothing(float p_amount);
float get_translation_smoothing() const;
void set_rotation_smoothing(float p_amount);
float get_rotation_smoothing() const;
void set_use_lookat_target(bool p_use, const Vector3 &p_lookat = Vector3());
void set_up_vector(const Vector3& p_up);
Vector3 get_up_vector() const;
virtual Transform get_camera_transform() const;
FollowCamera();
~FollowCamera();
};
#endif // FOLLOW_CAMERA_H
|