00001 #ifndef GSGL_SCENEGRAPH_UTILS_H
00002 #define GSGL_SCENEGRAPH_UTILS_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include "scenegraph/scenegraph.hpp"
00038
00039 #include "data/broker.hpp"
00040 #include "math/vector.hpp"
00041 #include "scenegraph/node.hpp"
00042 #include "platform/color.hpp"
00043 #include "platform/vbuffer.hpp"
00044 #include "platform/texture.hpp"
00045
00046 namespace gsgl
00047 {
00048
00049 namespace scenegraph
00050 {
00051
00052 class context;
00053 class node;
00054
00055 namespace utils
00056 {
00057
00058
00059 class SCENEGRAPH_API coord_system
00060 {
00061 node *parent;
00062 const gsgl::real_t radius, degree_step;
00063 const platform::color draw_color;
00064 int display_list_id;
00065
00066 public:
00067 coord_system(node *parent, const gsgl::real_t radius, const gsgl::real_t degree_step, const platform::color & draw_color);
00068 ~coord_system();
00069
00070 void init(context *);
00071 void draw(context *);
00072 };
00073
00074
00075
00076 class SCENEGRAPH_API simple_sphere
00077 {
00078 node *parent;
00079 const int num_steps;
00080 const gsgl::real_t equatorial_radius, polar_radius;
00081
00082 platform::vertex_buffer vertices;
00083 platform::index_buffer indices;
00084
00085 platform::texture *tex;
00086 const gsgl::real_t tex_offset_x, tex_offset_y;
00087
00088 public:
00089 simple_sphere(node *parent, const int num_latitude_steps,
00090 const gsgl::real_t equatorial_radius, const gsgl::real_t polar_radius,
00091 platform::texture *tex, const gsgl::real_t tex_offset_x = 0, const gsgl::real_t tex_offset_y = 0);
00092 ~simple_sphere();
00093
00094 const gsgl::real_t get_tex_offset_x() const { return tex_offset_x; }
00095 const gsgl::real_t get_tex_offset_y() const { return tex_offset_y; }
00096
00097 void init(context *);
00098 void draw(context *);
00099 };
00100
00101
00102
00103
00104
00105 SCENEGRAPH_API math::vector pos_in_eye_space(node *frame, const math::vector & pos = math::vector::ZERO);
00106
00107
00108 SCENEGRAPH_API gsgl::real_t dot_in_eye_space(node *frame, const math::vector & pos = math::vector::ZERO);
00109
00110
00111 SCENEGRAPH_API bool is_on_screen(node *frame, const gsgl::real_t field_of_view, const gsgl::real_t aspect_ratio,
00112 const math::vector & pos = math::vector::ZERO, const gsgl::real_t radius = 0);
00113
00114
00115 SCENEGRAPH_API gsgl::real_t pixel_size(const gsgl::real_t distance, const gsgl::real_t radius,
00116 const gsgl::real_t field_of_view, const int pixels_in_field_of_view);
00117
00118
00119 SCENEGRAPH_API void save_screen_info(int viewport[4], gsgl::math::transform & modelview_projection);
00120
00121
00122 SCENEGRAPH_API gsgl::math::vector pos_in_screen_space(const gsgl::math::vector & point, const int viewport[4], const gsgl::math::transform & modelview_projection);
00123
00124
00125 SCENEGRAPH_API gsgl::real_t greatest_extent(const node *n);
00126
00127
00128
00129
00130
00131 SCENEGRAPH_API void draw_billboard(node *frame, const math::vector & pos, const gsgl::real_t radius);
00132
00133
00134
00135
00136 class SCENEGRAPH_API checkered_box
00137 : public scenegraph::node
00138 {
00139 gsgl::real_t radius;
00140 platform::vertex_buffer normals, vertices;
00141
00142 public:
00143 checkered_box(const gsgl::string & name, scenegraph::node *parent, gsgl::real_t radius);
00144 virtual ~checkered_box();
00145
00146 gsgl::real_t & get_radius() { return radius; }
00147
00148 virtual void init(gsgl::scenegraph::context *c);
00149 virtual void draw(gsgl::scenegraph::context *c);
00150 virtual void update(gsgl::scenegraph::context *c);
00151 virtual void cleanup(gsgl::scenegraph::context *c);
00152
00153 virtual gsgl::real_t get_priority(gsgl::scenegraph::context *);
00154 virtual gsgl::real_t max_extent() const;
00155
00156 virtual gsgl::real_t default_view_distance() const;
00157 virtual gsgl::real_t minimum_view_distance() const;
00158 };
00159
00160 }
00161
00162 }
00163
00164 }
00165
00166 #endif