Mercurial > hg > Game > Cerium
annotate TaskManager/Test/test_render/node.cpp @ 186:06cdf8baa989 draft
fix
author | gongo@localhost.localdomain |
---|---|
date | Tue, 06 Jan 2009 16:18:37 +0900 |
parents | 9588726193e1 |
children | 7e045a4cdb77 cfd20d609ace |
rev | line source |
---|---|
139 | 1 #include <stdlib.h> |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
2 #include "SceneGraph.h" |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
3 #include "xml_file/cube.h" |
138 | 4 |
5 static void | |
6 cube_collision(SceneGraphPtr node, int screen_w, int screen_h, | |
7 SceneGraphPtr tree) | |
8 { | |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
9 } |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
10 |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
11 static void |
138 | 12 cube_move2(SceneGraphPtr node, int screen_w, int screen_h) |
13 { | |
14 node->angle[1] += 1.0f; | |
15 if (node->angle[1] > 360.0f) { | |
16 node->angle[1] = 0.0f; | |
17 } | |
18 | |
19 node->xyz[0] += node->stack_xyz[0]; | |
20 if ((int)node->xyz[0] > screen_w || (int)node->xyz[0] < 0) { | |
21 node->stack_xyz[0] = -node->stack_xyz[0]; | |
22 } | |
23 | |
24 node->xyz[1] += node->stack_xyz[1]; | |
25 if ((int)node->xyz[1] > screen_h || (int)node->xyz[1] < 0) { | |
26 node->stack_xyz[1] = -node->stack_xyz[1]; | |
27 } | |
28 } | |
29 | |
30 static void | |
31 cube_move(SceneGraphPtr node, int screen_w, int screen_h) | |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
32 { |
138 | 33 node->angle[1] += 1.0f; |
34 if (node->angle[1] > 360.0f) { | |
35 node->angle[1] = 0.0f; | |
36 } | |
37 | |
38 node->xyz[0] += node->stack_xyz[0]; | |
39 if ((int)node->xyz[0] > screen_w || (int)node->xyz[0] < 0) { | |
40 node->stack_xyz[0] = -node->stack_xyz[0]; | |
41 } | |
42 | |
43 node->xyz[1] += node->stack_xyz[1]; | |
44 if ((int)node->xyz[1] > screen_h || (int)node->xyz[1] < 0) { | |
45 | |
140 | 46 // 実は微妙に意味が無い |
139 | 47 srandom(random()); |
48 | |
138 | 49 SceneGraphPtr p = node->clone(); |
50 p->position_init(); | |
51 node->addBrother(p); | |
142 | 52 p->set_move_collision(cube_move2, cube_collision); |
139 | 53 p->stack_xyz[0] = (float)(random() % 5); |
54 p->stack_xyz[1] = (float)(random() % 5); | |
138 | 55 //p->xyz[0] = screen_w/2; |
56 //p->xyz[1] = screen_h/2; | |
139 | 57 p->xyz[2] = node->xyz[2]+1000.0f; |
138 | 58 |
59 node->stack_xyz[1] = -node->stack_xyz[1]; | |
60 } | |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
61 } |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
62 |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
63 void |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
64 node_init(void) |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
65 { |
143 | 66 SceneGraph::createFromXMLfile("xml_file/cube.xml"); |
67 Cube->set_move_collision(cube_move, cube_collision); | |
139 | 68 Cube->stack_xyz[0] = 2.0f; |
69 Cube->stack_xyz[1] = 2.0f; | |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
70 } |