Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox: finished first ruff cleanup. now its about the algorithms

  • Property svn:executable set to *
File size: 4.3 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#include "p_node.h"
20
21
22#define texRate      32
23#define texRatef     4.0f
24#define tileSize     64
25
26//!< define the LOD level distances. later this could be dynamicaly adjusted
27#define HM_LOD_LOW_RES     5000         //!< low resolution unless farther away than LOW_RES
28#define HM_LOD_HIGH_RES    1000
29
30
31class SDL_Surface;
32class Vector;
33class Material;
34class PNode;
35class Texture;
36class HeightMap;
37
38
39//!< one part of the height map
40class Tile : public PNode
41{
42  public:
43    Tile(int i1, int j1, int i2, int j2, HeightMap* hm) ;
44    virtual ~Tile();
45
46    int getRes();
47    int setHighRes(bool b);
48
49    void draw();
50    inline void drawHighRes() const { highResModel->draw(); }
51    inline void drawLowRes() const { lowResModel->draw(); }
52
53
54  private:
55    void load(int i1, int j1, int i2, int i2, VertexArrayModel* model, int Res);
56
57
58  public:
59    float x;
60    float z;
61
62
63  private:
64    VertexArrayModel*                          highResModel;                      //!< heigh resolution model of the tile
65    VertexArrayModel*                          lowResModel;                       //!< low resolution model of the tile
66
67    HeightMap*                                 heightMapReference;                //!< reference to the heightmap this tile belongs to
68    int                                        highRes;                           //!<
69    int                                        lowRes;                            //!<
70};
71
72
73//!< the height map representation itself
74class HeightMap : public VertexArrayModel
75{
76  friend class Tile;
77
78  public:
79    HeightMap(const std::string& heightMapName);
80    HeightMap(const std::string& heightMapName, const std::string& colorMapName);
81    virtual ~HeightMap();
82
83    void init(const std::string& heightMapName);
84
85    void setAbsCoor(Vector V);
86    float getHeight(float x, float y);
87    float getNormal(float x, float y);
88
89    void load();
90    void load(int Mode);
91    void load(const std::string&, int Mode);
92    void scale( Vector V);
93
94    void draw() const;
95
96
97  private:
98    void generateNormalVectorField();
99    void drawRect(int xBottomLeft, int yBottomLeft, int xTopRight, int yTopRight );
100    void fixBoarder(int xBottomLeft, int yBottomLeft, int xTopRight, int yTopRight);
101
102    /** helper function absolute value @param val value*/
103    inline int abs(int val) { return (val<0)?-val:val; }
104    /** returns the max of two numbers @param x value 1 @param y value 2*/
105    inline int max(int x, int y) { return (x>y)? x:y; }
106    /** returns the min of two numbers @param x value 1 @param y value 2*/
107    inline int min(int x, int y) { return (x<y)? x: y; }
108
109
110  private:
111    SDL_Surface*                          heightMap;
112    SDL_Surface*                          colorMap;
113    unsigned char*                        heights;
114    unsigned char*                        colors;
115
116    Vector**                              normalVectorField;
117    Tile***                               tiles;
118    Vector                                camCoords;
119    Vector                                offsetCoords;
120    Material*                             tmp_mat;
121    Material*                             red_mat;
122    Texture*                              texture;
123    const PNode*                          camera;
124
125    float                                 scaleX ;
126    float                                 scaleY ;
127    float                                 scaleZ ;
128    float                                 shiftX ; // to be removed
129    float                                 shiftY ; // to be removed
130    float                                 shiftZ ; // to be removed
131    float                                 offsetX;
132    float                                 offsetY;
133    float                                 offsetZ;
134    int                                   cmScaleX;
135    int                                   cmScaleY;
136    bool                                  hasColourMap;
137};
Note: See TracBrowser for help on using the repository browser.