Mercurial > hg > Game > Cerium
annotate Renderer/Test/universe.cc @ 1292:90efd2aac2cb draft
add matrix test and debug light vector
author | Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 02 Dec 2011 12:27:51 +0900 |
parents | ec6b55aed337 |
children | e51127dbd63c |
rev | line source |
---|---|
539 | 1 #include <stdlib.h> |
2 #include "SceneGraphRoot.h" | |
557
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
3 #include "universe.h" |
539 | 4 |
5 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
|
6 earth_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, |
539 | 7 SceneGraphPtr tree) |
8 { | |
9 } | |
10 | |
11 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
|
12 moon_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, |
539 | 13 SceneGraphPtr tree) |
14 { | |
15 } | |
16 | |
17 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
|
18 moon_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) |
539 | 19 { |
1122 | 20 node->angle[0] += 3.0f; |
539 | 21 } |
22 | |
23 | |
24 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
|
25 earth_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) |
539 | 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
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
43 MainLoopPtr |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
44 universe::init(Viewer *sgroot, int screen_w, int screen_h) |
539 | 45 { |
46 SceneGraphPtr earth; | |
47 SceneGraphPtr moon; | |
48 | |
563
338ad9c856fc
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"); |
855 | 50 sgroot->createFromXMLfile( "xml_file/cube.xml"); |
854 | 51 sgroot->OnLightSysSwitch(); |
52 SceneGraphPtr light = sgroot->getLight(0); | |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1122
diff
changeset
|
53 sgroot->OnLightSwitch(0); |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1122
diff
changeset
|
54 light->xyz[0] = screen_w; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1122
diff
changeset
|
55 light->xyz[1] = screen_h; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1122
diff
changeset
|
56 light->xyz[2] = 100; |
539 | 57 |
1122 | 58 // SceneGraph ID から SceneGraph を生成する |
563
338ad9c856fc
all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
557
diff
changeset
|
59 earth = sgroot->createSceneGraph("Earth"); |
539 | 60 |
61 // SceneGraph の move と collision を設定 | |
768
06302c1dc87d
add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
761
diff
changeset
|
62 earth->set_move_collision(earth_move, earth_collision); |
761 | 63 earth->xyz[0] = screen_w / 2; |
64 earth->xyz[1] = screen_h / 2; | |
1122 | 65 earth->stack_xyz[0] = 3.0f; |
66 earth->stack_xyz[1] = 3.0f; | |
67 | |
563
338ad9c856fc
all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
557
diff
changeset
|
68 moon = sgroot->createSceneGraph("Moon"); |
539 | 69 moon->set_move_collision(moon_move, moon_collision); |
70 | |
71 // SceneGraph 同士の親子関係を設定 (今回は 親 earth、子 moon) | |
891 | 72 |
539 | 73 earth->addChild(moon); |
74 | |
75 // SceneGraphRoot に、使用する SceneGraph を設定する | |
1122 | 76 // このとき、ユーザーは SceneGraph の root を渡す。 |
539 | 77 sgroot->setSceneData(earth); |
557
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
78 return sgroot; |
539 | 79 } |
557
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 extern Application * |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
82 application() { |
563
338ad9c856fc
all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
557
diff
changeset
|
83 return new universe(); |
557
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
84 } |
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 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
|
87 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
88 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
|
89 extern void task_initialize(); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
90 static void TMend(TaskManager *manager); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
91 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
92 int |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
93 TMmain(TaskManager *manager, int argc, char *argv[]) |
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 task_initialize(); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
96 manager->set_TMend(TMend); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
97 return init(manager, argc, argv); |
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 } |
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 void |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
102 TMend(TaskManager *manager) |
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 printf("test_nogl end\n"); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
105 } |
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 /* end */ |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
108 |