//course-handles the static world data, communicates with dynamic data, and renders the terrain. //have a .h file with all the display lists and model imports corresponding to chars in the map. the char converted to an int, multiplied by 2, is the number of the display list. the one plus that number is the display list for the sides-to be used only if the neighboring quad is lower in elevation //necessary files: // -coursedisplaylists.h defines what the map chars mean, provides display lists for all of them. not implemented yet // -course file (name passed into input) size, other files' names, map //format: // width // height // numtextures // all texture pathnames // grid of chars //note: the player is stored in the map as an object with npcid 10000 or 10001 #ifndef __COURSECITY_H__ #define __COURSECITY_H__ #ifndef IGNORE_DEPEND #include #include #include #endif #include "texturemap.h" #include "playerlocation.h" #include "npc.h" class NPC; struct tileinfo {//stores the definition of a tile type unsigned char id;//the char in the map. (int)id should be the index of this node in the array. int solid; float height; int modelid; int xsize;//how many tiles it covers in each direction. the "real" tile is at the corner with minimum x and y values int ysize; }; struct tiledata {//a node in the map storage unsigned char type; float height;//if it's solid, how high does it go? for collision detection if you jump or fly. set in SetupModels bool solid;//do we need this anymore, or can it be removed? //bool rendered;//whether it was rendered this frame-use to check whether to draw objects? int contents;//pointer to the npc object cointained in this tile, -1 if none int drawtile;//which tile's model covers this one int renderlisting;//where this is listed in the to render array int event;//which event happens here, as an index in the event manager's event array }; #define HEIGHTSHIFT 100.0 //shift quads down by this amount-normally the lowest height is char 0, HS of 100.0 makes the lowest -100.0 before heightscale #define HEIGHTSCALE 25.0 //divide all heights by this amount while reading them in, to scale it #define sbx 100 #define sby 100 #define sbz 150 #define TILESIZE 1 //size of ground tiles class coursecity { public: coursecity(); virtual ~coursecity(); bool Init(char *coursefileinput); bool CheckCollision(float oldx, float oldy, float oldz, float newx, float newy, float newz, int thisguy); //thisguy is an object id that doesnt count for collision, so objects dont collide with themselves //if old xy vars=new xy vars, checks if that space is open at the newz elevation. //if different, if old and new are adjacent, checks whether theres a path from old to new. if not adjacent, error, returns no path. doesn't check whether old is open, but if an object is in new, or there's no path (diagonals: either adjacent square can be open for a path) returns a collision. //true means collision, false means no collision //examples: 1=old, 2=new, O=empty, X=full //X2 X2 //1X 1O //no path ok bool AddDynamicObject(int x, int y, int objectid); bool RemoveDynamicObject(int x, int y); bool MoveDynamicObject(int oldx, int oldy, int newx, int newy); bool Render(); int GetSize(); void SetStartLocation(PlayerState *theplayer,int which, bool init); //private: void Skybox(int hour, int minute);//draws the skybox, given the time of day void SetSolid();//goes through the map and sets tiles solid or not according to the type void DrawTile(float x, float y, float z, int tiletype);//draws one map tile, from x to x+1, y to y+1, z to z void drawbox(float, int, int, int, int, int, int ,int);//for drawing a box on a tile, interactive mode void MainLight(int on);//pass 0 to turn the light off, 1 to turn it on void SetGlowLights(int on); bool SetupModels(); //data char *coursefile; int coursewidth; int courseheight; tiledata *coursemap;//allocate after reading the file int numtypes;//how many tile types are defined tileinfo *tiletypes;//store definitions of tile types, should be 255 at least int start1x, start1y, start1z, start1theta, start2x, start2y, start2z, start2theta; //resource management enum { SKYBOX_FRONT=0, SKYBOX_BACK, SKYBOX_RIGHT, SKYBOX_LEFT, SKYBOX_UP, SKYBOX_DOWN, TERRAIN1, TERRAIN2, TERRAIN3, TERRAIN4, TERRAIN5, T6, T7, M6, M7, M8, M9, M10, M11, M12, M13, M14, M15, M16, NUM_TEXTURES }; TextureMap CourseTexture[100];//NUM_TEXTURES, set it to 100 for testing int texturesread; NPC *thenpcs;//pointer allows us to check info about npc's for collision detection PlayerState **playerlist;//stores pointers to the players that have been initialized (The only ones we care about for collision detection). the values are taken from parameters of setstartlocation }; #endif