annotate Renderer/test_render/node.cpp @ 503:516d5c91d5b4 draft double-linked-task-list

comment
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 11 Oct 2009 19:35:33 +0900
parents 15bfacccde99
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
283
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
1 #include <stdlib.h>
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
2 #include "SceneGraph.h"
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
3 #include "xml_file/cube.h"
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
4
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
5 static void
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
6 cube_collision(SceneGraphPtr node, int screen_w, int screen_h,
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
7 SceneGraphPtr tree)
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
8 {
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
9 }
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
10
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
11 static void
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
12 cube_move2(SceneGraphPtr node, int screen_w, int screen_h)
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
13 {
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
14 node->angle[1] += 1.0f;
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
15 if (node->angle[1] > 360.0f) {
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
16 node->angle[1] = 0.0f;
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
17 }
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
18
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
19 node->xyz[0] += node->stack_xyz[0];
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
20 if ((int)node->xyz[0] > screen_w || (int)node->xyz[0] < 0) {
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
21 node->stack_xyz[0] = -node->stack_xyz[0];
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
22 }
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
23
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
24 node->xyz[1] += node->stack_xyz[1];
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
25 if ((int)node->xyz[1] > screen_h || (int)node->xyz[1] < 0) {
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
26 node->stack_xyz[1] = -node->stack_xyz[1];
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
27 }
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
28 }
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
29
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
30 static void
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
31 cube_move(SceneGraphPtr node, int screen_w, int screen_h)
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
32 {
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
33 node->angle[1] += 1.0f;
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
34 if (node->angle[1] > 360.0f) {
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
35 node->angle[1] = 0.0f;
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
36 }
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
37
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
38 node->xyz[0] += node->stack_xyz[0];
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
39 if ((int)node->xyz[0] > screen_w || (int)node->xyz[0] < 0) {
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
40 node->stack_xyz[0] = -node->stack_xyz[0];
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
41 }
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
42
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
43 node->xyz[1] += node->stack_xyz[1];
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
44 if ((int)node->xyz[1] > screen_h || (int)node->xyz[1] < 0) {
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
45
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
46 // 実は微妙に意味が無い
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
47 srandom(random());
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
48
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
49 SceneGraphPtr p = node->clone();
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
50 p->position_init();
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
51 node->addBrother(p);
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
52 p->set_move_collision(cube_move2, cube_collision);
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
53 p->stack_xyz[0] = (float)(random() % 5);
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
54 p->stack_xyz[1] = (float)(random() % 5);
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
55 //p->xyz[0] = screen_w/2;
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
56 //p->xyz[1] = screen_h/2;
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
57 p->xyz[2] = node->xyz[2]+1000.0f;
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
58
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
59 node->stack_xyz[1] = -node->stack_xyz[1];
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
60 }
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
61 }
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
62
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
63 void
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
64 node_init(void)
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
65 {
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
66 SceneGraph::createFromXMLfile("xml_file/cube.xml");
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
67 Cube->set_move_collision(cube_move, cube_collision);
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
68 Cube->stack_xyz[0] = 2.0f;
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
69 Cube->stack_xyz[1] = 2.0f;
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
70 }