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