annotate Renderer/Test/property_universe.cc @ 767:e4d635b1f018

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