Mercurial > hg > Game > Cerium
annotate Renderer/Test/node.cc @ 2022:fac44ad2867d draft
make a sound
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 16 Jul 2014 02:50:32 +0900 |
parents | f326494ffdc7 |
children |
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 { |
1136 | 34 |
35 SceneGraphRootPtr sgroot = (SceneGraphRootPtr)sgroot_; | |
36 | |
539 | 37 node->angle[1] += 1.0f; |
38 if (node->angle[1] > 360.0f) { | |
39 node->angle[1] = 0.0f; | |
40 } | |
41 | |
42 node->xyz[0] += node->stack_xyz[0]; | |
43 if ((int)node->xyz[0] > screen_w || (int)node->xyz[0] < 0) { | |
44 node->stack_xyz[0] = -node->stack_xyz[0]; | |
45 } | |
46 | |
47 node->xyz[1] += node->stack_xyz[1]; | |
48 if ((int)node->xyz[1] > screen_h || (int)node->xyz[1] < 0) { | |
49 | |
50 // 実は微妙に意味が無い | |
51 // そうじゃなくて、やっちゃいけないことです。 | |
52 // srandom(random()); | |
53 | |
1136 | 54 SceneGraphPtr p = node->clone(sgroot->tmanager); |
539 | 55 p->position_init(); |
56 node->addBrother(p); | |
57 p->set_move_collision(cube_move2, cube_collision); | |
58 p->stack_xyz[0] = (float)(random() % 5); | |
59 p->stack_xyz[1] = (float)(random() % 5); | |
60 //p->xyz[0] = screen_w/2; | |
61 //p->xyz[1] = screen_h/2; | |
62 p->xyz[2] = node->xyz[2]+1000.0f; | |
63 | |
64 node->stack_xyz[1] = -node->stack_xyz[1]; | |
65 } | |
66 } | |
67 | |
557
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
68 MainLoopPtr |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
69 node::init(Viewer *sgroot, int screen_w, int screen_h) |
539 | 70 { |
563
338ad9c856fc
all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
557
diff
changeset
|
71 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
|
72 SceneGraphPtr Cube = sgroot->createSceneGraph("Cube"); |
539 | 73 Cube->set_move_collision(cube_move, cube_collision); |
74 Cube->stack_xyz[0] = 2.0f; | |
75 Cube->stack_xyz[1] = 2.0f; | |
557
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
76 return sgroot; |
539 | 77 } |
557
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
78 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
79 extern Application * |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
80 application() { |
563
338ad9c856fc
all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
557
diff
changeset
|
81 return new node(); |
557
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 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
84 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
|
85 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
86 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
|
87 extern void task_initialize(); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
88 static void TMend(TaskManager *manager); |
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 int |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
91 TMmain(TaskManager *manager, int argc, char *argv[]) |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
92 { |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
93 task_initialize(); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
94 manager->set_TMend(TMend); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
95 return init(manager, argc, argv); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
96 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
97 } |
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 void |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
100 TMend(TaskManager *manager) |
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 printf("test_nogl end\n"); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
103 } |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
104 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
105 /* end */ |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
106 |