annotate Renderer/Test/property_chain.cc @ 1798:3babb36ac459 draft

array(bmskip table) allocate size change 256 to 256*sizeof(int)
author Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
date Thu, 05 Dec 2013 16:41:38 +0900
parents f40558ec00a8
children
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
1412
f40558ec00a8 remove duplicated spe task code source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1393
diff changeset
71 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
72 property_task->set_outData(0,update_property, sizeof(Property)*PROPERTY_LENGTH);
768
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);
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
109 } else {
1109
tkaito
parents: 1070
diff changeset
110 get_matrix(p_node->matrix, p_node->angle, p_node->xyz, camera->matrix);
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
111 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
112 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
113
771
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
114 root = (SceneGraphPtr)update_property[0].node;
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
115 root->set_move_collision(move, collision);
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
116 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
117
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
118 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
119 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
120 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
121
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
122 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
123 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
124
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
125 static void
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
126 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
127 {
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
128 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
129 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
130 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
131 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
132 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
133 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
134 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
135 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
136
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 static void
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
141 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
142 {
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
143 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
144 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
145 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
146 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
147 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
148 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
149 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
150 p->property_index = index;
771
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
151 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
152 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
153 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
154 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
155
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
156 static void
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
157 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
158 {
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
159 TaskManager *manager = sgroot->tmanager;
771
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
160 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
161 // 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
162 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
163 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
164
771
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
165 /*
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
166 Property に親子関係を書き込む
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
167 これも API に入れちゃっていいかな
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
168 */
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
169 static void
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
170 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
171 {
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
172 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
173 Property *c = (Property *)child->property;
770
0038b94e1fa6 fix Test/property_chain
hiroki
parents: 769
diff changeset
174 p->children = (memaddr)child;
0038b94e1fa6 fix Test/property_chain
hiroki
parents: 769
diff changeset
175 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
176 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
177 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
178 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
179
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
180 MainLoopPtr
771
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
181 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
182 {
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
183 // SgChange を使うための2行
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
184 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
185 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
186 // 上で書いた regist_task() を登録
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
187 // 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
188 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
189
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
190 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
191 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
192
769
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
193 // property の初期化 application ごとに固有
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
194 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
195 init_chain(&property[i]);
769
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
196 }
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
197
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
198 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
199 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
200 root_chain = sgroot->createSceneGraph("CHAIN");
772
06cabc57afcf add chain_move.h
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 771
diff changeset
201 //root_chain->xyz[0] = screen_w / 2;
06cabc57afcf add chain_move.h
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 771
diff changeset
202 //root_chain->xyz[0] = screen_w / 4;
06cabc57afcf add chain_move.h
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 771
diff changeset
203 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
204 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
205 root_chain->set_move_collision(move, collision);
770
0038b94e1fa6 fix Test/property_chain
hiroki
parents: 769
diff changeset
206 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
207
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
208 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
209 chain = sgroot->createSceneGraph("CHAIN");
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
210 chain->xyz[0] = 0;
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
211 chain->xyz[1] = chain_width * i;
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
212 chain->angle[1] = -90 * (i % 2);
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
213 root_chain->addChild(chain);
770
0038b94e1fa6 fix Test/property_chain
hiroki
parents: 769
diff changeset
214 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
215 set_relation(root_chain, chain);
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
216 }
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
217
770
0038b94e1fa6 fix Test/property_chain
hiroki
parents: 769
diff changeset
218 // root の set_property は SceneGraph を作成してから実行
0038b94e1fa6 fix Test/property_chain
hiroki
parents: 769
diff changeset
219 // addChild したら set_relation しないとだめ、あんまりにもあんまり
769
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
220
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
221 /*
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
222 apply_property は post_func の createSceneGraphFromProperty 中で使う
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
223 apply_property は sgroot に持たせてもいいと思います○
55961847652c property_chain is under construction
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 768
diff changeset
224 */
768
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
225
770
0038b94e1fa6 fix Test/property_chain
hiroki
parents: 769
diff changeset
226 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
227
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
228 return sgroot;
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
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
231 extern Application *
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
232 application() {
771
0ad733bd134a Test/property_chain is work
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 770
diff changeset
233 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
234 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
235
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
236 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
237
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
238 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
239 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
240 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
241
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
242 int
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
243 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
244 {
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
245 task_initialize();
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
246 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
247 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
248
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
249 }
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 void
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
252 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
253 {
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
254 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
255 }
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
256
06302c1dc87d add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
257 /* end */