什么是3dmax扫描线(概念化行业适于设)

懵懂先生 投稿文章什么是3dmax扫描线(概念化行业适于设)已关闭评论50阅读模式

文章源自略懂百科-http://wswcn.cn/113025.html

数据结构:

CPoint3D: 3维点类CPolygon: 多边形类CEdge: 边类CActiveEdge: 活化边类文章源自略懂百科-http://wswcn.cn/113025.html

CScanLineZbufferProcess: 扫描线ZBuffer算法实现类,包括3ds文件加载,旋转,扫描过程,显示等。文章源自略懂百科-http://wswcn.cn/113025.html

CPoint3D

classCPoint3D{public:
CPoint3D(void);
CPoint3D(doublea,doubleb,doublec);
~CPoint3D(void);文章源自略懂百科-http://wswcn.cn/113025.html

CPoint3D(CPoint3D&rth);
CPoint3D&operator=(CPoint3D&rth);CPointGetPoint2D();public:doublex;doubley;doublez;文章源自略懂百科-http://wswcn.cn/113025.html

};文章源自略懂百科-http://wswcn.cn/113025.html

CPoint3D::CPoint3D(void)
{
x=y=z=0;
}
CPoint3D::CPoint3D(doublea,doubleb,doublec)
{
x=a;y=b;z=c;
}
CPoint3D::CPoint3D(CPoint3D&rth)
{
x=rth.x;
y=rth.y;
z=rth.z;
}文章源自略懂百科-http://wswcn.cn/113025.html

CPoint3D& CPoint3D::operator=(CPoint3D&rth)
{
x=rth.x;
y=rth.y;
z=rth.z;return*this;
}文章源自略懂百科-http://wswcn.cn/113025.html

CPoint CPoint3D::GetPoint2D()
{CPointp(x,y);returnp;
}文章源自略懂百科-http://wswcn.cn/113025.html

CPoint3D::~CPoint3D(void)
{
}文章源自略懂百科-http://wswcn.cn/113025.html

CEdge 类

