[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: |
---|
[6727] | 12 | main-programmer: bottac@ee.ethz.ch |
---|
[5942] | 13 | */ |
---|
| 14 | |
---|
[5967] | 15 | |
---|
[6494] | 16 | #include "vertex_array_model.h" |
---|
[5942] | 17 | |
---|
[6494] | 18 | |
---|
[6727] | 19 | #define texRate 32 |
---|
[6494] | 20 | #define texRatef 4.0f |
---|
[6727] | 21 | #define tileSize 128 |
---|
[6494] | 22 | |
---|
[5967] | 23 | class SDL_Surface; |
---|
| 24 | class Vector; |
---|
[6494] | 25 | class Material; |
---|
| 26 | class PNode; |
---|
| 27 | class Texture; |
---|
| 28 | class HeightMap; |
---|
[5942] | 29 | |
---|
[6494] | 30 | class Tile |
---|
[5942] | 31 | { |
---|
| 32 | public: |
---|
[6494] | 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 | |
---|
| 52 | class HeightMap : public VertexArrayModel |
---|
| 53 | { |
---|
| 54 | public: |
---|
| 55 | void draw(); |
---|
[5942] | 56 | void load(); |
---|
[6494] | 57 | void load(int Mode); |
---|
| 58 | void load(const char*, int Mode); |
---|
| 59 | void scale( Vector V); |
---|
[6727] | 60 | void setAbsCoor(Vector V); |
---|
[6494] | 61 | float getHeight(float x, float y); |
---|
[6727] | 62 | float getNormal(float x, float y); |
---|
[5942] | 63 | HeightMap(); |
---|
[5967] | 64 | HeightMap(const char*); |
---|
[6494] | 65 | HeightMap(const char*, const char*); |
---|
[5967] | 66 | ~HeightMap(); |
---|
| 67 | |
---|
[6494] | 68 | friend class Tile; |
---|
| 69 | |
---|
[5967] | 70 | private: |
---|
| 71 | SDL_Surface* heightMap; |
---|
[6494] | 72 | SDL_Surface* colourMap; |
---|
| 73 | unsigned char* heights; |
---|
| 74 | unsigned char* colours; |
---|
[5967] | 75 | |
---|
[6494] | 76 | void generateNormalVectorField(); |
---|
| 77 | void drawRect(int xBottomLeft, int yBottomLeft, int xTopRight, int yTopRight ); |
---|
| 78 | void fixBoarder(int xBottomLeft, int yBottomLeft, int xTopRight, int yTopRight); |
---|
| 79 | Vector ** normalVectorField ; |
---|
| 80 | Tile *** tiles; |
---|
[6727] | 81 | Vector camCoords; |
---|
| 82 | Vector offsetCoords; |
---|
[6494] | 83 | Material * tmp_mat; |
---|
| 84 | Material* red_mat; |
---|
| 85 | Texture* texture; |
---|
| 86 | const PNode* camera; |
---|
| 87 | float scaleX ; |
---|
| 88 | float scaleY ; |
---|
| 89 | float scaleZ ; |
---|
[6727] | 90 | float shiftX ; // to be removed |
---|
| 91 | float shiftY ; // to be removed |
---|
| 92 | float shiftZ ; // to be removed |
---|
| 93 | float offsetX; |
---|
| 94 | float offsetY; |
---|
| 95 | float offsetZ; |
---|
[6494] | 96 | int cmScaleX; |
---|
| 97 | int cmScaleY; |
---|
| 98 | bool hasColourMap; |
---|
| 99 | |
---|
| 100 | inline int abs(int val) |
---|
| 101 | { |
---|
| 102 | if(val < 0) val = -val; |
---|
| 103 | return val; |
---|
| 104 | } |
---|
| 105 | inline int max(int x, int y) |
---|
| 106 | { |
---|
| 107 | return (x>y)? x:y; |
---|
| 108 | } |
---|
| 109 | inline int min(int x, int y) |
---|
| 110 | { |
---|
| 111 | return (x<y)? x: y; |
---|
| 112 | } |
---|
[5942] | 113 | }; |
---|