710
|
1 #include "Application.h"
|
|
2
|
|
3 typedef void (*spe_move_func)(void *cv, int screen_w, int screen_h);
|
|
4 typedef void (*spe_collision_func)(void *cv, int screen_w, int screen_h);
|
|
5
|
|
6 typedef struct {
|
|
7 double x, y, next_x, next_y;
|
|
8 double vx, vy, next_vx, next_vy;
|
|
9 double angle[3];
|
|
10 int can_move;
|
|
11 int id;
|
|
12 char *objname;
|
|
13 spe_move_func move;
|
|
14 spe_collision_func collision;
|
|
15 SceneGraphPtr parent;
|
|
16 SceneGraphPtr root;
|
|
17 } *ChainPropertyPtr, ChainProperty;
|
|
18
|
|
19 #define FALSE 0
|
|
20 #define TRUE !FALSE
|
|
21 #define CHAIN_LEN 50
|
|
22
|
|
23 static const double m = 100.0;
|
|
24 static const double k = 7000.0;
|
|
25 static const double g = 9.8;
|
|
26 static const double dt = 0.003;
|
|
27 static const double chain_width = 10;
|
|
28 static const double safe = 0.995;
|
|
29
|
|
30 class Chain : public Application {
|
|
31 public:
|
|
32 Chain(){}
|
|
33
|
|
34 SceneGraphPtr scenegraph_factory(void *p, int size);
|
|
35 SceneGraphPtr scenegraph_connector(void *p, int size, SceneGraphPtr s, SceneGraphPtr sg_available_list);
|
|
36 void init(TaskManager *manager, int w, int h);
|
|
37 void init_chain_vars(ChainPropertyPtr cv);
|
|
38 void chain_move(TaskManager *manager, SceneGraphPtr sg, int w, int h);
|
|
39 //void chain_collision(SceneGraphPtr sg, int w, int h, SceneGraphPtr osg);
|
|
40 void chain_collision(ChainPropertyPtr cv, int w, int h);
|
|
41 void createSceneGraphFromProperty(SceneGraphPtr root, ChainPropertyPtr cv);
|
|
42 //void property_swich();
|
|
43 //void set_properties(ChainPropertyPtr cv);
|
|
44 MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
|
|
45
|
|
46
|
|
47 };
|