Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/graphics/importer/height_map.h @ 7469

Last change on this file since 7469 was 7469, checked in by patrick, 18 years ago

orxonox: introduced some new variable names, some code cleanup

  • Property svn:executable set to *
File size: 4.2 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: bottac@ee.ethz.ch
13
14   review: patrick boenzli, patrick@orxonox.ethz.ch
15*/
16
17
18#include "vertex_array_model.h"
19
20
21#define texRate      32
22#define texRatef     4.0f
23#define tileSize     64
24
25//!< define the LOD level distances. later this could be dynamicaly adjusted
26#define HM_LOD_LOW_RES     5000         //!< low resolution unless farther away than LOW_RES
27#define HM_LOD_HIGH_RES    1000
28
29
30class SDL_Surface;
31class Vector;
32class Material;
33class PNode;
34class Texture;
35class HeightMap;
36
37
38//!< one part of the height map
39class Tile
40{
41  public:
42    Tile(int i1, int j1, int i2, int j2, HeightMap* hm) ;
43    virtual ~Tile();
44
45    int getRes();
46    int setHighRes(bool b);
47
48    void draw();
49    inline void drawHighRes() { highResModel->draw(); }
50    inline void drawLowRes() { lowResModel->draw(); }
51
52
53  private:
54    void load(int i1, int j1, int i2, int i2, VertexArrayModel* model, int Res);
55
56
57  public:
58    float x;
59    float z;
60
61
62  private:
63    VertexArrayModel*                          highResModel;                      //!< heigh resolution model of the tile
64    VertexArrayModel*                          lowResModel;                       //!< low resolution model of the tile
65
66    HeightMap*                                 heightMapReference;                //!< reference to the heightmap this tile belongs to
67    int                                        highRes;                           //!<
68    int                                        lowRes;                            //!<
69};
70
71
72//!< the height map representation itself
73class HeightMap : public VertexArrayModel
74{
75  friend class Tile;
76
77  public:
78    HeightMap();
79    HeightMap(const std::string&);
80    HeightMap(const std::string&, const std::string&);
81    virtual ~HeightMap();
82
83    void setAbsCoor(Vector V);
84    float getHeight(float x, float y);
85    float getNormal(float x, float y);
86
87    void load();
88    void load(int Mode);
89    void load(const std::string&, int Mode);
90    void scale( Vector V);
91
92    void draw();
93
94
95  private:
96    void generateNormalVectorField();
97    void drawRect(int xBottomLeft, int yBottomLeft, int xTopRight, int yTopRight );
98    void fixBoarder(int xBottomLeft, int yBottomLeft, int xTopRight, int yTopRight);
99
100    /** helper function absolute value @param val value*/
101    inline int abs(int val) { return (val<0)?-val:val; }
102    /** returns the max of two numbers @param x value 1 @param y value 2*/
103    inline int max(int x, int y) { return (x>y)? x:y; }
104    /** returns the min of two numbers @param x value 1 @param y value 2*/
105    inline int min(int x, int y) { return (x<y)? x: y; }
106
107
108  private:
109    SDL_Surface*                          heightMap;
110    SDL_Surface*                          colourMap;
111    unsigned char*                        heights;
112    unsigned char*                        colours;
113
114    Vector**                              normalVectorField;
115    Tile***                               tiles;
116    Vector                                camCoords;
117    Vector                                offsetCoords;
118    Material*                             tmp_mat;
119    Material*                             red_mat;
120    Texture*                              texture;
121    const PNode*                          camera;
122
123    float                                 scaleX ;
124    float                                 scaleY ;
125    float                                 scaleZ ;
126    float                                 shiftX ; // to be removed
127    float                                 shiftY ; // to be removed
128    float                                 shiftZ ; // to be removed
129    float                                 offsetX;
130    float                                 offsetY;
131    float                                 offsetZ;
132    int                                   cmScaleX;
133    int                                   cmScaleY;
134    bool                                  hasColourMap;
135};
Note: See TracBrowser for help on using the repository browser.