Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

landscape.h

Go to the documentation of this file.
00001 // OMICRON ENGINE HEADER FILE
00002 //
00003 // --------------------------------------------------------------------------
00004 // Copyright (C) 2001-2002 by Bjoern Paetzel <kolrabi@gmx.de>
00005 //
00006 // This file is part of the Omicron Engine.
00007 //
00008 // The Omicron Engine is free software; you can redistribute it and/or modify
00009 // it under the terms of the  GNU General Public License  as published by the
00010 // Free Software Foundation;  either version  2  of the License,  or (at your
00011 // option) any later version.
00012 //
00013 // The Omicron Engine  is distributed in the hope that it will be useful, but
00014 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00015 // or  FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
00016 // for more details.
00017 //
00018 // You should have  received a copy of the  GNU General Public License  along
00019 // with The Omicron Engine;  if not,  write to the  Free Software Foundation,
00020 // Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
00021 //
00022 // --------------------------------------------------------------------------
00023 // Last modified:       $Date: 2002/12/07 19:02:17 $
00024 // By           :       $Author: kolrabi $
00025 // $Id: landscape.h,v 1.1.1.1 2002/12/07 19:02:17 kolrabi Exp $ 
00026 
00027 /*
00028 
00029   $Log: landscape.h,v $
00030   Revision 1.1.1.1  2002/12/07 19:02:17  kolrabi
00031   initial release
00032 
00033 
00034 */
00035 
00043 #include            "forward.h"
00044 
00045 /****************************************************************************
00046  ****************************************************************************
00047  * DEFINES ******************************************************************
00048  ****************************************************************************
00049  ****************************************************************************/
00050 
00051 #define             LSNFLAG_INVISIBLE       (1<<0)
00052 #define             LSNFLAG_NONSOLID        (1<<1)
00053 
00054 /****************************************************************************
00055  ****************************************************************************
00056  * TYPES ********************************************************************
00057  ****************************************************************************
00058  ****************************************************************************/
00059 
00060 #ifndef             OMICRON_TYPES_LANDSCAPE_DEFINED
00061 #define             OMICRON_TYPES_LANDSCAPE_DEFINED
00062 
00069 class landscape_c
00070 {
00071 protected:
00072 
00078     struct node_s
00079     {
00080         float           value;              
00081 
00082 //        vec3_t          normal;             ///< node's normal
00083 //        vec2_t          uv[4];              ///< texture coordinates
00084 
00085 //        ulong           color;              ///< light color
00086         ulong           shader;             
00087 
00088         ulong           flags;              
00089 
00090         vertex_t        verts[4];
00091 
00092         int             displist;
00093     };
00094 
00095     ulong           width, height;      
00096     vec3_c          scale;              
00097     vec3_c          pos;                
00098     array_c <struct shader_s> *shaders; 
00099 
00100     bool            init;               
00101 
00102     ulong           drawntiles;         
00103 
00104     node_s *        nodes;              
00105 
00106     void
00107         update_verts();
00108 
00109 public:
00110 
00111     // initialization ///////////////////////
00112                     landscape_c();
00113                     ~landscape_c();
00114 
00115     void                                
00116         deinit();
00117 
00118     // creation /////////////////////////////
00119 
00120     void                                
00121         create(ulong width, ulong height);
00122 
00123     void                                
00124         create_from_texture(sshort tex);
00125 
00126     void                                
00127         create_from_raw(uchar *raw, ulong width, ulong height);
00128 
00129     void                                
00130         create_from_image(image_c *img);
00131 
00132     // modification ////////////////////////
00133 
00134     void                                
00135         circles(ulong iter);
00136 
00137     void                                
00138         erode(float power);
00139 
00140     void                                
00141         normalize();
00142 
00143     void                                
00144         create_normals();
00145 
00152     void
00153         prelight();
00154 
00155     void                                
00156         set_height(ulong x, ulong y, float value);
00157 
00158     void                                
00159         set_uv(ulong x, ulong y, ushort corner, float u, float v);
00160 
00161     void                                
00162         tile_shader(shader_t *_shader);
00163 
00164     void                                
00165         stretch_shader(shader_t *_shader);
00166 
00167     void                                
00168         set_shader(shader_t *_shader, ulong x, ulong y, bool setuv);
00169 
00170     inline void                         
00171         set_scale(const vec3_t _scale);
00172 
00173     inline void
00174         set_position(const vec3_t _pos);
00175 
00176     // query
00177 
00178     float                               
00179         get_height(float x, float y);
00180 
00181     void                                
00182         get_slope(float x, float y, vec2_t out);
00183 
00184     bool                                
00185         is_node_visible(ulong x, ulong y);
00186 
00187     inline vec3_c                       
00188         get_scale();
00189 
00190     // statistics
00191 
00192     inline ulong                        
00193         get_drawn_tile_count();
00194 
00195     // draw etc.
00196 
00197     void
00198         draw();
00199 };
00200 
00201 inline void landscape_c::set_scale(const vec3_t _scale)
00202 { 
00203     AssertThis;     scale = _scale;
00204 }
00205 
00206 inline vec3_c landscape_c::get_scale()
00207 { 
00208     AssertThisValue(vec3_c());  return scale;
00209 }
00210 
00211 inline void landscape_c::set_position(const vec3_t _pos)
00212 { 
00213     AssertThis;     pos = _pos;
00214 }
00215 
00216 inline ulong landscape_c::get_drawn_tile_count()
00217 {
00218     AssertThisV;
00219  
00220     long l      = drawntiles; 
00221     drawntiles  = 0; 
00222     return l;
00223 }
00224 
00225 #endif

Generated on Wed Dec 18 15:48:46 2002 for omicron engine by doxygen1.2.18