view Renderer/Engine/polygon_pack.h @ 1998:ed30952c240e draft

change function read() to pread() in my_read
author masa
date Tue, 22 Apr 2014 00:58:37 +0900
parents 3778a1eda68d
children
line wrap: on
line source

#ifndef INCLUDED_POLYGON_PACK
#define INCLUDED_POLYGON_PACK

#include "types.h"

// #define MAX_SIZE_TRIANGLE 128
#define MAX_SIZE_TRIANGLE 64

#define POLYGONPACK_SEGMENT_NUM 2

typedef struct VertexPack {
    float x;
    float y;
    float z;
    float tex_x;
    float tex_y;
    float diffuse; // 拡散成分
} VertexPack, *VertexPackPtr; // 24

typedef struct NormalPack {
  float x;
  float y;
  float z;
} NormalPack, *NormalPackPtr; // 12  

typedef struct TriTexInfo {
    uint32 *addr;
    int width;
    int height;
    int scale_max;
} TriangleTexInfo, *TriangleTexInfoPtr; // 16


typedef struct TrianglePack {
    TriTexInfo  tex_info;   // 16
    VertexPack  ver1;       // 20
    VertexPack  ver2;       // 20
    VertexPack  ver3;       // 20
    NormalPack  normal1;    // 12
    NormalPack  normal2;    // 12
    NormalPack  normal3;    // 12
} TrianglePack, *TrianglePackPtr; 

/*
 * PolygonPackは3Dモデルの情報を格納し、CreatePolygonTask の input, output として扱われる
 * Task内で、各頂点にmatrixが乗算され、拡散成分が計算される
 * 冗長なところがあるから、どうにかならんものか。 NormalPack は CPTask
 * の output としてはいらないデータ。 Task の input と output で被っているデータとそうで
 * ないところがあるから、ひとつの構造体として送るのはどうかな
 * DS はそこらへんの、データの結合と分解をできればいいか 
 */

typedef struct PolygonPack {
    PolygonPack* next;
    struct POLYGON_info {
	int size;
        int span_num;
    }info;
    TrianglePack tri[MAX_SIZE_TRIANGLE];

    void init(void) {
	info.size = 0;
	info.span_num = 0;

	next = 0;
    }

    void clear(void) {
	PolygonPack *q = 0;
	PolygonPack *q1 = 0;
	
	q = this->next;
	while (q) {
	    q1 = q->next;
	    delete(q);
	    q = q1;
	}
	this->init();
    }
} PolygonPack, *PolygonPackPtr; // サイズは 14384 みたい。

typedef struct PolygonPackList {
    int size;
    PolygonPack *list;
} PolygonPackList;

#endif