classCEdge{public:CEdge(void);CEdge(CEdge&rth);~CEdge(void);public:CEdge&operator=(CEdge &rth);voidPoints2Edge(CPoint3D p1, CPoint3D p2);public:doublex;//边的上端点x的坐标doubledx;//相邻两条扫描线交点的x坐标差dx (-1/k)intdy;//边跨越的扫描线数目intid;//边所属多边形的编号intyMax;//CEdge*next;};CEdge::CEdge(void){x=0;dx=0;dy=0;id=-1;next=NULL;yMax=-100000;}CEdge::CEdge(CEdge &rth){x=rth.x;dx=rth.dx;dy=rth.dy;id=rth.id;next=rth.next;yMax=rth.yMax;}CEdge&CEdge::operator=(CEdge &rth){x=rth.x;dx=rth.dx;dy=rth.dy;id=rth.id;next=rth.next;yMax=rth.yMax;return*this;}CEdge::~CEdge(void){if(next)deletenext;}voidCEdge::Points2Edge(CPoint3D p1, CPoint3D p2){/*CPoint3DtopPoint = p1;yMax=p1.y;dy=abs(p1.y-p2.y);*/dy=abs(p1.y-p2.y);if(p1.y>p2.y){//p1是TOPpointyMax=p1.y;x=p1.x;if(dy!=0){dx=(p2.x-p1.x)/(p1.y-p2.y);}}else{//p2是TOPpointyMax=p2.y;x=p2.x;if(dy!=0){dx=(p1.x-p2.x)/(p2.y-p1.y);}}dy+=1;}文章源自略懂百科-http://wswcn.cn/113025.html

CEdgeList

classCEdgeList{public:
CEdgeList(void);
~CEdgeList(void);public:intymax;
CEdge *head;
};
CEdgeList::CEdgeList(void)
{
ymax =-1;
head=NULL;
}文章源自略懂百科-http://wswcn.cn/113025.html

CEdgeList::~CEdgeList(void)
{
}文章源自略懂百科-http://wswcn.cn/113025.html

CActiveEdge

classCActiveEdge{
public:CActiveEdge(void);
~CActiveEdge(void);
public:doublexl;//左交点的x坐标doubledxl;//(左交点边上)两相邻扫描线交点的x坐标之差intdyl;//以和左交点所在边相交的扫描线数为初值,doublexr;//右交点的x坐标doubledxr;//(右交点边上)两相邻扫描线交点的x坐标之差intdyr;//以和右交点所在边相交的扫描线数为初值,doublezl;//左交点处多边形所在平面的深度值;doubledzx;//沿扫描线向右走过一个像素时,多边形所在平面的深度增量。对于平面方程,dzx=-a/c(c≠0);doubledzy;//沿y方向向下移过一根扫描线时,多边形所在平面的深度增量。对于平面方程,dzy=b/c(c≠0);intid;//交点对所在的多边形的编号;CActiveEdge*next;文章源自略懂百科-http://wswcn.cn/113025.html

};CActiveEdge::CActiveEdge(void)
{
dxl =0;
dxr=0;
dyl=0;
dyr=0;
dzx=0;
dzy=0;
xl=0;
xr=0;
zl=0;文章源自略懂百科-http://wswcn.cn/113025.html

next =NULL;id=-1;
}CActiveEdge::~CActiveEdge(void)
{
}文章源自略懂百科-http://wswcn.cn/113025.html

CPolygon

//这里的多边形都是三角形,方便计算classCPolygon{public:
CPolygon(void);
CPolygon(CPolygon &rth);voidPoint2Face(CPoint3D p1, CPoint3D p2, CPoint3D p3);voidPoint2Face(CPoint3D *p,intnpoints);voidget_dy();CEdge*getEdgeList();//获取边表voidClearHorizontalEdge();//清除水平边.平行X的边~CPolygon(void);public:
CPolygon&operator=(CPolygon &rth);public:doublea,b,c,d;//多边形所在平面的方程系数ax+by+cz+d=0intid;//多边形的编号intdy;//多边形跨越的扫描线数目COLORREF color;//多边形的颜色intyMax;intnPoints;//点数CPolygon *next;文章源自略懂百科-http://wswcn.cn/113025.html

CPoint3D *point;//按顺序的点,要求前三个不能是共线的点};include"StdAfx.h"include"Polygon.h"CPolygon::CPolygon(void)
{
a =0;
b =0;
c =0;
d =0;文章源自略懂百科-http://wswcn.cn/113025.html

id =-1;
dy =0;文章源自略懂百科-http://wswcn.cn/113025.html

color = RGB(255,255,255);//默认底色为白next =NULL;文章源自略懂百科-http://wswcn.cn/113025.html

nPoints =0;
yMax =-100000;
}
CPolygon::CPolygon(CPolygon &rth)
{
a = rth.a;
b = rth.b;
c = rth.c;
d = rth.d;文章源自略懂百科-http://wswcn.cn/113025.html

id = rth.id;
dy = rth.dy;
color = rth.color;文章源自略懂百科-http://wswcn.cn/113025.html

next = rth.next;文章源自略懂百科-http://wswcn.cn/113025.html

}
CPolygon& CPolygon::operator=(CPolygon &rth)
{
a =rth.a;
b =rth.b;
c =rth.c;
d = rth.d;文章源自略懂百科-http://wswcn.cn/113025.html

id = rth.id;
dy = rth.dy;
color = rth.color;文章源自略懂百科-http://wswcn.cn/113025.html

point = rth.point;
nPoints = rth.nPoints;文章源自略懂百科-http://wswcn.cn/113025.html

next = rth.next;return*this;
}//三点不共线下求平面方程参数voidCPolygon::Point2Face(CPoint3D p1, CPoint3D p2, CPoint3D p3)
{doublex1 = p1.x, y1 = p1.y, z1 = p1.z;doublex2 = p2.x, y2 = p2.y, z2 = p2.z;doublex3 = p3.x, y3 = p3.y, z3 = p3.z;文章源自略懂百科-http://wswcn.cn/113025.html

a = (y2-y1)*(z3-z1)-(y3-y1)*(z2-z1);
b = (x3-x1)*(z2-z1)-(x2-x1)*(z3-z1);
c = (x2-x1)*(y3-y1)-(x3-x1)*(y2-y1);文章源自略懂百科-http://wswcn.cn/113025.html

d = -(a*x1+b*y1+c*z1);文章源自略懂百科-http://wswcn.cn/113025.html

}//voidCPolygon::Point2Face(CPoint3D *p,intnpoints)
{
point = p;
nPoints = npoints;文章源自略懂百科-http://wswcn.cn/113025.html

Point2Face(p[0],p[1],p[2]);
}//求出dyvoidCPolygon::get_dy()
{
CPoint3D *p = point;intyMin =100000;for(inti=0;i文章源自略懂百科-http://wswcn.cn/113025.html

}文章源自略懂百科-http://wswcn.cn/113025.html

dy = yMax - yMin +1;
}//获取边表CEdge* CPolygon::getEdgeList()
{
CEdge* pHead =NULL;// = new CEdge();/*pHead->Points2Edge(point[0], point[1]);
pHead->id = id;*/CEdge* pOld =NULL;// = pHead;for(inti=0;iPoints2Edge(point[i], point[j]);
pt->id = id;
pt->next =NULL;if(pHead==NULL)
{
pHead = pt;文章源自略懂百科-http://wswcn.cn/113025.html

pOld = pt;
}else{
pOld->next = pt;
pOld = pt;
}文章源自略懂百科-http://wswcn.cn/113025.html

}returnpHead;文章源自略懂百科-http://wswcn.cn/113025.html

}voidCPolygon::ClearHorizontalEdge()
{
}文章源自略懂百科-http://wswcn.cn/113025.html

