diff TaskManager/Test/simple_pack/task/create_sgp.cpp @ 53:0c8ae614d421

Initial revision
author chiaki
date Fri, 15 Feb 2008 20:58:50 +0900
parents
children 35a6cf176c38
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/Test/simple_pack/task/create_sgp.cpp	Fri Feb 15 20:58:50 2008 +0900
@@ -0,0 +1,84 @@
+#include <iostream>
+#include "scene_graph_pack.h"
+#include "polygon.h"
+using namespace std;
+
+int create_sgp(Polygon *sg, SceneGraphPack *sgp)
+{
+    int i = 0;
+    int nnpn = -1;
+    SceneGraphNodePtr node;
+
+    Polygon *t;
+    t = sg;
+
+    while(t)
+    {
+	node = &sgp->node[i];
+
+	node->size = t->size;
+	int d,tex;
+	for(d=0,tex=0; d<t->size*3; d+=3,tex+=2)
+	{
+	    node->vertex[d] = t->data[d];
+	    node->vertex[d+1] = t->data[d+1];
+	    node->vertex[d+2] = t->data[d+2];
+	    node->texture[tex] = t->data[d+t->size*6];
+	    node->texture[tex+1] = t->data[d+t->size*6+1];
+	}
+
+	node->obj_pos[0] = 0;
+	node->obj_pos[1] = 0;
+	node->obj_pos[2] = 0;
+	node->obj_pos[3] = 1;
+	node->angle[0] = 0;
+	node->angle[1] = 0;
+	node->angle[2] = 0;
+	node->angle[3] = 1;
+
+	for(int tm=0; tm<16; tm++)
+        {
+	    node->translation[tm] = 0;
+        }
+	node->id = 0;
+	node->move = 0;
+	node->interaction = 0;
+	node->pn = nnpn;
+
+	if(t->child != NULL)
+	{
+	    nnpn = i;
+	    t = t->child;
+	}
+	else if(t->brother != NULL)
+	{
+	    nnpn = node->pn;
+	    t = t->brother;
+	}
+	else
+	{
+	    while(t)
+	    {
+		if(t->brother != NULL)
+		{
+		    t = t->brother;
+		    break;
+		}
+		else
+		{
+		    if(t->parent == NULL)
+		    {
+			t = NULL;
+			break;
+		    }
+		    nnpn = sgp->node[nnpn].pn;
+		    t = t->parent;
+		}
+	    }
+	}
+	i++;
+    }
+    sgp->info.size = i;
+
+    return sizeof(SceneGraphPack);
+}