view old/simple_pack/trash/scene_graph_to_polygon_pack.cpp @ 507:735f76483bb2

Reorganization..
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 12 Oct 2009 09:39:35 +0900
parents TaskManager/Test/simple_pack/trash/scene_graph_to_polygon_pack.cpp@0c8ae614d421
children
line wrap: on
line source

typedef struct Triangle {
  long  tex_addr, tex_width, tex_height;
  float x1, y1, z1, tex_x1, tex_y1;
  float x2, y2, z2, tex_x2, tex_y2;
  float x3, y3, z3, tex_x3, tex_y3;
}  TRIANGLEPACK, *TRIANGLEPACK_PTR;


typedef struct PolygonPack {
  PORIGON_INFO info {
                int size
                light_pos[3]
                light_rgb[3]
		  };
  TrianglePack tri[1];    // Variable length array
} POLYGONPACK, POLYGONPACK_PTR;


class SceneGraph2PolygonPack : SpeTask {

    SceneGraph2PolygonPack() {
	rbuf = _rbuf;
	wbuf = _wbuf;
    }

  int
  SceneGraph2PlygonPack::run() {
    SceneGraphPack *sgp = (SceneGraphPack*)rbuf;
    PolygonPack *pp = (PolygonPack*)wbuf;;
    for (int i = 0; i < sgp->size; i++) {
      SceneGraphNode *node = sgp->node[i];

      int n,tex;
      for(n=0,tex=0; n<node->size*3; n+=9,tex+=6) {
	pp->tri[].x1 = node.vertex[n];
	pp->tri[].y1 = node.vertex[n+1];
	pp->tri[].z1 = node.vertex[n+2];
	pp->tri[].tex_x1 = node.texture[tex];
	pp->tri[].tex_y1 = node.texture[tex+1];
	
	pp->tri[].x2 = node.vertex[n+3];
	pp->tri[].y2 = node.vertex[n+3+1];
	pp->tri[].z2 = node.vertex[n+3+2];
	pp->tri[].tex_x2 = node.texture[tex+2];
	pp->tri[].tex_y2 = node.texture[tex+2+1];
	
	pp->tri[].x3 = node.vertex[n+6];
	pp->tri[].y3 = node.vertex[n+6+1];
	pp->tri[].z3 = node.vertex[n+6+2];
	pp->tri[].tex_x3 = node.texture[tex+4];
	pp->tri[].tex_y3 = node.texture[tex+4+1];
      }

      copy(pp, wbuf, pp->size());
    }
  }
  
};