Mercurial > hg > Game > Cerium
annotate Renderer/Test/untitled.cc @ 1963:6988e5478a8c draft
fix CudaScheduler
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 12 Feb 2014 17:56:40 +0900 |
parents | ec6b55aed337 |
children |
rev | line source |
---|---|
539 | 1 #include <stdlib.h> |
2 #include "SceneGraphRoot.h" | |
563
338ad9c856fc
all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
557
diff
changeset
|
3 #include "untitled.h" |
539 | 4 #include <math.h> |
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:
589
diff
changeset
|
7 cubetest_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:
589
diff
changeset
|
13 test_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, |
539 | 14 SceneGraphPtr tree) |
15 { | |
16 // test | |
17 } | |
18 | |
19 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:
589
diff
changeset
|
20 test_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) |
539 | 21 { |
22 | |
23 node->angle[0] += 10.0f; | |
24 | |
25 } | |
26 | |
27 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:
589
diff
changeset
|
28 cubetest_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) |
539 | 29 { |
30 node->angle[1] += 10.0f; | |
31 if (node->angle[1] > 360.0f) { | |
32 node->angle[1] = 0.0f; | |
33 } | |
34 node->xyz[0] += node->stack_xyz[0]; | |
35 if ((int)node->xyz[0] > screen_w || (int)node->xyz[0] < 0) { | |
36 node->stack_xyz[0] = -node->stack_xyz[0]; | |
37 } | |
1122 | 38 |
539 | 39 node->xyz[1] += node->stack_xyz[1]; |
40 if ((int)node->xyz[1] > screen_h || (int)node->xyz[1] < 0) { | |
41 node->stack_xyz[1] = -node->stack_xyz[1]; | |
42 } | |
43 | |
589 | 44 node->xyz[2] = 100 ; |
539 | 45 |
46 } | |
47 | |
557
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
48 MainLoopPtr |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
49 untitled::init(Viewer *sgroot, int screen_w, int screen_h) |
539 | 50 { |
51 SceneGraphPtr test00; | |
52 SceneGraphPtr test01; | |
53 SceneGraphPtr test02; | |
54 SceneGraphPtr test03; | |
55 SceneGraphPtr test04; | |
56 SceneGraphPtr test05; | |
57 SceneGraphPtr test06; | |
58 SceneGraphPtr test07; | |
59 SceneGraphPtr test08; | |
60 SceneGraphPtr test09; | |
61 | |
563
338ad9c856fc
all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
557
diff
changeset
|
62 sgroot->createFromXMLfile( "xml_file/Venus.xml"); |
539 | 63 |
563
338ad9c856fc
all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
557
diff
changeset
|
64 test00 = sgroot->createSceneGraph("Venus000"); |
338ad9c856fc
all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
557
diff
changeset
|
65 test01 = sgroot->createSceneGraph("Venus009"); |
338ad9c856fc
all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
557
diff
changeset
|
66 test02 = sgroot->createSceneGraph("Venus008"); |
338ad9c856fc
all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
557
diff
changeset
|
67 test03 = sgroot->createSceneGraph("Venus007"); |
338ad9c856fc
all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
557
diff
changeset
|
68 test04 = sgroot->createSceneGraph("Venus006"); |
338ad9c856fc
all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
557
diff
changeset
|
69 test05 = sgroot->createSceneGraph("Venus005"); |
338ad9c856fc
all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
557
diff
changeset
|
70 test06 = sgroot->createSceneGraph("Venus004"); |
338ad9c856fc
all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
557
diff
changeset
|
71 test07 = sgroot->createSceneGraph("Venus003"); |
338ad9c856fc
all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
557
diff
changeset
|
72 test08 = sgroot->createSceneGraph("Venus002"); |
338ad9c856fc
all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
557
diff
changeset
|
73 test09 = sgroot->createSceneGraph("Venus001"); |
539 | 74 |
75 // SceneGraph の move と collision を設定 | |
76 test00->set_move_collision(cubetest_move, cubetest_collision); | |
77 test00->stack_xyz[0] = 3.0f; | |
78 test00->stack_xyz[1] = 3.0f; | |
79 test00->stack_xyz[2] = 3.0f; | |
80 | |
81 test01->set_move_collision(test_move, test_collision); | |
82 test02->set_move_collision(test_move, test_collision); | |
83 test03->set_move_collision(test_move, test_collision); | |
84 test04->set_move_collision(test_move, test_collision); | |
85 test05->set_move_collision(test_move, test_collision); | |
86 test06->set_move_collision(test_move, test_collision); | |
87 test07->set_move_collision(test_move, test_collision); | |
88 test08->set_move_collision(test_move, test_collision); | |
89 test09->set_move_collision(test_move, test_collision); | |
90 | |
91 // SceneGraph 同士の親子関係を設定 (今回は 親 test00、子 その他) | |
92 test00->addChild(test01); | |
93 test00->addChild(test02); | |
94 test00->addChild(test03); | |
95 test00->addChild(test04); | |
96 test00->addChild(test05); | |
97 test00->addChild(test06); | |
98 test00->addChild(test07); | |
99 test00->addChild(test08); | |
100 test00->addChild(test09); | |
101 | |
102 // SceneGraphRoot に、使用する SceneGraph を設定する | |
103 // このとき、ユーザーが記述した SceneGraph の root を渡す。 | |
104 sgroot->setSceneData(test00); | |
557
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
105 return sgroot; |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
106 } |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
107 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
108 extern Application * |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
109 application() { |
563
338ad9c856fc
all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
557
diff
changeset
|
110 return new untitled(); |
539 | 111 } |
557
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
112 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
113 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
|
114 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
115 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
|
116 extern void task_initialize(); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
117 static void TMend(TaskManager *manager); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
118 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
119 int |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
120 TMmain(TaskManager *manager, int argc, char *argv[]) |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
121 { |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
122 task_initialize(); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
123 manager->set_TMend(TMend); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
124 return init(manager, argc, argv); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
125 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
126 } |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
127 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
128 void |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
129 TMend(TaskManager *manager) |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
130 { |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
131 printf("test_nogl end\n"); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
132 } |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
133 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
134 /* end */ |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
135 |