character_camera.h
1 /*************************************************************************/
2 /* character_camera.h */
3 /*************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* http://www.godotengine.org */
7 /*************************************************************************/
8 /* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
9 /* */
10 /* Permission is hereby granted, free of charge, to any person obtaining */
11 /* a copy of this software and associated documentation files (the */
12 /* "Software"), to deal in the Software without restriction, including */
13 /* without limitation the rights to use, copy, modify, merge, publish, */
14 /* distribute, sublicense, and/or sell copies of the Software, and to */
15 /* permit persons to whom the Software is furnished to do so, subject to */
16 /* the following conditions: */
17 /* */
18 /* The above copyright notice and this permission notice shall be */
19 /* included in all copies or substantial portions of the Software. */
20 /* */
21 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
22 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
23 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
24 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
25 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
26 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
27 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
28 /*************************************************************************/
29 #ifndef CHARACTER_CAMERA_H
30 #define CHARACTER_CAMERA_H
31 
32 
33 #include "scene/3d/camera.h"
34 #if 0
35 class CharacterCamera : public Camera {
36 
37  OBJ_TYPE( CharacterCamera, Camera );
38 public:
39 
40  enum CameraType {
41  CAMERA_FIXED,
42  CAMERA_FOLLOW
43  };
44 
45 private:
46 
47 
48  CameraType type;
49 
50  //used for follow
51  Vector3 follow_pos;
52  //used for fixed
53  Vector2 orbit;
54  float distance;
55 
56  float height;
57 
58  float min_distance;
59  float max_distance;
60 
61  float max_orbit_x;
62  float min_orbit_x;
63 
64  float inclination;
65 
66  bool clip;
67  bool autoturn;
68  float autoturn_tolerance;
69  float autoturn_speed;
70 
71 
72 
73  struct ClipRay {
74  RID query;
75  bool clipped;
76  Vector3 clip_pos;
77  };
78 
79  ClipRay clip_ray[3];
80  Vector3 target_pos;
81  float clip_len;
82 
83 
84  Transform accepted;
85  Vector3 proposed_pos;
86 
87  bool use_lookat_target;
88  Vector3 lookat_target;
89 
90  void _compute_camera();
91 
92  RID ray_query;
93  RID left_turn_query;
94  RID right_turn_query;
95  RID target_body;
96 
97 protected:
98 
99  virtual void _request_camera_update() {} //ignore
100 
101  bool _set(const StringName& p_name, const Variant& p_value);
102  bool _get(const StringName& p_name,Variant &r_ret) const;
103  void _get_property_list( List<PropertyInfo> *p_list) const;
104  void _notification(int p_what);
105 
106  static void _bind_methods();
107 
108  void _ray_collision(Vector3 p_point, Vector3 p_normal, int p_subindex, ObjectID p_against,int p_idx);
109 
110 public:
111 
112 
113  void set_camera_type(CameraType p_camera_type);
114  CameraType get_camera_type() const;
115 
116  void set_orbit(const Vector2& p_orbit);
117  void set_orbit_x(float p_x);
118  void set_orbit_y(float p_y);
119  Vector2 get_orbit() const;
120 
121  void set_height(float p_height);
122  float get_height() const;
123 
124  void set_inclination(float p_degrees);
125  float get_inclination() const;
126 
127  void set_max_orbit_x(float p_max);
128  float get_max_orbit_x() const;
129 
130  void set_min_orbit_x(float p_min);
131  float get_min_orbit_x() const;
132 
133  void rotate_orbit(const Vector2& p_relative);
134 
135  void set_distance(float p_distance);
136  float get_distance() const;
137 
138  float get_min_distance() const;
139  float get_max_distance() const;
140  void set_min_distance(float p_min);
141  void set_max_distance(float p_max);
142 
143 
144  void set_clip(bool p_enabled);
145  bool has_clip() const;
146 
147  void set_autoturn(bool p_enabled);
148  bool has_autoturn() const;
149 
150  void set_autoturn_tolerance(float p_degrees);
151  float get_autoturn_tolerance() const;
152 
153  void set_autoturn_speed(float p_speed);
154  float get_autoturn_speed() const;
155 
156  void set_use_lookat_target(bool p_use, const Vector3 &p_lookat = Vector3());
157 
158  virtual Transform get_camera_transform() const;
159 
160  CharacterCamera();
161  ~CharacterCamera();
162 };
163 
164 VARIANT_ENUM_CAST( CharacterCamera::CameraType );
165 
166 #endif
167 #endif // CHARACTER_CAMERA_H
Definition: variant.h:74
Definition: camera.h:39
Definition: string_db.h:48
Definition: vector3.h:38
Definition: transform.h:38
Definition: rid.h:47
Definition: math_2d.h:65