view TaskManager/Test/simple_render/create_pp.cpp @ 33:1c7c3d73ffc7

*** empty log message ***
author gongo
date Tue, 12 Feb 2008 15:41:38 +0900
parents 3f68b2ef4fb0
children
line wrap: on
line source

#include <iostream>
#include "polygon_pack.h"
#include "scene_graph_pack.h"
#include "sys.h"
using namespace std;


int create_pp(PolygonPack *pp, SceneGraphPack *sgp)
{
  float xyz1[4],xyz2[4],xyz3[4];

  for (int i = 0; i < sgp->info.size; i++) {
    SceneGraphNodePtr node = &sgp->node[i];

    int n,nt,pt;
    for(n=0,nt=0,pt=0; n<node->size*3; n+=9,nt+=6,pt++) {
      xyz1[0] = node->vertex[n];
      xyz1[1] = node->vertex[n+1];
      xyz1[2] = node->vertex[n+2]*-1;
      xyz1[3] = 1;
      xyz2[0] = node->vertex[n+3];
      xyz2[1] = node->vertex[n+3+1];
      xyz2[2] = node->vertex[n+3+2]*-1;
      xyz2[3] = 1;
      xyz3[0] = node->vertex[n+6];
      xyz3[1] = node->vertex[n+6+1];
      xyz3[2] = node->vertex[n+6+2]*-1;
      xyz3[3] = 1;

      rotate(xyz1, node->translation);
      rotate(xyz2, node->translation);
      rotate(xyz3, node->translation);

      pp->tri[pt].x1 = xyz1[0];
      pp->tri[pt].y1 = xyz1[1];
      pp->tri[pt].z1 = xyz1[2];
      pp->tri[pt].tex_x1 = node->texture[nt];
      pp->tri[pt].tex_y1 = node->texture[nt+1];

      pp->tri[pt].x2 = xyz2[0];
      pp->tri[pt].y2 = xyz2[1];
      pp->tri[pt].z2 = xyz2[2];
      pp->tri[pt].tex_x2 = node->texture[nt+2];
      pp->tri[pt].tex_y2 = node->texture[nt+2+1];

      pp->tri[pt].x3 = xyz3[0];
      pp->tri[pt].y3 = xyz3[1];
      pp->tri[pt].z3 = xyz3[2];
      pp->tri[pt].tex_x3 = node->texture[nt+4];
      pp->tri[pt].tex_y3 = node->texture[nt+4+1];

    }
    pp->info.size = pt;
  }

  return sizeof(PolygonPack);
}