annotate Renderer/Test/universe.cc @ 1351:e51127dbd63c draft

operate directly on matrix. not work yet.
author Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
date Sun, 15 Jan 2012 23:21:39 +0900
parents 90efd2aac2cb
children 57c3b08b76b5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include <stdlib.h>
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 SceneGraphPtr tree)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 SceneGraphPtr tree)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 {
1351
e51127dbd63c operate directly on matrix. not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1292
diff changeset
20 //node->stack_angle[0] += 3.0f;
e51127dbd63c operate directly on matrix. not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1292
diff changeset
21 node->angleIt(3, 0, 0);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 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
26 earth_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 {
1351
e51127dbd63c operate directly on matrix. not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1292
diff changeset
28 //node->angle[1] += 1.0f;
e51127dbd63c operate directly on matrix. not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1292
diff changeset
29 //node->angleIt(1, 0, 0);
e51127dbd63c operate directly on matrix. not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1292
diff changeset
30 //if (node->angle[1] > 360.0f) {
e51127dbd63c operate directly on matrix. not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1292
diff changeset
31 //node->angle[1] = 0.0f;
e51127dbd63c operate directly on matrix. not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1292
diff changeset
32 //}
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33
1351
e51127dbd63c operate directly on matrix. not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1292
diff changeset
34 //node->xyz[0] += node->stack_xyz[0];
e51127dbd63c operate directly on matrix. not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1292
diff changeset
35 //node->translateX(node->stack_xyz[0]);
e51127dbd63c operate directly on matrix. not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1292
diff changeset
36 if ((int)node->matrix[12] > screen_w || (int)node->matrix[12] < 0) {
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 node->stack_xyz[0] = -node->stack_xyz[0];
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39
1351
e51127dbd63c operate directly on matrix. not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1292
diff changeset
40 //node->xyz[1] += node->stack_xyz[1];
e51127dbd63c operate directly on matrix. not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1292
diff changeset
41 //node->translateY(node->stack_xyz[1]);
e51127dbd63c operate directly on matrix. not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1292
diff changeset
42 if ((int)node->matrix[13] > screen_h || (int)node->matrix[13] < 0) {
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 node->stack_xyz[1] = -node->stack_xyz[1];
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46
557
764772be1e3c fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 540
diff changeset
47 MainLoopPtr
764772be1e3c fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 540
diff changeset
48 universe::init(Viewer *sgroot, int screen_w, int screen_h)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 SceneGraphPtr earth;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 SceneGraphPtr moon;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52
563
338ad9c856fc all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 557
diff changeset
53 sgroot->createFromXMLfile( "xml_file/universe.xml");
855
641451e6a95b light fix--
Yutaka_Kinjyo
parents: 854
diff changeset
54 sgroot->createFromXMLfile( "xml_file/cube.xml");
854
293fcceaac36 may be need ppeManager
yutaka@localhost.localdomain
parents: 768
diff changeset
55 sgroot->OnLightSysSwitch();
293fcceaac36 may be need ppeManager
yutaka@localhost.localdomain
parents: 768
diff changeset
56 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
57 sgroot->OnLightSwitch(0);
1351
e51127dbd63c operate directly on matrix. not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1292
diff changeset
58 //light->xyz[0] = screen_w;
e51127dbd63c operate directly on matrix. not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1292
diff changeset
59 //light->xyz[1] = screen_h;
e51127dbd63c operate directly on matrix. not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1292
diff changeset
60 //light->xyz[2] = 100;
e51127dbd63c operate directly on matrix. not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1292
diff changeset
61 light->translateX(screen_w);
e51127dbd63c operate directly on matrix. not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1292
diff changeset
62 light->translateY(screen_h);
e51127dbd63c operate directly on matrix. not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1292
diff changeset
63 light->translateZ(100);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64
1122
ec6b55aed337 CreateSpan ver 1118. (can work Mac)
tkaito
parents: 891
diff changeset
65 // SceneGraph ID から SceneGraph を生成する
563
338ad9c856fc all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 557
diff changeset
66 earth = sgroot->createSceneGraph("Earth");
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 // 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
69 earth->set_move_collision(earth_move, earth_collision);
1351
e51127dbd63c operate directly on matrix. not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1292
diff changeset
70 //earth->xyz[0] = screen_w / 2;
e51127dbd63c operate directly on matrix. not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1292
diff changeset
71 earth->translateX(screen_w / 2);
e51127dbd63c operate directly on matrix. not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1292
diff changeset
72 //earth->xyz[1] = screen_h / 2;
e51127dbd63c operate directly on matrix. not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1292
diff changeset
73 earth->translateY(screen_h / 2);
1122
ec6b55aed337 CreateSpan ver 1118. (can work Mac)
tkaito
parents: 891
diff changeset
74 earth->stack_xyz[0] = 3.0f;
ec6b55aed337 CreateSpan ver 1118. (can work Mac)
tkaito
parents: 891
diff changeset
75 earth->stack_xyz[1] = 3.0f;
ec6b55aed337 CreateSpan ver 1118. (can work Mac)
tkaito
parents: 891
diff changeset
76
563
338ad9c856fc all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 557
diff changeset
77 moon = sgroot->createSceneGraph("Moon");
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 moon->set_move_collision(moon_move, moon_collision);
1351
e51127dbd63c operate directly on matrix. not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1292
diff changeset
79
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 // SceneGraph 同士の親子関係を設定 (今回は 親 earth、子 moon)
891
Yutaka_Kinjyo
parents: 855
diff changeset
81
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 earth->addChild(moon);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
83
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 // SceneGraphRoot に、使用する SceneGraph を設定する
1122
ec6b55aed337 CreateSpan ver 1118. (can work Mac)
tkaito
parents: 891
diff changeset
85 // このとき、ユーザーは SceneGraph の root を渡す。
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 sgroot->setSceneData(earth);
557
764772be1e3c fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 540
diff changeset
87 return sgroot;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 }
557
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 extern Application *
764772be1e3c fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 540
diff changeset
91 application() {
563
338ad9c856fc all exmple on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 557
diff changeset
92 return new universe();
557
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 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
96
764772be1e3c fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 540
diff changeset
97 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
98 extern void task_initialize();
764772be1e3c fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 540
diff changeset
99 static void TMend(TaskManager *manager);
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 int
764772be1e3c fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 540
diff changeset
102 TMmain(TaskManager *manager, int argc, char *argv[])
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 task_initialize();
764772be1e3c fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 540
diff changeset
105 manager->set_TMend(TMend);
764772be1e3c fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 540
diff changeset
106 return init(manager, argc, argv);
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 }
764772be1e3c fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 540
diff changeset
109
764772be1e3c fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 540
diff changeset
110 void
764772be1e3c fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 540
diff changeset
111 TMend(TaskManager *manager)
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 printf("test_nogl end\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
764772be1e3c fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 540
diff changeset
116 /* end */
764772be1e3c fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 540
diff changeset
117