annotate Renderer/Test/property_universe.cc @ 1767:1a68c05eeadf draft

minor fix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 23 Nov 2013 01:28:59 +0900
parents f40558ec00a8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
766
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
1 #include <math.h>
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
2 #include <stdlib.h>
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
3 #include "SceneGraphRoot.h"
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
4 #include "MainLoop.h"
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
5 #include "property_universe.h"
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
6 #include "types.h"
1070
yutaka@localhost.localdomain
parents: 768
diff changeset
7 #include "MyFunc.h"
yutaka@localhost.localdomain
parents: 768
diff changeset
8 #include "matrix_calc.h"
766
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
9 #include "SgChange.h"
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
10
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
11 static const int PROPERTY_LENGTH = 2;
766
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
12
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
13 Property *property, *update_property;
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
14
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
15 // prototype
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
16 static void collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree);
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
17 static void move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h);
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
18 static void createSceneGraphFromProperty(SchedTask *s, void *sgroot, void *arg1);
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
19 static void set_property(Property *p, SceneGraphPtr sg, int index);
766
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
20 static void apply_property(SceneGraphPtr sg, Property *p);
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
21 static void regist_task(SceneGraphRoot *sgroot);
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
22 static void set_relation(SceneGraphPtr parent, SceneGraphPtr child);
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
23
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
24 static void
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
25 move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
26 {
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
27 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
28 HTaskPtr property_task = sgroot->move_exec_task;
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
29
1412
f40558ec00a8 remove duplicated spe task code source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1393
diff changeset
30 property_task->set_inData(0,property, sizeof(Property)*PROPERTY_LENGTH);
f40558ec00a8 remove duplicated spe task code source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1393
diff changeset
31 property_task->set_outData(0,update_property, sizeof(Property)*PROPERTY_LENGTH);
766
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
32 property_task->set_cpu(SPE_ANY);
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
33 property_task->set_post(createSceneGraphFromProperty, (void *)sgroot, 0);
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
34 property_task->spawn();
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
35 }
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
36
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
37 static void
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
38 collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
39 SceneGraphPtr tree)
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
40 {
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
41 }
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
42
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
43 static void
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
44 createSceneGraphFromProperty(SchedTask *s, void *sgroot_, void *arg1)
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
45 {
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
46 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
47 SceneGraphPtr camera = sgroot->camera;
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
48 SceneGraphPtr p_node;
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
49
766
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
50 // ここが allExecute の tree をたどって clone して行くところに相当する
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
51 Property *p;
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
52
766
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
53 for (int i = 0; i < PROPERTY_LENGTH; i++) {
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
54 p = &update_property[i];
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
55 SceneGraphPtr node = sgroot->createSceneGraph(p->name);
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
56 if (strcmp(node->name, "Earth") == 0) {
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
57 node->set_move_collision(move, collision);
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
58 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
59 apply_property(node, p);
766
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
60 }
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
61
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
62 for (int j = 0; j < PROPERTY_LENGTH; j++) {
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
63 p = &update_property[j];
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
64 p_node = (SceneGraphPtr)p->node;
1115
e954ec5d9b96 warning fix.
tkaito
parents: 1109
diff changeset
65 //float scale[] = {1,1,1};
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
66 if (p->have_parent) {
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
67 SceneGraphPtr parent = (SceneGraphPtr)update_property[p->parent_index].node;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
68 parent->addChild(p_node);
1109
tkaito
parents: 1070
diff changeset
69 get_matrix(p_node->matrix, p_node->angle, p_node->xyz, parent->matrix);
766
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
70 } else {
1109
tkaito
parents: 1070
diff changeset
71 get_matrix(p_node->matrix, p_node->angle, p_node->xyz, camera->matrix);
766
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
72 }
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
73 }
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
74
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
75 sgroot->setSceneData((SceneGraphPtr)update_property[0].node);
766
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
76
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
77 Property *tmp = property;
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
78 property = update_property;
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
79 update_property = tmp;
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
80
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
81 sgroot->move_finish();
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
82 }
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
83
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
84 static void
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
85 apply_property(SceneGraphPtr node, Property *p)
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
86 {
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
87 for (int i = 0; i < 3; i++) {
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
88 node->xyz[i] = p->xyz[i];
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
89 node->angle[i] = p->angle[i];
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
90 node->stack_xyz[i] = p->stack_xyz[i];
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
91 }
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
92 p->node = (memaddr)node;
766
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
93 node->property = (memaddr)p;
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
94 }
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
95
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
96 /*
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
97 ここで必要な値をプロパティに格納
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
98 */
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
99 static void
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
100 set_property(Property *p, SceneGraphPtr node, int index)
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
101 {
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
102 for (int i = 0; i < 3; i++) {
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
103 p->xyz[i] = node->xyz[i];
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
104 p->angle[i] = node->angle[i];
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
105 p->stack_xyz[i] = node->stack_xyz[i];
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
106 }
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
107 p->parent = (memaddr)node->parent;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
108 p->children = (memaddr)node->children;
766
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
109 p->name = node->name;
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
110 p->property_index = index;
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
111
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
112 p->node = (memaddr)node;
766
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
113 node->property = (memaddr)p;
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
114 }
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
115
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
116 static void
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
117 regist_task(SceneGraphRoot *sgroot)
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
118 {
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
119 TaskManager *manager = sgroot->tmanager;
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
120 HTaskPtr task = manager->create_task(UniverseTask);
766
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
121 // sgroot->setExecTask(task); とやるべき?
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
122 sgroot->move_exec_task = task;
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
123 }
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
124
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
125 static void
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
126 set_relation(SceneGraphPtr parent, SceneGraphPtr child)
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
127 {
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
128 /*
766
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
129 child->property->parent_index = parent->property->property_index;
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
130 child->property->have_parent = 1;
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
131 */
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
132
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
133 Property *p = (Property *)parent->property;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
134 Property *c = (Property *)child->property;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
135 c->parent_index = p->property_index;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
136 c->have_parent = 1;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
137
766
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
138 }
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
139
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
140 MainLoopPtr
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
141 property_universe::init(Viewer *viewer, int screen_w, int screen_h)
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
142 {
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
143 // SgChange を使うための2行
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
144 SgChange *sgroot = new SgChange(viewer);
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
145 sgroot->run_init();
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
146 // 上で書いた regist_task() を登録
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
147 // sgroot->appTaskRegist(regist_task); がいいかな
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
148 sgroot->sgroot_A->appTaskRegist(regist_task);
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
149
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
150 int root_obj_index = 0;
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
151 property = (Property *)sgroot->manager->allocate(sizeof(Property)*PROPERTY_LENGTH);
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
152 update_property = (Property *)sgroot->manager->allocate(sizeof(Property)*PROPERTY_LENGTH);
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
153
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
154 SceneGraphPtr earth;
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
155 sgroot->createFromXMLfile("xml_file/universe.xml");
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
156 earth = sgroot->createSceneGraph("Earth");
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
157 earth->set_move_collision(move, collision);
766
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
158 earth->xyz[0] = screen_w / 2;
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
159 earth->xyz[1] = screen_h / 2;
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
160
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
161 SceneGraphPtr moon;
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
162 moon = sgroot->createSceneGraph("Moon");
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
163
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
164 earth->addChild(moon);
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
165
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
166 set_property(&property[root_obj_index], earth, 0);
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
167 set_property(&property[1], moon, 1);
766
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
168 set_relation(earth, moon);
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
169
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
170 sgroot->setSceneData(earth);
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
171
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
172 return sgroot;
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
173 }
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
174
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
175 extern Application *
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
176 application() {
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 766
diff changeset
177 return new property_universe();
766
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
178 }
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
179
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
180 const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n";
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
181
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
182 extern int init(TaskManager *manager, int argc, char *argv[]);
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
183 extern void task_initialize();
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
184 static void TMend(TaskManager *manager);
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
185
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
186 int
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
187 TMmain(TaskManager *manager, int argc, char *argv[])
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
188 {
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
189 task_initialize();
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
190 manager->set_TMend(TMend);
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
191 return init(manager, argc, argv);
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
192
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
193 }
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
194
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
195 void
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
196 TMend(TaskManager *manager)
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
197 {
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
198 printf("test_nogl end\n");
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
199 }
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
200
3541fe06be2b add spe/univers_move
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
201 /* end */