Mercurial > hg > Game > Cerium
annotate Renderer/Test/node.cc @ 859:3f45bd7b910a draft
linda connection init
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 17 Jun 2010 04:46:25 +0900 |
parents | 91e2c96be77b |
children | f326494ffdc7 |
rev | line source |
---|---|
539 | 1 #include <stdlib.h> |
2 #include "SceneGraphRoot.h" | |
3 #include "SceneGraph.h" | |
563
338ad9c856fc
all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
557
diff
changeset
|
4 #include "node.h" |
539 | 5 |
6 static void | |
653
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
563
diff
changeset
|
7 cube_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, |
539 | 8 SceneGraphPtr tree) |
9 { | |
10 } | |
11 | |
12 static void | |
653
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
563
diff
changeset
|
13 cube_move2(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) |
539 | 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 | |
653
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
563
diff
changeset
|
32 cube_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) |
539 | 33 { |
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 | |
47 // 実は微妙に意味が無い | |
48 // そうじゃなくて、やっちゃいけないことです。 | |
49 // srandom(random()); | |
50 | |
51 SceneGraphPtr p = node->clone(); | |
52 p->position_init(); | |
53 node->addBrother(p); | |
54 p->set_move_collision(cube_move2, cube_collision); | |
55 p->stack_xyz[0] = (float)(random() % 5); | |
56 p->stack_xyz[1] = (float)(random() % 5); | |
57 //p->xyz[0] = screen_w/2; | |
58 //p->xyz[1] = screen_h/2; | |
59 p->xyz[2] = node->xyz[2]+1000.0f; | |
60 | |
61 node->stack_xyz[1] = -node->stack_xyz[1]; | |
62 } | |
63 } | |
64 | |
557
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
65 MainLoopPtr |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
66 node::init(Viewer *sgroot, int screen_w, int screen_h) |
539 | 67 { |
563
338ad9c856fc
all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
557
diff
changeset
|
68 sgroot->createFromXMLfile( "xml_file/cube.xml"); |
338ad9c856fc
all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
557
diff
changeset
|
69 SceneGraphPtr Cube = sgroot->createSceneGraph("Cube"); |
539 | 70 Cube->set_move_collision(cube_move, cube_collision); |
71 Cube->stack_xyz[0] = 2.0f; | |
72 Cube->stack_xyz[1] = 2.0f; | |
557
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
73 return sgroot; |
539 | 74 } |
557
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
75 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
76 extern Application * |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
77 application() { |
563
338ad9c856fc
all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
557
diff
changeset
|
78 return new node(); |
557
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
79 } |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
80 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
81 const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n"; |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
82 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
83 extern int init(TaskManager *manager, int argc, char *argv[]); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
84 extern void task_initialize(); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
85 static void TMend(TaskManager *manager); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
86 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
87 int |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
88 TMmain(TaskManager *manager, int argc, char *argv[]) |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
89 { |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
90 task_initialize(); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
91 manager->set_TMend(TMend); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
92 return init(manager, argc, argv); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
93 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
94 } |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
95 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
96 void |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
97 TMend(TaskManager *manager) |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
98 { |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
99 printf("test_nogl end\n"); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
100 } |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
101 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
102 /* end */ |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
103 |