[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 |
---|
[5942] | 13 | */ |
---|
| 14 | |
---|
[5967] | 15 | |
---|
[6956] | 16 | #include "vertex_array_model.h" |
---|
[5942] | 17 | |
---|
[6956] | 18 | |
---|
| 19 | #define texRate 32 |
---|
| 20 | #define texRatef 4.0f |
---|
| 21 | #define tileSize 64 |
---|
| 22 | |
---|
[5967] | 23 | class SDL_Surface; |
---|
| 24 | class Vector; |
---|
[6956] | 25 | class Material; |
---|
| 26 | class PNode; |
---|
| 27 | class Texture; |
---|
| 28 | class HeightMap; |
---|
[5942] | 29 | |
---|
[6981] | 30 | class Tile |
---|
[5942] | 31 | { |
---|
| 32 | public: |
---|
[6956] | 33 | void draw(); |
---|
| 34 | void drawHighRes(); |
---|
| 35 | void drawLowRes(); |
---|
| 36 | int getRes(); |
---|
| 37 | int setHighRes(bool b); |
---|
| 38 | Tile(int i1, int j1, int i2, int j2, HeightMap* hm ) ; |
---|
| 39 | Tile(); |
---|
| 40 | float x; |
---|
| 41 | float z; |
---|
[6981] | 42 | virtual ~Tile(); |
---|
[6956] | 43 | |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | private: |
---|
| 47 | HeightMap* hmref; |
---|
| 48 | VertexArrayModel* highResModel; |
---|
[6981] | 49 | VertexArrayModel* lowResModel; |
---|
[6956] | 50 | int highRes; |
---|
| 51 | int lowRes; |
---|
| 52 | void load(int i1, int j1, int i2, int i2, HeightMap* hm, VertexArrayModel* model, int Res); |
---|
| 53 | }; |
---|
| 54 | |
---|
| 55 | class HeightMap : public VertexArrayModel |
---|
| 56 | { |
---|
| 57 | public: |
---|
| 58 | void draw(); |
---|
[5942] | 59 | void load(); |
---|
[6956] | 60 | void load(int Mode); |
---|
[7221] | 61 | void load(const std::string&, int Mode); |
---|
[6981] | 62 | void scale( Vector V); |
---|
[6956] | 63 | void setAbsCoor(Vector V); |
---|
[6981] | 64 | float getHeight(float x, float y); |
---|
[6956] | 65 | float getNormal(float x, float y); |
---|
[5942] | 66 | HeightMap(); |
---|
[7221] | 67 | HeightMap(const std::string&); |
---|
| 68 | HeightMap(const std::string&, const std::string&); |
---|
[6981] | 69 | virtual ~HeightMap(); |
---|
[5967] | 70 | |
---|
[6956] | 71 | friend class Tile; |
---|
| 72 | |
---|
[5967] | 73 | private: |
---|
| 74 | SDL_Surface* heightMap; |
---|
[6956] | 75 | SDL_Surface* colourMap; |
---|
[6981] | 76 | unsigned char* heights; |
---|
[6956] | 77 | unsigned char* colours; |
---|
[5967] | 78 | |
---|
[6956] | 79 | void generateNormalVectorField(); |
---|
| 80 | void drawRect(int xBottomLeft, int yBottomLeft, int xTopRight, int yTopRight ); |
---|
| 81 | void fixBoarder(int xBottomLeft, int yBottomLeft, int xTopRight, int yTopRight); |
---|
[6981] | 82 | Vector ** normalVectorField ; |
---|
[6956] | 83 | Tile *** tiles; |
---|
| 84 | Vector camCoords; |
---|
[6981] | 85 | Vector offsetCoords; |
---|
[6956] | 86 | Material * tmp_mat; |
---|
| 87 | Material* red_mat; |
---|
| 88 | Texture* texture; |
---|
| 89 | const PNode* camera; |
---|
| 90 | float scaleX ; |
---|
| 91 | float scaleY ; |
---|
| 92 | float scaleZ ; |
---|
| 93 | float shiftX ; // to be removed |
---|
| 94 | float shiftY ; // to be removed |
---|
| 95 | float shiftZ ; // to be removed |
---|
| 96 | float offsetX; |
---|
| 97 | float offsetY; |
---|
| 98 | float offsetZ; |
---|
| 99 | int cmScaleX; |
---|
| 100 | int cmScaleY; |
---|
| 101 | bool hasColourMap; |
---|
| 102 | |
---|
| 103 | inline int abs(int val) |
---|
| 104 | { |
---|
| 105 | if(val < 0) val = -val; |
---|
| 106 | return val; |
---|
| 107 | } |
---|
| 108 | inline int max(int x, int y) |
---|
| 109 | { |
---|
| 110 | return (x>y)? x:y; |
---|
| 111 | } |
---|
| 112 | inline int min(int x, int y) |
---|
| 113 | { |
---|
| 114 | return (x<y)? x: y; |
---|
| 115 | } |
---|
[5942] | 116 | }; |
---|