00001 #ifndef PERIAPSIS_SPACE_CELESTIAL_BODY_H 00002 #define PERIAPSIS_SPACE_CELESTIAL_BODY_H 00003 00004 // 00005 // $Id: celestial_body.hpp 2 2008-03-01 20:58:50Z kulibali $ 00006 // 00007 // Copyright (c) 2008, The Periapsis Project. All rights reserved. 00008 // 00009 // Redistribution and use in source and binary forms, with or without 00010 // modification, are permitted provided that the following conditions are 00011 // met: 00012 // 00013 // * Redistributions of source code must retain the above copyright notice, 00014 // this list of conditions and the following disclaimer. 00015 // 00016 // * Redistributions in binary form must reproduce the above copyright 00017 // notice, this list of conditions and the following disclaimer in the 00018 // documentation and/or other materials provided with the distribution. 00019 // 00020 // * Neither the name of the The Periapsis Project nor the names of its 00021 // contributors may be used to endorse or promote products derived from 00022 // this software without specific prior written permission. 00023 // 00024 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 00025 // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 00026 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00027 // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 00028 // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00029 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00030 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00031 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00032 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00033 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00034 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00035 // 00036 00037 #include "space/space.hpp" 00038 #include "space/orbital_frame.hpp" 00039 #include "space/rotating_body.hpp" 00040 #include "space/atmosphere.hpp" 00041 #include "space/lithosphere.hpp" 00042 00043 #include "platform/texture.hpp" 00044 #include "scenegraph/utils.hpp" 00045 00046 namespace periapsis 00047 { 00048 00049 namespace space 00050 { 00051 00052 00053 /// Base class for celestial bodies: stars, planets, asteroids, etc. 00054 /// This node represents the inertial (nonrotating) frame centered at the center of the body. 00055 /// The body's lithosphere (in the case of a rocky body) or atmosphere (in the case of a gas body) represents the inclined and rotating frame. 00056 class SPACE_API celestial_body 00057 : public orbital_frame 00058 { 00059 gsgl::real_t mass; 00060 gsgl::real_t polar_radius; 00061 gsgl::real_t equatorial_radius; 00062 00063 rotating_body *rotating_frame; 00064 00065 atmosphere *atmo_child; 00066 lithosphere *litho_child; 00067 00068 gsgl::platform::texture *simple_colormap; 00069 gsgl::real_t simple_color_x_offset, simple_color_y_offset; 00070 00071 gsgl::platform::texture *simple_heightmap; 00072 gsgl::real_t simple_height_x_offset, simple_height_y_offset; 00073 gsgl::real_t simple_height_max; 00074 00075 gsgl::scenegraph::utils::simple_sphere *sphere; 00076 00077 public: 00078 celestial_body(const gsgl::data::config_record & obj_config); 00079 virtual ~celestial_body(); 00080 00081 gsgl::real_t get_mass() const { return mass; } 00082 gsgl::real_t get_polar_radius() const { return polar_radius; } 00083 gsgl::real_t get_equatorial_radius() const { return equatorial_radius; } 00084 00085 const rotating_body * get_rotating_frame() const { return rotating_frame; } 00086 const atmosphere * get_atmosphere() const { return atmo_child; } 00087 const lithosphere * get_lithosphere() const { return litho_child; } 00088 00089 const gsgl::platform::texture *get_simple_colormap() const { return simple_colormap; } 00090 const gsgl::real_t get_simple_color_x_offset() const { return simple_color_x_offset; } 00091 const gsgl::real_t get_simple_color_y_offset() const { return simple_color_y_offset; } 00092 00093 const gsgl::platform::texture *get_simple_heightmap() const { return simple_heightmap; } 00094 const gsgl::real_t get_simple_height_x_offset() const { return simple_height_x_offset; } 00095 const gsgl::real_t get_simple_height_y_offset() const { return simple_height_y_offset; } 00096 const gsgl::real_t get_simple_height_max() const { return simple_height_max; } 00097 00098 const gsgl::scenegraph::utils::simple_sphere *get_simple_sphere() const { return sphere; } 00099 00100 // 00101 virtual gsgl::real_t max_extent() const; 00102 virtual gsgl::real_t default_view_distance() const; 00103 virtual gsgl::real_t minimum_view_distance() const; 00104 00105 virtual gsgl::real_t get_priority(gsgl::scenegraph::context *); 00106 virtual void init(gsgl::scenegraph::context *c); 00107 virtual void draw(gsgl::scenegraph::context *c); ///< This will draw the simple sphere, so override if you want to do something else... 00108 00109 // 00110 void draw_point(float width); 00111 void draw_name(gsgl::scenegraph::context *c, gsgl::real_t near_plane, gsgl::real_t far_plane); 00112 00113 static gsgl::data::config_variable<gsgl::real_t> MIN_PIXEL_WIDTH; 00114 00115 protected: 00116 rotating_body * & get_rotating_frame() { return rotating_frame; } 00117 atmosphere * & get_atmosphere() { return atmo_child; } 00118 lithosphere * & get_lithosphere() { return litho_child; } 00119 gsgl::scenegraph::utils::simple_sphere * & get_simple_sphere() { return sphere; } 00120 }; // class celestial_body 00121 00122 00123 } // namespace space 00124 00125 } // namespace periapsis 00126 00127 #endif