annotate Renderer/Test/property_chain.cc @ 1115:e954ec5d9b96 draft

warning fix.
author tkaito
date Tue, 18 Jan 2011 20:09:17 +0900
parents d2cb74984336
children 80e96b616196
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
1 #include <math.h>
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
2 #include <stdlib.h>
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
3 #include "SceneGraphRoot.h"
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
4 #include "MainLoop.h"
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
5 #include "property_chain.h"
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
6 #include "types.h"
1070
yutaka@localhost.localdomain
parents: 772
diff changeset
7 #include "MyFunc.h"
yutaka@localhost.localdomain
parents: 772
diff changeset
8 #include "matrix_calc.h"
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
9 #include "SgChange.h"
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
10
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
11 #define FALSE 0
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
12 #define TRUE !FALSE
771
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
13 static const int PROPERTY_LENGTH = 50;
769
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
14 static double chain_width = 10;
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
15
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
16 typedef struct {
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
17 float xyz[3];
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
18 float angle[3];
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
19 float stack_xyz[3];
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
20 float next_xyz[3];
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
21 float v_xyz[3];
771
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
22 float next_v_xyz[3];
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
23 int property_index;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
24 int parent_index;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
25 int have_parent;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
26 int can_move;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
27 memaddr parent;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
28 memaddr children;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
29 memaddr node;
771
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
30 int sgid;
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
31 } *PropertyPtr, Property;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
32
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
33
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
34 Property *property, *update_property;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
35
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
36 // prototype
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
37 static void collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree);
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
38 static void move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h);
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
39 static void createSceneGraphFromProperty(SchedTask *s, void *sgroot, void *arg1);
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
40 static void set_property(Property *p, SceneGraphPtr sg, int index);
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
41 static void apply_property(SceneGraphPtr sg, Property *p);
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
42 static void regist_task(SceneGraphRoot *sgroot);
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
43 static void set_relation(SceneGraphPtr parent, SceneGraphPtr child);
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
44
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
45 static void
770
0038b94e1fa6 fix Test/property_chain
hiroki
parents: 769
diff changeset
46 init_chain(Property *p) {
769
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
47 for (int i = 0; i < 3; i++) {
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
48 p->xyz[i] = 0;
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
49 p->angle[i] = 0;
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
50 p->stack_xyz[i] = 0;
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
51 p->next_xyz[i] = 0;
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
52 p->v_xyz[i] = 0;
771
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
53 p->next_v_xyz[i] = 0;
769
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
54 }
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
55
770
0038b94e1fa6 fix Test/property_chain
hiroki
parents: 769
diff changeset
56 p->property_index = 0;
769
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
57 p->parent_index = 0;
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
58 p->have_parent = 0;
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
59 p->can_move = TRUE;
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
60 p->parent = NULL;
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
61 p->children = NULL;
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
62 p->node = NULL;
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
63 }
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
64
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
65 static void
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
66 move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
67 {
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
68 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
69 HTaskPtr property_task = sgroot->move_exec_task;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
70
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
71 property_task->add_inData(property, sizeof(Property)*PROPERTY_LENGTH);
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
72 property_task->add_outData(update_property, sizeof(Property)*PROPERTY_LENGTH);
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
73 property_task->set_cpu(SPE_ANY);
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
74 property_task->set_post(createSceneGraphFromProperty, (void *)sgroot, 0);
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
75 property_task->spawn();
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
76 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
77
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
78 static void
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
79 collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
80 SceneGraphPtr tree)
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
81 {
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
82 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
83
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
84 static void
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
85 createSceneGraphFromProperty(SchedTask *s, void *sgroot_, void *arg1)
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
86 {
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
87 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
88 SceneGraphPtr camera = sgroot->camera;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
89 SceneGraphPtr p_node;
771
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
90 SceneGraphPtr root;
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
91
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
92 // ここが allExecute の tree をたどって clone して行くところに相当する
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
93 Property *p;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
94
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
95 for (int i = 0; i < PROPERTY_LENGTH; i++) {
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
96 p = &update_property[i];
771
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
97 SceneGraphPtr node = sgroot->createSceneGraph(p->sgid);
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
98 apply_property(node, p);
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
99 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
100
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
101 for (int j = 0; j < PROPERTY_LENGTH; j++) {
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
102 p = &update_property[j];
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
103 p_node = (SceneGraphPtr)p->node;
1115
e954ec5d9b96 warning fix.
tkaito
parents: 1109
diff changeset
104 //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:
diff changeset
105 if (p->have_parent) {
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
106 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:
diff changeset
107 parent->addChild(p_node);
1109
tkaito
parents: 1070
diff changeset
108 get_matrix(p_node->matrix, p_node->angle, p_node->xyz, parent->matrix);
tkaito
parents: 1070
diff changeset
109 get_matrix(p_node->real_matrix, p_node->angle, p_node->xyz, parent->real_matrix);
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
110 } else {
1109
tkaito
parents: 1070
diff changeset
111 get_matrix(p_node->matrix, p_node->angle, p_node->xyz, camera->matrix);
tkaito
parents: 1070
diff changeset
112 get_matrix(p_node->real_matrix, p_node->angle, p_node->xyz, camera->real_matrix);
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
113 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
114 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
115
771
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
116 root = (SceneGraphPtr)update_property[0].node;
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
117 root->set_move_collision(move, collision);
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
118 sgroot->setSceneData(root);
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
119
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
120 Property *tmp = property;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
121 property = update_property;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
122 update_property = tmp;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
123
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
124 sgroot->move_finish();
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
125 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
126
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
127 static void
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
128 apply_property(SceneGraphPtr node, Property *p)
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
129 {
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
130 for (int i = 0; i < 3; i++) {
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
131 node->xyz[i] = p->xyz[i];
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
132 node->angle[i] = p->angle[i];
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
133 node->stack_xyz[i] = p->stack_xyz[i];
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
134 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
135 p->node = (memaddr)node;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
136 node->property = (memaddr)p;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
137 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
138
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
139 /*
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
140 ここで必要な値をプロパティに格納
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
141 */
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
142 static void
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
143 set_property(Property *p, SceneGraphPtr node, int index)
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
144 {
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
145 for (int i = 0; i < 3; i++) {
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
146 p->xyz[i] = node->xyz[i];
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
147 p->angle[i] = node->angle[i];
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
148 p->stack_xyz[i] = node->stack_xyz[i];
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
149 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
150 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:
diff changeset
151 p->children = (memaddr)node->children;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
152 p->property_index = index;
771
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
153 p->sgid = node->sgid;
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
154 p->node = (memaddr)node;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
155 node->property = (memaddr)p;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
156 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
157
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
158 static void
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
159 regist_task(SceneGraphRoot *sgroot)
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
160 {
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
161 TaskManager *manager = sgroot->tmanager;
771
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
162 HTaskPtr task = manager->create_task(ChainTask);
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
163 // sgroot->setExecTask(task); とやるべき?
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
164 sgroot->move_exec_task = task;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
165 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
166
771
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
167 /*
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
168 Property に親子関係を書き込む
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
169 これも API に入れちゃっていいかな
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
170 */
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
171 static void
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
172 set_relation(SceneGraphPtr parent, SceneGraphPtr child)
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
173 {
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
174 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:
diff changeset
175 Property *c = (Property *)child->property;
770
0038b94e1fa6 fix Test/property_chain
hiroki
parents: 769
diff changeset
176 p->children = (memaddr)child;
0038b94e1fa6 fix Test/property_chain
hiroki
parents: 769
diff changeset
177 c->parent = (memaddr)parent;
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
178 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:
diff changeset
179 c->have_parent = 1;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
180 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
181
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
182 MainLoopPtr
771
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
183 property_chain::init(Viewer *viewer, int screen_w, int screen_h)
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
184 {
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
185 // SgChange を使うための2行
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
186 SgChange *sgroot = new SgChange(viewer);
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
187 sgroot->run_init();
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
188 // 上で書いた regist_task() を登録
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
189 // sgroot->appTaskRegist(regist_task); がいいかな
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
190 sgroot->sgroot_A->appTaskRegist(regist_task);
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
191
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
192 property = (Property *)sgroot->manager->allocate(sizeof(Property)*PROPERTY_LENGTH);
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
193 update_property = (Property *)sgroot->manager->allocate(sizeof(Property)*PROPERTY_LENGTH);
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
194
769
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
195 // property の初期化 application ごとに固有
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
196 for(int i = 0; i < PROPERTY_LENGTH; i++) {
771
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
197 init_chain(&property[i]);
769
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
198 }
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
199
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
200 SceneGraphPtr root_chain, chain;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
201 sgroot->createFromXMLfile("xml_file/chain.xml");
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
202 root_chain = sgroot->createSceneGraph("CHAIN");
772
06cabc57afcf add chain_move.h
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 771
diff changeset
203 //root_chain->xyz[0] = screen_w / 2;
06cabc57afcf add chain_move.h
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 771
diff changeset
204 //root_chain->xyz[0] = screen_w / 4;
06cabc57afcf add chain_move.h
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 771
diff changeset
205 root_chain->xyz[0] = 300.0f;
769
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
206 root_chain->xyz[1] = 0.0f;
771
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
207 root_chain->set_move_collision(move, collision);
770
0038b94e1fa6 fix Test/property_chain
hiroki
parents: 769
diff changeset
208 set_property(&property[0], root_chain, 0);
769
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
209
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
210 for (int i = 1; i < PROPERTY_LENGTH; i++) {
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
211 chain = sgroot->createSceneGraph("CHAIN");
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
212 chain->xyz[0] = 0;
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
213 chain->xyz[1] = chain_width * i;
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
214 chain->angle[1] = -90 * (i % 2);
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
215 root_chain->addChild(chain);
770
0038b94e1fa6 fix Test/property_chain
hiroki
parents: 769
diff changeset
216 set_property(&property[i], chain, i);
769
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
217 set_relation(root_chain, chain);
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
218 }
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
219
770
0038b94e1fa6 fix Test/property_chain
hiroki
parents: 769
diff changeset
220 // root の set_property は SceneGraph を作成してから実行
0038b94e1fa6 fix Test/property_chain
hiroki
parents: 769
diff changeset
221 // addChild したら set_relation しないとだめ、あんまりにもあんまり
769
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
222
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
223 /*
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
224 apply_property は post_func の createSceneGraphFromProperty 中で使う
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
225 apply_property は sgroot に持たせてもいいと思います○
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
226 */
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
227
770
0038b94e1fa6 fix Test/property_chain
hiroki
parents: 769
diff changeset
228 sgroot->setSceneData(root_chain);
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
229
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
230 return sgroot;
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
231 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
232
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
233 extern Application *
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
234 application() {
771
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
235 return new property_chain();
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
236 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
237
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
238 const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n";
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
239
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
240 extern int init(TaskManager *manager, int argc, char *argv[]);
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
241 extern void task_initialize();
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
242 static void TMend(TaskManager *manager);
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
243
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
244 int
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
245 TMmain(TaskManager *manager, int argc, char *argv[])
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
246 {
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
247 task_initialize();
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
248 manager->set_TMend(TMend);
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
249 return init(manager, argc, argv);
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
250
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
251 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
252
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
253 void
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
254 TMend(TaskManager *manager)
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
255 {
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
256 printf("test_nogl end\n");
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
257 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
258
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
259 /* end */