91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 4.42MB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2023-09-28
  • 語言: 其他
  • 標簽: Z_buffer??

資源簡介

用visual studio環境可以運行,實現Z_buffer掃描線消隱算法。源碼中有主要的步驟注釋說明。用到了OpenGL的函數、庫文件、頭文件和glut庫

資源截圖

代碼片段和文件信息

//?Auth:?zousong@cad.zju.edu.cn
//?Date:?2008-12-25

//?定義是否每個面片使用隨機顏色值
#define?RANDOM_COLOR?1

#include?
#include?
#include?
#include?
#include?
#include?
#ifdef?RANDOM_COLOR
#include?
#include?
#endif

using?namespace?std;

#define?MAX_WIDTH?(1024*2)
#define?MAX_HEIGHT?(768*2)

//定義圖像
#define INIT_WIDTH?1024
#define INIT_HEIGHT?768
GLubyte?image[INIT_HEIGHT][INIT_WIDTH][3];
//?定義顏色結構體
typedef?struct??
{
unsigned?char?r?b?g?a;
}?color_t;

//?定義點結構
typedef?struct??
{
double?x?y?z;
}?point_t;

//?定義分類邊表
typedef?struct?_line_t?
{
int?x; //?邊的上端點的x坐標
double?dx; //?相鄰兩條掃描線交點的x坐標差dx(-1/k)
int?dy; //?邊跨越的掃描線數目
int?id; //?邊所屬多邊形的編號
//_line_t?*?next; //?下個分類邊表指針?由于本算法中分類邊表存于STL?Vector中?故不需要
}?line_t;

//?定義活化邊表
typedef?struct?_active_line_t?
{
double?xl; //?左交點的x坐標
double?dxl; //?(左交點邊上)兩相鄰掃描線交點的x坐標之差
int?dyl; //?以和左交點所在邊相交的掃描線數為初值?以后向下每處理一條掃描線減1
double?zl; //?左交點處多邊形所在平面的深度值
double?dzx; //?沿掃描線向右走過一個像素時?多邊形所在平面的深度增量.?多于平面方程?dzx?=?-a/c?(c!=?0)
double?dzy; //?沿y方向向下移過一根掃描線時?多邊形所在平面的深度增量.?對于平面方程?dzy?=?b/c?(c!=?0)

#if?0??//?由于邊對分拆在兩個活化邊表結構中,故右節點的元素可以省略
// double?xr; //?右交點的x坐標
// double?dxr; //?(右交點邊上)兩相鄰掃描線交點的x坐標之差
// int?dyr; //?以右交點所在邊相交的掃描線數為初值?以后向下每處理一條掃描線減1
#endif
// int id; //?交點所在多邊形的編號?由于將活化邊表存于各自所屬的活化多邊形中?故所屬ID不需要保存
//_active_line_t?*?next; //?下個活化邊表指針?由于本算法中活化邊表存于STL?Vector中?故不需要
}?active_line_t;

//?定義分類多邊形表?||??活化多邊形表
typedef?struct??_poly_t
{
int?id; //?多邊形編號
double?abcd; //?多邊形所在的平面的方程系數?ax?+?by?+?cz?+?d?=?0
int?dy; //?多邊形跨越的掃描線數目?||?多邊形跨越的剩余掃描線數目
color_t?color; //?多邊形顏色
vector??ale;??//?活化邊表?放在活化多邊形中?對于分類多邊形表無意義
//_poly_t?*?next; //?下個分類多邊形指針?||?下個活化多邊形指針?由于本算法中多邊形表存于STL?Vector中?故不需要
}?poly_t;


