Mercurial > hg > Game > Cerium
annotate Renderer/Test/motion_man.cc @ 1813:d7973604e81f draft
fix memin size
author | kkb |
---|---|
date | Thu, 12 Dec 2013 18:34:16 +0900 |
parents | 20a09f7522a7 |
children |
rev | line source |
---|---|
1380
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 #include <math.h> |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 #include <stdlib.h> |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 #include <unistd.h> |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4 #include "SceneGraphRoot.h" |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 #include "MainLoop.h" |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 #include "motion_man.h" |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 float x=0,y=-80; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 float dx=0,dy=80; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11 float tx=0,ty=10; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12 float cx=0,cy=-10; |
1383
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
13 static int cube_subID,cub5ID,cub6ID; |
1386
20a09f7522a7
change motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1383
diff
changeset
|
14 static float cube_radius = 35.0f; |
20a09f7522a7
change motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1383
diff
changeset
|
15 static float cube_sub_radius = 35.0f; |
1380
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
17 static void |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
18 push_move_false(SceneGraphPtr, void *sgroot_, int w, int h, SceneGraphPtr tree) { |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
19 } |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
20 |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
21 static void |
1383
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
22 walk(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree) { |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
23 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; |
1386
20a09f7522a7
change motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1383
diff
changeset
|
24 SceneGraphIteratorPtr it = sgroot->getIterator(tree); |
1383
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
25 |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
26 Pad *pad = sgroot->getController(); |
1386
20a09f7522a7
change motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1383
diff
changeset
|
27 it->next(cub5ID); |
20a09f7522a7
change motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1383
diff
changeset
|
28 SceneGraphPtr cub5 = it->get(); |
1383
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
29 |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
30 if (pad->left.isHold()) { |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
31 if (x==80) { |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
32 cub5->angle[0] -= 10; |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
33 y=cub5->angle[0]; |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
34 if (y==-80) |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
35 x=0; |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
36 } else if (y==-80) { |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
37 cub5->angle[0] += 10; |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
38 x=cub5->angle[0]; |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
39 } |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
40 } |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
41 |
1386
20a09f7522a7
change motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1383
diff
changeset
|
42 it->next(cub6ID); |
20a09f7522a7
change motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1383
diff
changeset
|
43 SceneGraphPtr cub6 = it->get(); |
1383
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
44 if (pad->left.isHold()) { |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
45 if (dx==-80) { |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
46 cub6->angle[0] += 10; |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
47 dy=cub6->angle[0]; |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
48 if (dy==80) |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
49 dx=0; |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
50 } else if (dy==80) { |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
51 cub6->angle[0] -= 10; |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
52 dx=cub6->angle[0]; |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
53 } |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
54 } |
1386
20a09f7522a7
change motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1383
diff
changeset
|
55 |
20a09f7522a7
change motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1383
diff
changeset
|
56 float x_distance,y_distance,distance; |
20a09f7522a7
change motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1383
diff
changeset
|
57 it->next(cube_subID); |
20a09f7522a7
change motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1383
diff
changeset
|
58 SceneGraphPtr cube_sub = it->get(); |
20a09f7522a7
change motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1383
diff
changeset
|
59 x_distance = node->xyz[0] - cube_sub->xyz[0]; |
20a09f7522a7
change motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1383
diff
changeset
|
60 y_distance = node->xyz[1] - cube_sub->xyz[1]; |
20a09f7522a7
change motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1383
diff
changeset
|
61 |
20a09f7522a7
change motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1383
diff
changeset
|
62 distance = hypotf(x_distance,y_distance); |
20a09f7522a7
change motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1383
diff
changeset
|
63 |
20a09f7522a7
change motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1383
diff
changeset
|
64 if (distance <= (cube_radius = cube_sub_radius)) { |
20a09f7522a7
change motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1383
diff
changeset
|
65 cube_sub->xyz[0] -= 30; |
20a09f7522a7
change motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1383
diff
changeset
|
66 if (cube_sub->xyz[0]<-40) |
20a09f7522a7
change motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1383
diff
changeset
|
67 cube_sub->xyz[0] = screen_w / 3; |
20a09f7522a7
change motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1383
diff
changeset
|
68 } |
1383
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
69 } |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
70 |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
71 static void |
1380
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
72 move_left(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) { |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
73 |
1383
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
74 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
75 Pad *pad = sgroot->getController(); |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
76 |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
77 if (pad->left.isHold()) { |
1380
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
78 node->xyz[0] -= 10; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
79 if (node->xyz[0] < 0) |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
80 node->xyz[0] = screen_w; |
1383
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
81 } |
1380
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
82 } |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
83 |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
84 static void |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
85 push_right_arm(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) { |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
86 |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
87 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
88 Pad *pad = sgroot->getController(); |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
89 |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
90 if (pad->triangle.isHold()) { |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
91 if (tx==-80) { |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
92 node->angle[1] += 10; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
93 ty=node->angle[1]; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
94 if (ty==10) |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
95 tx=0; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
96 } else if (ty==10) { |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
97 node->angle[1] -= 10; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
98 tx=node->angle[1]; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
99 } |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
100 } |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
101 } |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
102 |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
103 static void |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
104 push_left_arm(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) { |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
105 |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
106 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
107 Pad *pad = sgroot->getController(); |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
108 |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
109 if (pad->square.isHold()) { |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
110 if (cx==80) { |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
111 node->angle[1] -= 10; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
112 cy=node->angle[1]; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
113 if (cy==-10) |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
114 cx=0; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
115 } else if (cy==-10) { |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
116 node->angle[1] += 10; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
117 cx=node->angle[1]; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
118 } |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
119 } |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
120 } |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
121 |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
122 MainLoopPtr |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
123 motion_man::init(Viewer *sgroot, int screen_w, int screen_h) { |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
124 |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
125 SceneGraphPtr cube1; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
126 SceneGraphPtr cube2; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
127 SceneGraphPtr cube3; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
128 SceneGraphPtr cube4; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
129 SceneGraphPtr cube5; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
130 SceneGraphPtr cube6; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
131 |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
132 sgroot->createFromXMLfile("xml_file/parent.xml"); |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
133 |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
134 SceneGraphPtr light = sgroot->getLight(0); |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
135 sgroot->OnLightSwitch(0); |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
136 light->xyz[0] = screen_w / 2; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
137 light->xyz[1] = screen_h / 2; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
138 light->xyz[2] = -100; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
139 |
1383
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
140 SceneGraphPtr root = sgroot->createSceneGraph(); |
1380
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
141 cube1 = sgroot->createSceneGraph("Cube"); |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
142 |
1383
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
143 cube1->xyz[0] = (screen_w / 2) / 2 + (screen_w / 2); |
1380
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
144 cube1->xyz[1] = screen_h / 2; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
145 cube1->xyz[2] = 0; |
1383
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
146 cube1->angle[1] = 90; |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
147 |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
148 root->addChild(cube1); |
1380
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
149 |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
150 cube2 = sgroot->createSceneGraph("Cube.001"); |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
151 cube3 = sgroot->createSceneGraph("Cube.002"); |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
152 cube4 = sgroot->createSceneGraph("Cube.003"); |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
153 cube5 = sgroot->createSceneGraph("Cube.004"); |
1383
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
154 cub5ID = cube5->sgid; |
1380
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
155 cube6 = sgroot->createSceneGraph("Cube.005"); |
1383
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
156 cub6ID = cube6->sgid; |
1380
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
157 cube1->addChild(cube2); |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
158 cube1->addChild(cube3); |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
159 cube1->addChild(cube4); |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
160 cube1->addChild(cube5); |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
161 cube1->addChild(cube6); |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
162 |
1383
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
163 cube1->set_move_collision(move_left, walk); |
1380
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
164 cube3->set_move_collision(push_right_arm, push_move_false); |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
165 cube2->set_move_collision(push_left_arm, push_move_false); |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
166 |
1383
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
167 SceneGraphPtr cube_sub = sgroot->createSceneGraph("Cube"); |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
168 cube_subID = cube_sub->sgid; |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
169 cube_sub->xyz[0] = screen_w / 3; |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
170 cube_sub->xyz[1] = screen_h / 2; |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
171 cube_sub->xyz[2] = 0; |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
172 root->addChild(cube_sub); |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
173 |
fa3d77953998
change Makefile.macosx motion_man.cc
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
1380
diff
changeset
|
174 sgroot->setSceneData(root); |
1380
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
175 |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
176 return sgroot; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
177 } |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
178 |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
179 extern Application *application() { |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
180 return new motion_man(); |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
181 } |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
182 |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
183 const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n"; |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
184 |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
185 extern int init(TaskManager *manager, int argc, char *argv[]); |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
186 extern void task_initialize(); |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
187 static void TMend(TaskManager *manager); |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
188 |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
189 int |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
190 TMmain(TaskManager *manager, int argc, char *argv[]) |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
191 { |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
192 task_initialize(); |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
193 manager->set_TMend(TMend); |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
194 return init(manager, argc, argv); |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
195 |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
196 } |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
197 |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
198 void |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
199 TMend(TaskManager *manager) |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
200 { |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
201 printf("test_nogl end\n"); |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
202 } |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
203 |
dd3b8f54e3e3
add motion_man.cc motion_man.h parent.xml
Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
204 /* end */ |