Mercurial > hg > Members > kono > Cerium
annotate Renderer/Test/universe.cc @ 757:5238f3e854fc
Test/create_task , create SPE task from application.
author | hiroki |
---|---|
date | Fri, 29 Jan 2010 14:34:30 +0900 |
parents | b7376415fa5f |
children | 10a8a80c2ea7 |
rev | line source |
---|---|
507 | 1 #include <stdlib.h> |
2 #include "SceneGraphRoot.h" | |
557
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
3 #include "universe.h" |
507 | 4 |
5 static void | |
656
d0b8860c17f8
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
|
6 earth_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, |
507 | 7 SceneGraphPtr tree) |
8 { | |
9 } | |
10 | |
11 static void | |
656
d0b8860c17f8
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
|
12 moon_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, |
507 | 13 SceneGraphPtr tree) |
14 { | |
15 } | |
16 | |
17 static void | |
656
d0b8860c17f8
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
|
18 moon_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) |
507 | 19 { |
20 node->angle[0] += 3.0f; | |
21 } | |
22 | |
23 | |
24 static void | |
656
d0b8860c17f8
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
|
25 earth_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) |
507 | 26 { |
27 node->angle[1] += 1.0f; | |
28 if (node->angle[1] > 360.0f) { | |
29 node->angle[1] = 0.0f; | |
30 } | |
31 | |
32 node->xyz[0] += node->stack_xyz[0]; | |
33 if ((int)node->xyz[0] > screen_w || (int)node->xyz[0] < 0) { | |
34 node->stack_xyz[0] = -node->stack_xyz[0]; | |
35 } | |
36 | |
37 node->xyz[1] += node->stack_xyz[1]; | |
38 if ((int)node->xyz[1] > screen_h || (int)node->xyz[1] < 0) { | |
39 node->stack_xyz[1] = -node->stack_xyz[1]; | |
40 } | |
41 } | |
42 | |
557
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
43 MainLoopPtr |
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
44 universe::init(Viewer *sgroot, int screen_w, int screen_h) |
507 | 45 { |
46 SceneGraphPtr earth; | |
47 SceneGraphPtr moon; | |
48 | |
563
b21a013051a2
all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
557
diff
changeset
|
49 sgroot->createFromXMLfile( "xml_file/universe.xml"); |
507 | 50 |
51 // SGList.h にある SceneGraph ID から SceneGraph を生成する | |
563
b21a013051a2
all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
557
diff
changeset
|
52 earth = sgroot->createSceneGraph("Earth"); |
507 | 53 |
54 // SceneGraph の move と collision を設定 | |
55 earth->set_move_collision(earth_move, earth_collision); | |
56 earth->stack_xyz[0] = 3.0f; | |
57 earth->stack_xyz[1] = 3.0f; | |
58 | |
563
b21a013051a2
all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
557
diff
changeset
|
59 moon = sgroot->createSceneGraph("Moon"); |
507 | 60 moon->set_move_collision(moon_move, moon_collision); |
61 | |
62 // SceneGraph 同士の親子関係を設定 (今回は 親 earth、子 moon) | |
63 earth->addChild(moon); | |
64 | |
65 // SceneGraphRoot に、使用する SceneGraph を設定する | |
66 // このとき、ユーザーが記述した SceneGraph の root を渡す。 | |
67 sgroot->setSceneData(earth); | |
557
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
68 return sgroot; |
507 | 69 } |
557
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
70 |
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
71 extern Application * |
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
72 application() { |
563
b21a013051a2
all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
557
diff
changeset
|
73 return new universe(); |
557
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
74 } |
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
75 |
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
76 const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n"; |
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
77 |
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
78 extern int init(TaskManager *manager, int argc, char *argv[]); |
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
79 extern void task_initialize(); |
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
80 static void TMend(TaskManager *manager); |
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
81 |
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
82 int |
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
83 TMmain(TaskManager *manager, int argc, char *argv[]) |
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
84 { |
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
85 task_initialize(); |
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
86 manager->set_TMend(TMend); |
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
87 return init(manager, argc, argv); |
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
88 |
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
89 } |
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
90 |
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
91 void |
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
92 TMend(TaskManager *manager) |
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
93 { |
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
94 printf("test_nogl end\n"); |
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
95 } |
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
96 |
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
97 /* end */ |
ec72b601b71f
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
508
diff
changeset
|
98 |