annotate TaskManager/Test/test_render/task/update_sgp.cpp @ 264:a59868d37093

merge 151 263
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 03 Jun 2009 23:57:38 +0900
parents 3fd24be89d02 a802b19ab9ae
children 7f2b30acf311
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
1 #include <stdio.h>
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
2 #include <string.h>
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
3 #include <unistd.h>
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
4 #include <math.h>
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
5 #include "scene_graph_pack.h"
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
6 #include "sys.h"
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
7 #include "update_sgp.hpp"
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
8
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
9 SchedDefineTask(Update_SGP);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
10
264
a59868d37093 merge 151 263
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 138 122
diff changeset
11 <<<<<<< local
a59868d37093 merge 151 263
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 138 122
diff changeset
12 =======
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
13 typedef void (*moveFunc)(SceneGraphNodePtr, int, int);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
14 typedef void (*collFunc)(SceneGraphNodePtr, int, int);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
15
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
16 static moveFunc moveList[3];
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
17 static collFunc collList[3];
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
18
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
19 static void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
20 move0(SceneGraphNodePtr node, int w, int h)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
21 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
22 static float dest_x = 0.3f;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
23 static float dest_y = 0.5f;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
24
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
25 node->angle[1] += 1.0f;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
26 if (node->angle[1] > 360.0f) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
27 node->angle[1] = 0.0f;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
28 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
29
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
30 node->obj_pos[0] += dest_x;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
31 if ((int)node->obj_pos[0] > w || (int)node->obj_pos[0] < 0) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
32 dest_x = -dest_x;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
33 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
34
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
35 node->obj_pos[1] += dest_y;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
36 if ((int)node->obj_pos[1] > h || (int)node->obj_pos[1] < 0) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
37 dest_y = -dest_y;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
38 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
39 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
40
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
41 static void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
42 move1(SceneGraphNodePtr node, int w, int h)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
43 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
44 node->angle[1] += 1.0f;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
45 if (node->angle[1] > 360.0f) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
46 node->angle[1] = 0.0f;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
47 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
48
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
49 static float dest_x = 0.5f;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
50 static float dest_y = 1.3f;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
51
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
52 node->obj_pos[0] += dest_x;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
53 if ((int)node->obj_pos[0] > w || (int)node->obj_pos[0] < 0) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
54 dest_x = -dest_x;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
55 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
56
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
57 node->obj_pos[1] += dest_y;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
58 if ((int)node->obj_pos[1] > h || (int)node->obj_pos[1] < 0) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
59 dest_y = -dest_y;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
60 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
61 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
62
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
63 static void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
64 move2(SceneGraphNodePtr node, int w, int h)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
65 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
66 node->angle[1] += 1.0f;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
67 if (node->angle[1] > 360.0f) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
68 node->angle[1] = 0.0f;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
69 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
70
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
71 static float dest_x = 1.0f;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
72 static float dest_y = 0.8f;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
73
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
74 node->obj_pos[0] += dest_x;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
75 if ((int)node->obj_pos[0] > w || (int)node->obj_pos[0] < 0) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
76 dest_x = -dest_x;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
77 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
78
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
79 node->obj_pos[1] += dest_y;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
80 if ((int)node->obj_pos[1] > h || (int)node->obj_pos[1] < 0) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
81 dest_y = -dest_y;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
82 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
83 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
84
122
a802b19ab9ae add SceneGraph move
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 109
diff changeset
85 static void
a802b19ab9ae add SceneGraph move
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 109
diff changeset
86 move4(SceneGraphNodePtr node, int w, int h)
a802b19ab9ae add SceneGraph move
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 109
diff changeset
87 {
a802b19ab9ae add SceneGraph move
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 109
diff changeset
88 node->angle[1] += 1.0f;
a802b19ab9ae add SceneGraph move
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 109
diff changeset
89 if (node->angle[1] > 360.0f) {
a802b19ab9ae add SceneGraph move
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 109
diff changeset
90 node->angle[1] = 0.0f;
a802b19ab9ae add SceneGraph move
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 109
diff changeset
91 }
a802b19ab9ae add SceneGraph move
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 109
diff changeset
92 }
a802b19ab9ae add SceneGraph move
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 109
diff changeset
93
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
94
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
95 static void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
96 coll(SceneGraphNodePtr node, int w, int h)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
97 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
98 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
99
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
100 static void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
101 init(void)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
102 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
103 moveList[0] = move0;
122
a802b19ab9ae add SceneGraph move
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 109
diff changeset
104 moveList[1] = move4;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
105 moveList[2] = move2;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
106
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
107 collList[0] = coll;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
108 collList[1] = coll;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
109 collList[2] = coll;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
110 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
111
264
a59868d37093 merge 151 263
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 138 122
diff changeset
112 >>>>>>> other
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
113 int
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
114 Update_SGP::run(void *rbuf, void *wbuf)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
115 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
116 SceneGraphNodePtr node;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
117 SceneGraphPack *sgp = (SceneGraphPack*)get_input(rbuf, 0);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
118 SceneGraphPack *_sgp = (SceneGraphPack*)get_output(wbuf, 0);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
119 int screen_width = get_param(0);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
120 int screen_height = get_param(1);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
121
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
122 // 本当はここでやるもんじゃないんだが。。。
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
123 for (int i = 0; i < sgp->info.size && i < 3; i++) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
124 node = &sgp->node[i];
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
125
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
126 do {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
127 if (node->pn != -1) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
128 get_matrix(node->translation,
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
129 node->angle, node->obj_pos,
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
130 sgp->node[node->pn].translation);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
131 } else {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
132 get_matrix(node->translation,
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
133 node->angle, node->obj_pos,
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
134 NULL);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
135 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
136
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
137 node = node->next;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
138 } while (node);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
139 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
140
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
141 memcpy(_sgp, sgp, sizeof(SceneGraphPack));
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
142
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
143 return 0;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
144 }