00001
00002
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
00043 #include "forward.h"
00044
00045
00046
00047
00048
00049
00050
00051 #define LSNFLAG_INVISIBLE (1<<0)
00052 #define LSNFLAG_NONSOLID (1<<1)
00053
00054
00055
00056
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
00083
00084
00085
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
00112 landscape_c();
00113 ~landscape_c();
00114
00115 void
00116 deinit();
00117
00118
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
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
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
00191
00192 inline ulong
00193 get_drawn_tile_count();
00194
00195
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