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