123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391 |
-
-
- #ifndef _WORLD_H_
- #define _WORLD_H_
-
- #define BAD_BLOOD
-
- #ifdef BAD_BLOOD
- #include <SkeletalModel.h>
- #endif
-
- #include <List.h>
- #include <Vector.h>
- #include <MatMath.h>
-
-
- typedef enum {
- roomFlag_underWater = 0x0001
- } room_flags_t;
-
- typedef enum {
- worldMoveType_walkNoSwim = -1,
- worldMoveType_walk = 0,
- worldMoveType_noClipping = 1,
- worldMoveType_fly = 2,
- worldMoveType_swim = 3
- } worldMoveType;
-
- typedef struct {
- vec3_t pos;
- } vertex_t;
-
-
-
- typedef struct {
- vec2_t st;
- } texel_t;
-
- typedef struct {
- int num_verts;
- vertex_t vertex[4];
- texel_t texel[4];
- float pos[3];
- float radius;
- int texture;
- } sprite_t;
-
- typedef struct {
- int num_sprites;
- sprite_t *sprite;
- } sprite_seq_t;
-
-
- typedef struct {
- int index[3];
- vec_t st[6];
- int texture;
- unsigned short transparency;
- } texture_tri_t;
-
- typedef struct {
- Vector<texture_tri_t *> texturedTriangles;
- Vector<texture_tri_t *> coloredTriangles;
- Vector<texture_tri_t *> texturedRectangles;
- Vector<texture_tri_t *> coloredRectangles;
-
- vec3_t center;
- float radius;
-
- unsigned int vertexCount;
- vec_t *vertices;
-
- unsigned int colorCount;
- vec_t *colors;
-
- unsigned int normalCount;
- vec_t *normals;
- } model_mesh_t;
-
- typedef struct entity_s {
- int id;
- float pos[3];
- float angles[3];
- int type;
- int room;
- worldMoveType moveType;
- bool moving;
- struct entity_s *master;
-
- int state;
- int objectId;
-
- int modelId;
- void *tmpHook;
- bool animate;
-
-
-
- } entity_t;
-
- typedef struct {
- int index;
- float yaw;
- float pos[3];
-
-
-
- } static_model_t;
-
- typedef struct {
- float vertices[4][3];
- float normal[3];
- int adjoining_room;
- } portal_t;
-
- typedef struct {
- vertex_t a;
- vertex_t b;
- vertex_t c;
- vertex_t d;
- } box_t;
-
- typedef struct {
- vec_t floor;
- vec_t ceiling;
-
- bool wall;
- } sector_t;
-
-
- typedef struct {
- Vector<int> adjacentRooms;
- Vector<portal_t *> portals;
- Vector<static_model_t *> models;
- Vector<sprite_t *> sprites;
- Vector<box_t *> boxes;
- Vector<sector_t *> sectors;
-
- int id;
- unsigned int flags;
- unsigned int numXSectors;
- unsigned int numZSectors;
- float pos[3];
- vec3_t bbox_min;
- vec3_t bbox_max;
- } room_mesh_t;
-
-
- typedef struct world_entity_s {
- vec3_t pos;
- vec3_t lastPos;
- vec3_t angle;
- vec_t ttl;
-
- int type;
- int state;
-
-
-
- } world_entity_t;
-
- typedef struct {
- vec3_t pos;
- vec3_t lastPos;
- vec3_t angle;
- char clipping;
- float time, eventTime, eventTimer;
- int state, nextState;
- float health;
-
-
- unsigned int uid;
- char name[32];
- int actor, enemy;
-
-
- unsigned int model;
- unsigned int skin;
- unsigned int animFrame;
-
- } actor_entity_t;
-
- enum OpenRaiderEvent {
- eNone = 0,
- eWeaponDischarge,
- eDying,
- eDead,
- eWounded,
- eRunForward,
- eRunBackward,
- eJump,
- eCrouchWalk,
- eIdle,
- eTaunt,
- eTurn,
- eRespawn,
- eLand
- };
-
-
- class World {
- public:
-
- enum WorldFlag {
- fEnableHopping = 1
- };
-
-
-
- World();
-
-
-
- ~World();
-
-
-
- int getRoomByLocation(int index, float x, float y, float z);
-
-
-
- int getRoomByLocation(float x, float y, float z);
-
-
-
- int getAdjoiningRoom(int index,
- float x, float y, float z,
- float x2, float y2, float z2);
-
-
-
- int getSector(int room, float x, float z);
- int getSector(int room, float x, float z, float *floor, float *ceiling);
-
- unsigned int getRoomInfo(int room);
-
-
-
- bool isWall(int room, int sector);
-
-
-
- bool getHeightAtPosition(int index, float x, float *y, float z);
-
- #ifdef BAD_BLOOD
-
- model_mesh_t *getMesh(int index);
- skeletal_model_t *getModel(int index);
- room_mesh_t *getRoom(int index);
- Vector<entity_t *> *getEntities();
- Vector<sprite_seq_t *> *getSprites();
- Vector<room_mesh_t *> *getRooms();
- #endif
-
-
-
- void setFlag(WorldFlag flag);
-
-
-
- void clearFlag(WorldFlag flag);
-
-
-
- void destroy();
-
-
-
- void addRoom(room_mesh_t *room);
-
-
-
- void addMesh(model_mesh_t *model);
-
-
-
- void addEntity(entity_t *e);
-
-
-
- int addModel(skeletal_model_t *model);
-
-
-
- void addSprite(sprite_seq_t *sprite);
-
-
-
- void moveEntity(entity_t *e, char movement);
-
- private:
-
-
-
- void clear();
-
- bool mClearLock;
- unsigned int mFlags;
- Vector<entity_t *> mEntities;
- Vector<room_mesh_t *> mRooms;
- Vector<model_mesh_t *> mMeshes;
- Vector<sprite_seq_t *> mSprites;
- Vector<skeletal_model_t *> mModels;
- };
-
- #endif
|