CPolygon::~CPolygon(void)
{if(next)deletenext;
}文章源自略懂百科-http://wswcn.cn/113025.html

CPolygonList文章源自略懂百科-http://wswcn.cn/113025.html

pragmaonceinclude" polygon.h"classcpolygonlist{public:="" cpolygonlist(void);="" ~cpolygonlist(void);public:intymax;="" 多边形的最大y坐标cpolygon="" *head;="" };="" cpolygonlist::cpolygonlist(void)="" ymax="-1;" head="NULL;" }="" cpolygonlist::~cpolygonlist(void)="" }CScanLineZbufferProcessclassCScanLineZbufferProcess{public:
CScanLineZbufferProcess(void);
~CScanLineZbufferProcess(void);public:intnWidth,nHeight;//显示屏幕的尺寸CPaintDC *pDC;
CPolygonList *PolygonList;//分类的多边形表CEdgeList *EdgeList;//分类边表CPolygonList *ActivePolygonList;//活化分类的多边形表CActiveEdge *ActiveEdgeList;//活化分类边表COLORREF *FrameBuffer;//帧缓冲器double*ZBuffer;//z缓冲器COLORREF BackGroundColor;//背景色doubleminZ;//最小z值public:voidInitBuffer(intwidth,intheight,CPaintDC *pdc);//void InitPolygonListEdgeList();voidSortEdge(CEdge* pEdge);boolAddActivePolygonList(inty);//添加新多边形进活化多边形表voidUpdateActivePolygonList();//更新多边形进活化多边形表boolAddActiveEdgeList(inty);//添加新边堆到活化边表voidUpdateActiveEdgeList(inty);//更新新边对中的一边,由于一边结束,而多边形还在扫描区域,删除一条边,加入新边boolIsInActivePolygonList(intid);//指定的多边形是否在活化多边形表中COLORREFGetPolygonColor(intid);//获取多边形的颜色voidUpdateZBufferColor(inty);voidScan();voidShow();voidOnX(doubleangle, CPoint3D *p);voidOnY(doubleangle, CPoint3D *p);voidAddFace(CPoint3D *pFacePoint,intnpoints, COLORREF faceColor);//增加面intfaceid;public:
Lib3dsFile *model;boolLoad3ds(char*argv);//加载3ds文件voidrender_node(Lib3dsNode *node);boolbInit;floatm_Scale;//缩放比例floatm_Max;voidgetScalFor3dsFile(char*argv);voidget_nodeMax(Lib3dsNode *node);voidClear();//清除所有数据boolm_bYZ;boolm_EdgeShow;doubleangle_x;//绕x轴旋转角度doubleangle_y;//绕y轴旋转角度include "StdAfx.h"include "ScanLineZbufferProcess.h"include CScanLineZbufferProcess::CScanLineZbufferProcess(void)
{
faceid =-1;
BackGroundColor = RGB(255,255,255);//背景为白色minZ =-100000;文章源自略懂百科-http://wswcn.cn/113025.html

bInit =false;文章源自略懂百科-http://wswcn.cn/113025.html

m_bYZ =false;//false:Y轴在上,Z轴为深度 true:Z轴在上,Y轴为深度angle_x =0.0;
angle_y =0.0;文章源自略懂百科-http://wswcn.cn/113025.html

m_EdgeShow =false;文章源自略懂百科-http://wswcn.cn/113025.html

}文章源自略懂百科-http://wswcn.cn/113025.html

CScanLineZbufferProcess::~CScanLineZbufferProcess(void)
{
Clear();
}//清除所有数据void CScanLineZbufferProcess::Clear()
{for(int y = nHeight/2; y>-nHeight/2;y--)//从上往下扫描{try{//删除多边形表CPolygon *oldPolygon = PolygonList[y+nHeight/2].head;//y是当前的扫描线y值if(oldPolygon)
delete oldPolygon;文章源自略懂百科-http://wswcn.cn/113025.html

PolygonList[y+nHeight/2].head =NULL;文章源自略懂百科-http://wswcn.cn/113025.html

CEdge* tpEdge = EdgeList[y+nHeight/2].head;//删除边表if(tpEdge)
delete tpEdge;文章源自略懂百科-http://wswcn.cn/113025.html

EdgeList[y+nHeight/2].head =NULL;文章源自略懂百科-http://wswcn.cn/113025.html

}catch(...)
{
}
}//清除FrameBuffer、ZBufferint nCount = nWidth*nHeight;for(int i=0;i文章源自略懂百科-http://wswcn.cn/113025.html

