Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox: work flush on hm

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