00001 #ifndef WIND_H
00002 #define WIND_H
00003
00004 #include <stdio.h>
00005 #include <math.h>
00006 #include <stdlib.h>
00007
00008 typedef enum {
00009 LONELY = 0,
00010 EMPTY,
00011 INITIAL,
00012 READY } _tstage;
00013
00014 typedef enum {
00015 NORTH = 0,
00016 NORTHWEST,
00017 WEST,
00018 SOUTHWEST,
00019 SOUTH,
00020 SOUTHEAST,
00021 EAST,
00022 NORTHEAST,
00023 } _tdirections;
00024
00025 #define NET_WIDTH 8
00026 #define NET_HEIGHT 5
00027 #define WIND_CONE_DELTA 5.0f
00028 #define MAX_NEIGHBOURS 4
00029 #define MAX_WIND_SPEED 20
00030
00031 class SNode;
00032 class SNode {
00033 public:
00034 SNode(unsigned char xx, unsigned char yy);
00035 char* get_stage() { return &stage;}
00036 void set_empty() { stage = EMPTY; }
00037 float* get_wind_speed() { return &speed;}
00038 float* get_wind_heading() { return &heading;}
00039 void set_neighbour(char dir, SNode* other);
00040 void update_forbidden();
00041 void gen_random();
00042 protected:
00043 unsigned char x;
00044 unsigned char y;
00045 SNode* north;
00046 SNode* south;
00047 SNode* west;
00048 SNode* east;
00049 SNode* northwest;
00050 SNode* southwest;
00051 SNode* northeast;
00052 SNode* southeast;
00053 float forbidden_headings[MAX_NEIGHBOURS];
00054 signed char last_h;
00055 float speed;
00056 float heading;
00057 char stage;
00058 bool is_forbidden(float angle);
00059 };
00060
00061 class SNet {
00062 public:
00063 SNet();
00064 ~SNet();
00065 float* get_wind(float x, float y);
00066 private:
00067 void clg();
00068 void chg();
00069 void initial_rn();
00070 SNode* sectors[NET_WIDTH][NET_HEIGHT];
00071 };
00072
00073 class FNode : SNode {
00074 public:
00075 FNode(unsigned char xx, unsigned char yy);
00076 };
00077
00078 #endif