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