character_camera.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. #include "scene/3d/camera.h"
  32. #if 0
  33. class CharacterCamera : public Camera {
  34. OBJ_TYPE( CharacterCamera, Camera );
  35. public:
  36. enum CameraType {
  37. CAMERA_FIXED,
  38. CAMERA_FOLLOW
  39. };
  40. private:
  41. CameraType type;
  42. //used for follow
  43. Vector3 follow_pos;
  44. //used for fixed
  45. Vector2 orbit;
  46. float distance;
  47. float height;
  48. float min_distance;
  49. float max_distance;
  50. float max_orbit_x;
  51. float min_orbit_x;
  52. float inclination;
  53. bool clip;
  54. bool autoturn;
  55. float autoturn_tolerance;
  56. float autoturn_speed;
  57. struct ClipRay {
  58. RID query;
  59. bool clipped;
  60. Vector3 clip_pos;
  61. };
  62. ClipRay clip_ray[3];
  63. Vector3 target_pos;
  64. float clip_len;
  65. Transform accepted;
  66. Vector3 proposed_pos;
  67. bool use_lookat_target;
  68. Vector3 lookat_target;
  69. void _compute_camera();
  70. RID ray_query;
  71. RID left_turn_query;
  72. RID right_turn_query;
  73. RID target_body;
  74. protected:
  75. virtual void _request_camera_update() {} //ignore
  76. bool _set(const StringName& p_name, const Variant& p_value);
  77. bool _get(const StringName& p_name,Variant &r_ret) const;
  78. void _get_property_list( List<PropertyInfo> *p_list) const;
  79. void _notification(int p_what);
  80. static void _bind_methods();
  81. void _ray_collision(Vector3 p_point, Vector3 p_normal, int p_subindex, ObjectID p_against,int p_idx);
  82. public:
  83. void set_camera_type(CameraType p_camera_type);
  84. CameraType get_camera_type() const;
  85. void set_orbit(const Vector2& p_orbit);
  86. void set_orbit_x(float p_x);
  87. void set_orbit_y(float p_y);
  88. Vector2 get_orbit() const;
  89. void set_height(float p_height);
  90. float get_height() const;
  91. void set_inclination(float p_degrees);
  92. float get_inclination() const;
  93. void set_max_orbit_x(float p_max);
  94. float get_max_orbit_x() const;
  95. void set_min_orbit_x(float p_min);
  96. float get_min_orbit_x() const;
  97. void rotate_orbit(const Vector2& p_relative);
  98. void set_distance(float p_distance);
  99. float get_distance() const;
  100. float get_min_distance() const;
  101. float get_max_distance() const;
  102. void set_min_distance(float p_min);
  103. void set_max_distance(float p_max);
  104. void set_clip(bool p_enabled);
  105. bool has_clip() const;
  106. void set_autoturn(bool p_enabled);
  107. bool has_autoturn() const;
  108. void set_autoturn_tolerance(float p_degrees);
  109. float get_autoturn_tolerance() const;
  110. void set_autoturn_speed(float p_speed);
  111. float get_autoturn_speed() const;
  112. void set_use_lookat_target(bool p_use, const Vector3 &p_lookat = Vector3());
  113. virtual Transform get_camera_transform() const;
  114. CharacterCamera();
  115. ~CharacterCamera();
  116. };
  117. VARIANT_ENUM_CAST( CharacterCamera::CameraType );
  118. #endif
  119. #endif // CHARACTER_CAMERA_H