00001
00002 #ifndef __WORLD_Block_H_
00003 #define __WORLD_Block_H_
00004
00005 namespace std {}
00006 using namespace std;
00007
00008 #include <fstream>
00009
00010 #include <vector>
00011
00012 #include "H_Geometry.h"
00013 #include "H_Object.h"
00014
00015 class WorldBlock
00016 {
00017 public:
00018 class MyTriangle
00019 {
00020 public:
00021 MyTriangle();
00022 MyTriangle(int Aa, int Ab, int Ac, int ASurfaceType);
00023 void Read(istream &in);
00024 void Write(ostream &out);
00025 void Init();
00026
00027
00028 void reset(WorldBlock *MyWorldBlock, int i, int j, int k, int ASurfaceType);
00029 bool IsInside(const Point2D &point);
00030 void UpdateValues();
00031 void FillIfEmpty();
00032 void Fill();
00033 void drawBorder();
00034
00035 Contact GetValueAt(const Point2D &point);
00036 bool Hit(const FixedVector &ARay);
00037 bool IsInside(Point3D &X);
00038 void SetMaterial(int FillMode);
00039 OFFObject::Polygon toOFFPolygon() const;
00040
00041
00042 Point3D *Corner1;
00043 Point3D *Corner2;
00044 Point3D *Corner3;
00045 int MyI, MyJ, MyK;
00046 REAL a, b, c;
00047 Point3D Normal;
00048 REAL MyOffset;
00049 public:
00050 int SurfaceType;
00051 WorldBlock *MyWorldBlock;
00052 Point3D Impact;
00053 };
00054 public:
00055 WorldBlock();
00056 bool IsInitialized();
00057
00058 MyTriangle *WhichTriangle(const Point2D &point);
00059 void InitTriangles();
00060
00061 Contact GetValueAt(const Point2D &point);
00062 void Place(Ref &ARef);
00063 void InitOffObject();
00064 Contact GetContact(const Point3D &APoint3D);
00065 Contact GetContact(const FixedVector &WheelRay);
00066
00067 void draw();
00068
00069 void ReadFile(const char *WorldBlockkName);
00070 void WriteFile(ofstream &outfile);
00071
00072 public:
00073
00074 vector<OFFObject::Vertex> MyOFFVertexes;
00075 vector<MyTriangle> Triangles;
00076
00077 Ref EndPosition;
00078 OFFObject MyOffObject;
00079
00080
00081 MyTriangle *PreviousTriangle;
00082 HRect EncapsulatingRect;
00083 };
00084
00085
00086 #define GRASS_SURFACE 0
00087 #define TARMAC_SURFACE 1
00088
00089
00090 istream &operator >> (istream &infile, WorldBlock::MyTriangle &ATriangle);
00091 ostream &operator << (ostream &outfile, WorldBlock::MyTriangle &ATriangle);
00092
00093 #endif //__WORLD_Block_H_