inline?bool?is_zero(double?f)
{
if?(abs(f)? return?true;
return?false;
}

inline?int?double_to_int(double?f)
{
return?(int)(f+0.5);
}

//?對活化多邊形表排序的比較函數?
bool?cmp(const?active_line_t?&lhs?const?active_line_t?&rhs)
{
if?(double_to_int(lhs.xl)? return?true;
}?else?if?(?double_to_int(lhs.xl)?==?double_to_int(rhs.xl)??){
if?(double_to_int(lhs.dxl)? return?true;
}
return?false;
}


//?從obj文件中讀取的點
vector? point;
//?分類多形型表
vector? poly[MAX_HEIGHT];
//?分類邊表
vector? line[MAX_HEIGHT];
//?活化多邊形表?內部包含各個活化多邊形表中的活化邊表對
vector??ape;


//?z值數組
double z[MAX_WIDTH];
//?顏色數組
color_t color[MAX_WIDTH];
//?處理字符串用的buffer
char buf[1024];

int?cal(const?char?*?file_name?int?max_width?int?max_height?double?scale)
{
//?判斷參數是否合法
if?(file_name?==?NULL?||?max_width?<=?0?||?max_width?>?MAX_WIDTH?||?max_height?<=?0?||?max_height?>?MAX_HEIGHT?||?scale? printf(“cal?err!\n“);
return?-1;
}

#ifdef?

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件??????16535??2007-12-30?10:48??bin\cone.obj

?????文件????????839??2008-01-04?01:34??bin\cube.obj

?????文件??????27670??2008-09-16?14:54??bin\glut.h

?????文件?????237568??2008-09-16?14:54??bin\glut32.dll

?????文件??????28728??2008-09-16?14:54??bin\glut32.lib

?????文件????????188??2008-12-31?19:46??bin\run.bat

?????文件?????122880??2008-12-31?19:15??bin\SL_Z_buffer.exe

?????文件??????57515??2007-12-30?10:48??bin\sphere.obj

?????文件??????61417??2007-12-30?10:48??bin\teapot.obj

?????文件????????286??2008-01-01?20:42??bin\test.obj

?????文件??????33973??2007-12-30?10:48??bin\torus.obj

?????文件?????179844??2007-12-30?10:48??bin\torusknot.obj

?????文件????3080597??2008-01-03?23:58??bin\venusm.obj

?????文件?????122880??2008-12-31?19:15??SL_Z_buffer\debug\SL_Z_buffer.exe

?????文件??????16535??2007-12-30?10:48??SL_Z_buffer\SL_Z_buffer\cone.obj

?????文件????????839??2008-01-04?01:34??SL_Z_buffer\SL_Z_buffer\cube.obj

?????文件???????9346??2010-11-06?10:56??SL_Z_buffer\SL_Z_buffer\Debug\BuildLog.htm

?????文件??????????2??2011-01-14?11:18??SL_Z_buffer\SL_Z_buffer\Debug\cl.command.1.tlog

?????文件??????????2??2011-01-14?11:18??SL_Z_buffer\SL_Z_buffer\Debug\CL.read.1.tlog

?????文件??????????2??2011-01-14?11:18??SL_Z_buffer\SL_Z_buffer\Debug\CL.write.1.tlog

?????文件?????????65??2008-12-31?19:15??SL_Z_buffer\SL_Z_buffer\Debug\mt.dep

?????文件????????145??2008-12-31?19:15??SL_Z_buffer\SL_Z_buffer\Debug\SL_Z_buffer.exe.intermediate.manifest

?????文件????????114??2011-01-14?11:18??SL_Z_buffer\SL_Z_buffer\Debug\SL_Z_buffer.lastbuildstate

?????文件????????994??2011-01-14?11:18??SL_Z_buffer\SL_Z_buffer\Debug\SL_Z_buffer.log

?????文件??????????0??2011-01-14?11:18??SL_Z_buffer\SL_Z_buffer\Debug\SL_Z_buffer.unsuccessfulbuild

?????文件??????86016??2011-01-14?11:18??SL_Z_buffer\SL_Z_buffer\Debug\vc100.pdb

?????文件?????117760??2010-11-06?10:56??SL_Z_buffer\SL_Z_buffer\Debug\vc80.idb

?????文件?????179301??2008-12-31?19:15??SL_Z_buffer\SL_Z_buffer\Debug\z_buffer.obj

?????文件??????27670??2008-09-16?14:54??SL_Z_buffer\SL_Z_buffer\glut.h

?????文件?????237568??2008-09-16?14:54??SL_Z_buffer\SL_Z_buffer\glut32.dll

............此處省略35個文件信息

評論

共有 條評論