Mercurial > hg > Members > kono > Cerium
annotate TaskManager/Test/test_render/cube_action.cpp @ 215:7ca6a2ef5be9
fix SceneGraph Constructor, Destructor
author | gongo@gendarme.local |
---|---|
date | Sun, 01 Feb 2009 22:14:44 +0900 |
parents | 159519cdca1f |
children | 0f1ff7b06157 |
rev | line source |
---|---|
212 | 1 #include "SceneGraphRoot.h" |
2 #include "SGList.h" | |
142 | 3 |
4 static void cube_move_left(SceneGraphPtr node, int screen_w, int screen_h); | |
5 static void cube_move_right(SceneGraphPtr node, int screen_w, int screen_h); | |
6 static void cube_move_idle(SceneGraphPtr node, int screen_w, int screen_h); | |
7 static void cube_collision(SceneGraphPtr node, int screen_w, int screen_h, | |
8 SceneGraphPtr tree); | |
9 | |
10 static void cube_split(SceneGraphPtr root); | |
11 | |
12 static void | |
13 cube_move_left(SceneGraphPtr node, int screen_w, int screen_h) | |
14 { | |
15 node->xyz[0] -= node->stack_xyz[0]; | |
16 node->xyz[1] -= node->stack_xyz[0] * node->stack_xyz[1]; | |
17 node->xyz[2] -= node->stack_xyz[0] * node->stack_xyz[2]; | |
18 | |
144 | 19 if (node->xyz[0] < 0) { |
20 node->set_move_collision(cube_move_right, cube_collision); | |
21 } | |
22 | |
23 if (node->xyz[1] < 0 || node->xyz[1] > screen_h) { | |
24 node->stack_xyz[1] = -node->stack_xyz[1]; | |
25 } | |
26 | |
143 | 27 node->angle[0] += 2.0f; |
28 node->angle[1] += 2.0f * node->stack_xyz[1]; | |
29 node->angle[2] += 2.0f * node->stack_xyz[2]; | |
142 | 30 |
215
7ca6a2ef5be9
fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents:
213
diff
changeset
|
31 if (node->frame > 10 && sgroot->controller->circle.isPush()) { |
7ca6a2ef5be9
fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents:
213
diff
changeset
|
32 cube_split(node); |
213
159519cdca1f
add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
212
diff
changeset
|
33 } |
142 | 34 } |
35 | |
36 static void | |
37 cube_move_right(SceneGraphPtr node, int screen_w, int screen_h) | |
38 { | |
39 node->xyz[0] += node->stack_xyz[0]; | |
40 node->xyz[1] -= node->stack_xyz[0] * node->stack_xyz[1]; | |
41 node->xyz[2] -= node->stack_xyz[0] * node->stack_xyz[2]; | |
42 | |
144 | 43 if (node->xyz[0] > screen_w) { |
44 node->set_move_collision(cube_move_left, cube_collision); | |
45 } | |
46 | |
47 if (node->xyz[1] < 0 || node->xyz[1] > screen_h) { | |
48 node->stack_xyz[1] = -node->stack_xyz[1]; | |
49 } | |
50 | |
143 | 51 node->angle[0] += 2.0f; |
52 node->angle[1] += 2.0f * node->stack_xyz[1]; | |
53 node->angle[2] += 2.0f * node->stack_xyz[2]; | |
215
7ca6a2ef5be9
fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents:
213
diff
changeset
|
54 |
7ca6a2ef5be9
fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents:
213
diff
changeset
|
55 if (node->frame > 10 && sgroot->controller->circle.isPush()) { |
7ca6a2ef5be9
fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents:
213
diff
changeset
|
56 cube_split(node); |
213
159519cdca1f
add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
212
diff
changeset
|
57 } |
142 | 58 } |
59 | |
60 static void | |
61 cube_split(SceneGraphPtr root) | |
62 { | |
63 SceneGraphPtr p = root->clone(); | |
64 root->addBrother(p); | |
65 | |
215
7ca6a2ef5be9
fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents:
213
diff
changeset
|
66 printf("%d %d\n", root->frame, p->frame); |
7ca6a2ef5be9
fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents:
213
diff
changeset
|
67 // TODO |
7ca6a2ef5be9
fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents:
213
diff
changeset
|
68 // 木の作り方変えたらここ消す |
7ca6a2ef5be9
fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents:
213
diff
changeset
|
69 p->frame = 0; |
7ca6a2ef5be9
fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents:
213
diff
changeset
|
70 root->frame = 0; |
7ca6a2ef5be9
fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents:
213
diff
changeset
|
71 |
142 | 72 root->set_move_collision(cube_move_left, cube_collision); |
73 p->set_move_collision(cube_move_right, cube_collision); | |
213
159519cdca1f
add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
212
diff
changeset
|
74 |
142 | 75 p->xyz[0] = root->xyz[0] + 2; |
76 p->xyz[1] = root->xyz[1]; | |
77 p->xyz[2] = root->xyz[2]; | |
78 | |
143 | 79 p->stack_xyz[0] = 2.0f; |
142 | 80 p->stack_xyz[1] = random()%3-1; |
81 p->stack_xyz[2] = random()%3-1; | |
82 | |
83 root->xyz[0] -= 2; | |
143 | 84 root->stack_xyz[0] = 2.0f; |
142 | 85 root->stack_xyz[1] = random()%3-1; |
86 root->stack_xyz[2] = random()%3-1; | |
87 } | |
88 | |
89 | |
90 static void | |
91 cube_move_idle(SceneGraphPtr node, int screen_w, int screen_h) | |
92 { | |
93 node->xyz[0] = screen_w/2; | |
94 node->xyz[1] = screen_h/2; | |
212 | 95 //node->xyz[2] = -300.0f; |
142 | 96 |
213
159519cdca1f
add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
212
diff
changeset
|
97 if (sgroot->controller->circle.isPush()) { |
215
7ca6a2ef5be9
fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents:
213
diff
changeset
|
98 cube_split(node); |
213
159519cdca1f
add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
212
diff
changeset
|
99 } |
142 | 100 } |
101 | |
102 static void | |
103 cube_collision(SceneGraphPtr node, int screen_w, int screen_h, | |
104 SceneGraphPtr tree) | |
105 { | |
106 } | |
107 | |
108 void | |
144 | 109 create_cube_split(int number) |
142 | 110 { |
212 | 111 SceneGraphPtr cube; |
112 | |
113 //sgroot->createFromXMLfile("xml_file/cube_split.xml"); | |
114 sgroot->createFromXMLfile("xml_file/cube.xml"); | |
115 | |
116 //if (number == 0) { | |
117 //cube = sgroot->createSceneGraph(SmallCube); | |
118 //} else { | |
119 cube = sgroot->createSceneGraph(Cube); | |
120 cube->xyz[0] = 960.0f; | |
121 cube->xyz[1] = 540.0f; | |
122 //} | |
123 | |
124 cube->set_move_collision(cube_move_idle, cube_collision); | |
125 | |
126 sgroot->setSceneData(cube); | |
142 | 127 } |