face->id = ++faceid;
face->color = faceColor;文章源自略懂百科-http://wswcn.cn/113025.html

face->get_dy();if(face->c!=0)
{//与xoy面没有投影的面去掉face->next = PolygonList[face->yMax+nHeight/2].head;
PolygonList[face->yMax+nHeight/2].head = face;//多边形表CEdge *pEdge = face->getEdgeList();//边表SortEdge(pEdge);
}文章源自略懂百科-http://wswcn.cn/113025.html

}//将边按照yMax存入相应的边表void CScanLineZbufferProcess::SortEdge(CEdge* pEdge)
{
CEdge* tpEdge = pEdge;do{
CEdge* tOldpEdge = tpEdge->next;if(tpEdge->yMax+nHeight/2<=nHeight) //去除Ymax超过边界的值{ tpEdge->next = EdgeList[tpEdge->yMax+nHeight/2].head;
EdgeList[tpEdge->yMax+nHeight/2].head = tpEdge;//坐标原点在画板中心EdgeList[tpEdge->yMax+nHeight/2].ymax = tpEdge->yMax;
}文章源自略懂百科-http://wswcn.cn/113025.html

tpEdge = tOldpEdge;文章源自略懂百科-http://wswcn.cn/113025.html

}while(tpEdge);
}//step1 添加活化多边形表bool CScanLineZbufferProcess::AddActivePolygonList(int y)
{if(PolygonList[y+nHeight/2].head!=NULL)
{
CPolygon *tPolygon = ActivePolygonList->head;while(tPolygon && tPolygon->next)
{文章源自略懂百科-http://wswcn.cn/113025.html

tPolygon = tPolygon->next;
}文章源自略懂百科-http://wswcn.cn/113025.html

CPolygon *oldPolygon = PolygonList[y+nHeight/2].head;//y是当前的扫描线y值while(oldPolygon)
{if(oldPolygon->c!=0)
{
CPolygon *tnewPolygon =newCPolygon();文章源自略懂百科-http://wswcn.cn/113025.html

*tnewPolygon = *oldPolygon;if(ActivePolygonList->head==NULL)
{
ActivePolygonList->head = tnewPolygon;
}else{
tPolygon->next = tnewPolygon;
}文章源自略懂百科-http://wswcn.cn/113025.html

tPolygon = tnewPolygon;
}文章源自略懂百科-http://wswcn.cn/113025.html

oldPolygon = oldPolygon->next;
}returntrue;//有新多边形加入}returnfalse;
}//更新活化多边形表,删除不再扫描区域的多边形void CScanLineZbufferProcess::UpdateActivePolygonList()
{//活化多边形表中的元素修改CPolygon *tPolygon = ActivePolygonList->head;文章源自略懂百科-http://wswcn.cn/113025.html

CPolygon *tOldPolygon = tPolygon;while(tPolygon)
{文章源自略懂百科-http://wswcn.cn/113025.html

tPolygon->dy -=1;//每一个多边形的dy:dy = dy-1if(tPolygon->dy<=0) //当dy <=0时,该多边形要从多边形活化表中删除{if(ActivePolygonList->head==tPolygon)
ActivePolygonList->head = tPolygon->next;//删除第一个节点else{
tOldPolygon->next = tPolygon->next;
}
}else{//不删除,才需更新上一个指针tOldPolygon = tPolygon;
}文章源自略懂百科-http://wswcn.cn/113025.html

tPolygon = tPolygon->next;
}
}//有新多边形加入时添加新边对到活化边表bool CScanLineZbufferProcess::AddActiveEdgeList(int y)
{文章源自略懂百科-http://wswcn.cn/113025.html

CPolygon* tPolygon = PolygonList[y+nHeight/2].head;while(tPolygon)
{
int i=0;文章源自略懂百科-http://wswcn.cn/113025.html

CEdge* tpEdge = EdgeList[y+nHeight/2].head;//这里的多边形都是三角形,方便计算CActiveEdge* tActiveEdge =newCActiveEdge();while(tpEdge)
{if(tpEdge->id==tPolygon->id)
{if(tpEdge->dy<=1) //是水平线{ tpEdge=tpEdge->next;continue;
}if(i==0)
{
tActiveEdge->id = tPolygon->id;文章源自略懂百科-http://wswcn.cn/113025.html

tActiveEdge->dxl = tpEdge->dx;
tActiveEdge->dyl = tpEdge->dy;
tActiveEdge->xl = tpEdge->x;文章源自略懂百科-http://wswcn.cn/113025.html

tActiveEdge->dzx = -(tPolygon->a / tPolygon->c);
tActiveEdge->dzy = tPolygon->b / tPolygon->c;
tActiveEdge->zl = -( tPolygon->a * tpEdge->x + tPolygon->b*y +tPolygon->d )/tPolygon->c;文章源自略懂百科-http://wswcn.cn/113025.html

i++;文章源自略懂百科-http://wswcn.cn/113025.html

}else{if((tActiveEdge->xl + tActiveEdge->dxl) > (tpEdge->x+tpEdge->dx))
{//左右两边交换tActiveEdge->dxr = tActiveEdge->dxl;
tActiveEdge->dyr = tActiveEdge->dyl;
tActiveEdge->xr = tActiveEdge->xl;文章源自略懂百科-http://wswcn.cn/113025.html

tActiveEdge->dxl = tpEdge->dx;
tActiveEdge->dyl = tpEdge->dy;
tActiveEdge->xl = tpEdge->x;
}else{
tActiveEdge->dxr = tpEdge->dx;
tActiveEdge->dyr = tpEdge->dy;
tActiveEdge->xr = tpEdge->x;
}/******************加入活化表*****************************/if(ActiveEdgeList==NULL||ActiveEdgeList->id==-1)
ActiveEdgeList = tActiveEdge;else{
tActiveEdge->next = ActiveEdgeList;//插入表头ActiveEdgeList = tActiveEdge;
}/*******************end 加入活化表**************************/i =0;break;//寻找下一个多边形}
}文章源自略懂百科-http://wswcn.cn/113025.html

tpEdge = tpEdge->next;
}文章源自略懂百科-http://wswcn.cn/113025.html

tPolygon = tPolygon->next;文章源自略懂百科-http://wswcn.cn/113025.html

}returntrue;
}//更新活化边表void CScanLineZbufferProcess::UpdateActiveEdgeList(int y)
{
CActiveEdge *tActiveEdgeList = ActiveEdgeList;文章源自略懂百科-http://wswcn.cn/113025.html

CActiveEdge *tOldActiveEdgeList = tActiveEdgeList;while(tActiveEdgeList&&tActiveEdgeList->id!=-1)
{
tActiveEdgeList->dyl -=1; tActiveEdgeList->dyr -=1;文章源自略懂百科-http://wswcn.cn/113025.html

tActiveEdgeList->xl +=tActiveEdgeList->dxl; tActiveEdgeList->xr +=tActiveEdgeList->dxr;//边和下一条扫描线交点的x值tActiveEdgeList->zl += tActiveEdgeList->dzx * tActiveEdgeList->dxl + tActiveEdgeList->dzy;//若dyl或dyr小于0,相应的边就要从一个边对if(tActiveEdgeList->dyl<=0||tActiveEdgeList->dyr<=0) {if(IsInActivePolygonList(tActiveEdgeList->id))
{
tOldActiveEdgeList = tActiveEdgeList;//保存为前向节点//还在活化多边形表中,选择修改边对,删除原来的,加入新边CEdge *tpEdge = EdgeList[y+nHeight/2].head;while(tpEdge)
{if(tpEdge->id==tActiveEdgeList->id)
{if(tActiveEdgeList->dyl<=0) {//更新左边tActiveEdgeList->dxl = tpEdge->dx;
tActiveEdgeList->dyl = tpEdge->dy;
tActiveEdgeList->xl = tpEdge->x;文章源自略懂百科-http://wswcn.cn/113025.html

}else{//更新右边tActiveEdgeList->dxr = tpEdge->dx;
tActiveEdgeList->dyr = tpEdge->dy;
tActiveEdgeList->xr = tpEdge->x;
}break;文章源自略懂百科-http://wswcn.cn/113025.html

}文章源自略懂百科-http://wswcn.cn/113025.html

tpEdge = tpEdge->next;
}文章源自略懂百科-http://wswcn.cn/113025.html

}else{//删除该边对if(tActiveEdgeList == ActiveEdgeList)
{//表头ActiveEdgeList = tActiveEdgeList->next;文章源自略懂百科-http://wswcn.cn/113025.html

tOldActiveEdgeList = ActiveEdgeList;文章源自略懂百科-http://wswcn.cn/113025.html

}else{
tOldActiveEdgeList->next = tActiveEdgeList->next;文章源自略懂百科-http://wswcn.cn/113025.html

}
}
}else{
tOldActiveEdgeList = tActiveEdgeList;//保存为前向节点}文章源自略懂百科-http://wswcn.cn/113025.html

tActiveEdgeList = tActiveEdgeList->next;//下一个边对}文章源自略懂百科-http://wswcn.cn/113025.html

}//获取多边形颜色值COLORREF CScanLineZbufferProcess::GetPolygonColor(int id)
{
CPolygon *tPolygon = ActivePolygonList->head;while(tPolygon)
{if(tPolygon->id == id)
{returntPolygon->color;
}
tPolygon = tPolygon->next;
}returnthis->BackGroundColor;//没找到返回背景色}//指定的多边形是否在活化多边形表中bool CScanLineZbufferProcess::IsInActivePolygonList(int id)
{
CPolygon *tPolygon = ActivePolygonList->head;while(tPolygon)
{if(tPolygon->id == id)
{returntrue;
}
tPolygon = tPolygon->next;
}returnfalse;文章源自略懂百科-http://wswcn.cn/113025.html

}//step2 增量式的深度更新void CScanLineZbufferProcess::UpdateZBufferColor(int y)
{
CActiveEdge *tActiveEdgeList = ActiveEdgeList;while(tActiveEdgeList && tActiveEdgeList->id!=-1)
{
double Zx = tActiveEdgeList->zl;for(int x = tActiveEdgeList->xl;x<=tActiveEdgeList->xr;x++)
{if(abs(x)>nWidth/2)
{
Zx += tActiveEdgeList->dzx;continue;
}文章源自略懂百科-http://wswcn.cn/113025.html

int index = (nHeight/2-y)*nWidth + nWidth/2+x;if(Zx > ZBuffer[index])
{
ZBuffer[index] = Zx;//更新深度值if(m_EdgeShow)
{if( x == (int)tActiveEdgeList->xl || x==(int)tActiveEdgeList->xr)
FrameBuffer[index] = RGB(255,255,255);//边界线都是白色else{
FrameBuffer[index] = GetPolygonColor(tActiveEdgeList->id);//更新颜色}
}else{文章源自略懂百科-http://wswcn.cn/113025.html

FrameBuffer[index] = GetPolygonColor(tActiveEdgeList->id);//更新颜色}文章源自略懂百科-http://wswcn.cn/113025.html

}文章源自略懂百科-http://wswcn.cn/113025.html

Zx += tActiveEdgeList->dzx;文章源自略懂百科-http://wswcn.cn/113025.html

}文章源自略懂百科-http://wswcn.cn/113025.html

tActiveEdgeList = tActiveEdgeList->next;//下一个边对}
}//扫描void CScanLineZbufferProcess::Scan()
{
ActivePolygonList =newCPolygonList();//活化多边形表ActiveEdgeList =newCActiveEdge();//活化边表for(int y = nHeight/2; y>-nHeight/2;y--)//从上往下扫描{try{//step1 添加新的多边形进活化多边形表,有新多变形加入时添加边对进活化边表AddActivePolygonList(y);
AddActiveEdgeList(y);//step2 增量式的深度更新UpdateZBufferColor(y);//活化多边形表中的元素修改UpdateActivePolygonList();//step3 活化边表中的元素修改:修改后的活化边表是下一条扫描线的活化边表UpdateActiveEdgeList(y);
}catch(...)
{
AfxMessageBox(_T(" 出错!"));="" 显示framebuffer图形void="" cscanlinezbufferprocess::show()="" dc="" 的原点在(nwidth="" 2,nheight="" 2)]for(int="" y="nHeight/2;" y>-nheight="" 2;="" y--)="" {for(int="" x="-nWidth/2;" x0人点赞文章源自略懂百科-http://wswcn.cn/113025.html

图形学文章源自略懂百科-http://wswcn.cn/113025.html


文章源自略懂百科-http://wswcn.cn/113025.html

文章源自略懂百科-http://wswcn.cn/113025.html

懵懂先生
  • 本文由 发表于 2023年8月20日 19:04:26
  • 转载请注明:http://wswcn.cn/113025.html
投稿文章

歌词我一路看过千山万水是哪首歌(我一路看过千山万水是什么歌)

有人说:人字有两笔,一笔写前半生,一笔写后半生。前半生生根、发芽、开花;后半生结果、收获、储藏。 也有人说:人生就像赶路,山一程,水一程,一路风雨兼程,一路披荆斩棘,往前看,人生仿佛遥不可及,往后看,...
投稿文章

菠萝要用盐水泡吗?菠萝要用盐水泡多久才能吃?

菠萝美味多汁,香甜可口,是葡萄牙人在明朝传入到我国的,其实菠萝和凤梨是同一个品种的水果,只不过菠萝到台湾地区后经过品种改良。所以和国内的菠萝有所区别。 我们在吃菠萝的时候,总是要用盐水浸泡一下,这是什...
投稿文章

好文:淮山排骨汤的做法 如何煮淮山排骨汤

夏天天气热,孕妇来碗淮山排骨汤,清淡爽口还能补充营养 夏天到了,气温一天比一天高,天气越来越炎热,孕妈妈吃不下饭,胎儿得不到营养怎么办?来碗淮山排骨汤,不仅可以补血补气、健脾养胃还能补充胎儿的营养。废...
投稿文章

手机银行介绍(什么叫手机银行)

6月16日,九江银行正式发布手机银行5.0版,新版手机银行围绕有温度,更懂你的主题全新升级,聚焦优化用户体验,打造全新一代九江银行线上综合服务平台。发布会上,九江银行还推出统一品牌形象江豚小九。 九江...