Mercurial > hg > Members > kono > Cerium
view TaskManager/Test/test_render/task/update_sgp.cpp @ 123:f515436feb71
delete scene_graph->child (instead use "children")
author | gongo@charles.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Tue, 25 Nov 2008 10:32:23 +0900 |
parents | 5c194c71eca8 |
children | 776eca0daa02 |
line wrap: on
line source
#include <stdio.h> #include <string.h> #include <unistd.h> #include <math.h> #include "scene_graph_pack.h" #include "sys.h" #include "update_sgp.hpp" SchedDefineTask(Update_SGP); typedef void (*moveFunc)(SceneGraphNodePtr, int, int); typedef void (*collFunc)(SceneGraphNodePtr, int, int); static moveFunc moveList[3]; static collFunc collList[3]; static void move0(SceneGraphNodePtr node, int w, int h) { static float dest_x = 0.3f; static float dest_y = 0.5f; node->angle[1] += 1.0f; if (node->angle[1] > 360.0f) { node->angle[1] = 0.0f; } node->obj_pos[0] += dest_x; if ((int)node->obj_pos[0] > w || (int)node->obj_pos[0] < 0) { dest_x = -dest_x; } node->obj_pos[1] += dest_y; if ((int)node->obj_pos[1] > h || (int)node->obj_pos[1] < 0) { dest_y = -dest_y; } } static void move3(SceneGraphNodePtr node, int w, int h) { node->angle[1] += 1.0f; if (node->angle[1] > 360.0f) { node->angle[1] = 0.0f; } } static void move1(SceneGraphNodePtr node, int w, int h) { node->angle[1] += 1.0f; if (node->angle[1] > 360.0f) { node->angle[1] = 0.0f; } static float dest_x = 0.5f; static float dest_y = 1.3f; node->obj_pos[0] += dest_x; if ((int)node->obj_pos[0] > w || (int)node->obj_pos[0] < 0) { dest_x = -dest_x; } node->obj_pos[1] += dest_y; if ((int)node->obj_pos[1] > h || (int)node->obj_pos[1] < 0) { dest_y = -dest_y; } } static void move2(SceneGraphNodePtr node, int w, int h) { node->angle[1] += 1.0f; if (node->angle[1] > 360.0f) { node->angle[1] = 0.0f; } static float dest_x = 1.0f; static float dest_y = 0.8f; node->obj_pos[0] += dest_x; if ((int)node->obj_pos[0] > w || (int)node->obj_pos[0] < 0) { dest_x = -dest_x; } node->obj_pos[1] += dest_y; if ((int)node->obj_pos[1] > h || (int)node->obj_pos[1] < 0) { dest_y = -dest_y; } } static void coll(SceneGraphNodePtr node, int w, int h) { } static void init(void) { moveList[0] = move0; moveList[1] = move3; moveList[2] = move2; collList[0] = coll; collList[1] = coll; collList[2] = coll; } int Update_SGP::run(void *rbuf, void *wbuf) { SceneGraphNodePtr node; SceneGraphPack *sgp = (SceneGraphPack*)get_input(rbuf, 0); SceneGraphPack *_sgp = (SceneGraphPack*)get_output(wbuf, 0); int screen_width = get_param(0); int screen_height = get_param(1); init(); // 本当はここでやるもんじゃないんだが。。。 for (int i = 0; i < sgp->info.size && i < 3; i++) { node = &sgp->node[i]; do { moveList[i](node, screen_width, screen_height); collList[i](node, screen_width, screen_height); if (node->pn != -1) { get_matrix(node->translation, node->angle, node->obj_pos, sgp->node[node->pn].translation); } else { get_matrix(node->translation, node->angle, node->obj_pos, NULL); } node = node->next; } while (node); } memcpy(_sgp, sgp, sizeof(SceneGraphPack)); return 0; }