diff --git a/PolyhedronHouse/AET.cpp b/PolyhedronHouse/AET.cpp new file mode 100644 index 0000000..e1653e6 --- /dev/null +++ b/PolyhedronHouse/AET.cpp @@ -0,0 +1,27 @@ +// AET.cpp: implementation of the CAET class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "Test.h" +#include "AET.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CAET::CAET() +{ + +} + +CAET::~CAET() +{ + +} diff --git a/PolyhedronHouse/AET.h b/PolyhedronHouse/AET.h new file mode 100644 index 0000000..7164c5b --- /dev/null +++ b/PolyhedronHouse/AET.h @@ -0,0 +1,27 @@ +// AET.h: interface for the CAET class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_CAET_H__D7F2123F_A3AE_40D6_81D8_E403C7E50447__INCLUDED_) +#define AFX_CAET_H__D7F2123F_A3AE_40D6_81D8_E403C7E50447__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +#include "Pi2.h" + +class CAET +{ +public: + CAET(); + virtual ~CAET(); +public: + double x;//当前扫描线与有效边交点的x坐标 + int yMax;//边的最大y值 + double k;//斜率的倒数(x的增量) + CPi2 ps;//边的起点 + CPi2 pe;//边的终点 + CAET *pNext; +}; + +#endif // !defined(AFX_CAET_H__D7F2123F_A3AE_40D6_81D8_E403C7E50447__INCLUDED_) diff --git a/PolyhedronHouse/Bucket.cpp b/PolyhedronHouse/Bucket.cpp new file mode 100644 index 0000000..646a0e5 --- /dev/null +++ b/PolyhedronHouse/Bucket.cpp @@ -0,0 +1,27 @@ +// Bucket.cpp: implementation of the CBucket class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "Test.h" +#include "Bucket.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CBucket::CBucket() +{ + +} + +CBucket::~CBucket() +{ + +} diff --git a/PolyhedronHouse/Bucket.h b/PolyhedronHouse/Bucket.h new file mode 100644 index 0000000..64fdd3b --- /dev/null +++ b/PolyhedronHouse/Bucket.h @@ -0,0 +1,24 @@ +// Bucket.h: interface for the CBucket class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_CBUCKET_H__B36B2287_DDD5_4BE9_B57A_D359001CB0C5__INCLUDED_) +#define AFX_CBUCKET_H__B36B2287_DDD5_4BE9_B57A_D359001CB0C5__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +#include "AET.h" + +class CBucket +{ +public: + CBucket(); + virtual ~CBucket(); +public: + int ScanLine; + CAET *pET; + CBucket *pNext; +}; + +#endif // !defined(AFX_CBUCKET_H__B36B2287_DDD5_4BE9_B57A_D359001CB0C5__INCLUDED_) diff --git a/PolyhedronHouse/Face.cpp b/PolyhedronHouse/Face.cpp new file mode 100644 index 0000000..c00c78a --- /dev/null +++ b/PolyhedronHouse/Face.cpp @@ -0,0 +1,46 @@ +// Face.cpp: implementation of the CFace class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "Test.h" +#include "Face.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CFace::CFace() +{ + vI=NULL; + fNormal=CVector(CP3(0.0,0.0,1.0)); + fClr=CRGB(1.0,1.0,1.0); +} + +CFace::~CFace() +{ + if(vI!=NULL) + { + delete []vI; + vI=NULL; + } +} + +void CFace::SetNum(int n) +{ + vN=n; + vI=new int[n]; +} + +void CFace::SetFaceNormal(CP3 pt0,CP3 pt1,CP3 pt2)//计算小面法矢量 +{ + CVector V01(pt0,pt1); + CVector V02(pt0,pt2); + fNormal=Cross(V01,V02); +} \ No newline at end of file diff --git a/PolyhedronHouse/Face.h b/PolyhedronHouse/Face.h new file mode 100644 index 0000000..2921a50 --- /dev/null +++ b/PolyhedronHouse/Face.h @@ -0,0 +1,27 @@ +// Face.h: interface for the CFace class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_FACE_H__82BF93AE_A82E_407D_AF42_6E6608253C1C__INCLUDED_) +#define AFX_FACE_H__82BF93AE_A82E_407D_AF42_6E6608253C1C__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +#include "Vector.h" + +class CFace +{ +public: + CFace(); + virtual ~CFace(); + void SetNum(int);//设置面的顶点数 + void SetFaceNormal(CP3,CP3,CP3);//设置面的法矢量 +public: + int vN; //面的顶点数 + int *vI; //面的顶点索引 + CVector fNormal; //面的法矢量 + CRGB fClr; //面的颜色 +}; + +#endif // !defined(AFX_FACE_H__82BF93AE_A82E_407D_AF42_6E6608253C1C__INCLUDED_) diff --git a/PolyhedronHouse/MainFrm.cpp b/PolyhedronHouse/MainFrm.cpp new file mode 100644 index 0000000..4b8fbd9 --- /dev/null +++ b/PolyhedronHouse/MainFrm.cpp @@ -0,0 +1,107 @@ +// MainFrm.cpp : implementation of the CMainFrame class +// + +#include "stdafx.h" +#include "Test.h" + +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame + +IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) + +BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) + //{{AFX_MSG_MAP(CMainFrame) + // NOTE - the ClassWizard will add and remove mapping macros here. + // DO NOT EDIT what you see in these blocks of generated code ! + ON_WM_CREATE() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +static UINT indicators[] = +{ + ID_SEPARATOR, // status line indicator + ID_INDICATOR_CAPS, + ID_INDICATOR_NUM, + ID_INDICATOR_SCRL, +}; + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame construction/destruction + +CMainFrame::CMainFrame() +{ + // TODO: add member initialization code here + +} + +CMainFrame::~CMainFrame() +{ +} + +int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CFrameWnd::OnCreate(lpCreateStruct) == -1) + return -1; + + if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP + | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || + !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) + { + TRACE0("Failed to create toolbar\n"); + return -1; // fail to create + } + + if (!m_wndStatusBar.Create(this) || + !m_wndStatusBar.SetIndicators(indicators, + sizeof(indicators)/sizeof(UINT))) + { + TRACE0("Failed to create status bar\n"); + return -1; // fail to create + } + + // TODO: Delete these three lines if you don't want the toolbar to + // be dockable + m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); + EnableDocking(CBRS_ALIGN_ANY); + DockControlBar(&m_wndToolBar); + + return 0; +} + +BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + if( !CFrameWnd::PreCreateWindow(cs) ) + return FALSE; + // TODO: Modify the Window class or styles here by modifying + // the CREATESTRUCT cs + + return TRUE; +} + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame diagnostics + +#ifdef _DEBUG +void CMainFrame::AssertValid() const +{ + CFrameWnd::AssertValid(); +} + +void CMainFrame::Dump(CDumpContext& dc) const +{ + CFrameWnd::Dump(dc); +} + +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame message handlers + diff --git a/PolyhedronHouse/MainFrm.h b/PolyhedronHouse/MainFrm.h new file mode 100644 index 0000000..a52d77a --- /dev/null +++ b/PolyhedronHouse/MainFrm.h @@ -0,0 +1,58 @@ +// MainFrm.h : interface of the CMainFrame class +// +///////////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_MAINFRM_H__7BDF38E2_1C35_4E15_804B_2AB491FCC818__INCLUDED_) +#define AFX_MAINFRM_H__7BDF38E2_1C35_4E15_804B_2AB491FCC818__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +class CMainFrame : public CFrameWnd +{ + +protected: // create from serialization only + CMainFrame(); + DECLARE_DYNCREATE(CMainFrame) + +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CMainFrame) + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CMainFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: // control bar embedded members + CStatusBar m_wndStatusBar; + CToolBar m_wndToolBar; + +// Generated message map functions +protected: + //{{AFX_MSG(CMainFrame) + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + // NOTE - the ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_MAINFRM_H__7BDF38E2_1C35_4E15_804B_2AB491FCC818__INCLUDED_) diff --git a/PolyhedronHouse/P2.cpp b/PolyhedronHouse/P2.cpp new file mode 100644 index 0000000..e495d96 --- /dev/null +++ b/PolyhedronHouse/P2.cpp @@ -0,0 +1,46 @@ +// P2.cpp: implementation of the CP2 class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "Test.h" +#include "P2.h" +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CP2::CP2() +{ + x=0.0; + y=0.0; + w=1.0; + c=CRGB(0.0,0.0,0.0); +} + +CP2::~CP2() +{ + +} + +CP2::CP2(double x,double y) +{ + this->x=x; + this->y=y; + this->w=1.0; + this->c=CRGB(1.0,1.0,1.0); +} + +CP2::CP2(double x,double y,CRGB c) +{ + this->x=x; + this->y=y; + this->w=1.0; + this->c=c; +} + diff --git a/PolyhedronHouse/P2.h b/PolyhedronHouse/P2.h new file mode 100644 index 0000000..e566e1c --- /dev/null +++ b/PolyhedronHouse/P2.h @@ -0,0 +1,27 @@ +// P2.h: interface for the CP2 class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_P2_H__F5B8C5D7_BC9B_4346_817B_F55E89EE7598__INCLUDED_) +#define AFX_P2_H__F5B8C5D7_BC9B_4346_817B_F55E89EE7598__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +#include "RGB.h" + +class CP2 +{ +public: + CP2(); + virtual ~CP2(); + CP2(double,double); + CP2(double,double,CRGB); +public: + double x; + double y; + double w; + CRGB c; +}; + +#endif // !defined(AFX_P2_H__F5B8C5D7_BC9B_4346_817B_F55E89EE7598__INCLUDED_) diff --git a/PolyhedronHouse/P3.cpp b/PolyhedronHouse/P3.cpp new file mode 100644 index 0000000..e162ca7 --- /dev/null +++ b/PolyhedronHouse/P3.cpp @@ -0,0 +1,110 @@ +// P3.cpp: implementation of the CP3 class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "Test.h" +#include "P3.h" +#include "math.h" +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CP3::CP3() +{ + z=0.0; +} + +CP3::~CP3() +{ + +} +CP3::CP3(double x,double y,double z):CP2(x,y) +{ + this->z=z; +} + +CP3 operator +(const CP3 &p0,const CP3 &p1)//和 +{ + CP3 p; + p.x=p0.x+p1.x; + p.y=p0.y+p1.y; + p.z=p0.z+p1.z; + return p; +} + +CP3 operator -(const CP3 &p0,const CP3 &p1)//差 +{ + CP3 p; + p.x=p0.x-p1.x; + p.y=p0.y-p1.y; + p.z=p0.z-p1.z; + return p; +} + +CP3 operator *(const CP3 &p,double k)//点和常量的积 +{ + return CP3(p.x*k,p.y*k,p.z*k); +} + +CP3 operator *(double k,const CP3 &p)//点和常量的积 +{ + return CP3(p.x*k,p.y*k,p.z*k); +} + +CP3 operator /(const CP3 &p0,double k)//数除 +{ + if(fabs(k)<1e-6) + k=1.0; + CP3 p; + p.x=p0.x/k; + p.y=p0.y/k; + p.z=p0.z/k; + return p; +} + +CP3 operator+=(CP3 &p0,CP3 &p1) +{ + p0.x=p0.x+p1.x; + p0.y=p0.y+p1.y; + p0.z=p0.z+p1.z; + return p0; +} + +CP3 operator-=(CP3 &p0,CP3 &p1) +{ + p0.x=p0.x-p1.x; + p0.y=p0.y-p1.y; + p0.z=p0.z-p1.z; + return p0; +} + +CP3 operator*=(CP3 &p0,double k) +{ + p0.x=p0.x*k; + p0.y=p0.y*k; + p0.z=p0.z*k; + return p0; +} + +CP3 operator/=(CP3 &p0,double k) +{ + if(fabs(k)<1e-6) + k=1.0; + p0.x=p0.x/k; + p0.y=p0.y/k; + p0.z=p0.z/k; + return p0; +} + +double CP3::Mag()//长度 +{ + return sqrt(x*x+y*y+z*z); +} + diff --git a/PolyhedronHouse/P3.h b/PolyhedronHouse/P3.h new file mode 100644 index 0000000..211dac3 --- /dev/null +++ b/PolyhedronHouse/P3.h @@ -0,0 +1,33 @@ +// P3.h: interface for the CP3 class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_P3_H__5B85FC65_6516_4259_941E_FAB30D13824E__INCLUDED_) +#define AFX_P3_H__5B85FC65_6516_4259_941E_FAB30D13824E__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +#include "P2.h" + +class CP3:public CP2 +{ +public: + CP3(); + virtual ~CP3(); + CP3(double,double,double); + friend CP3 operator +(const CP3 &,const CP3 &);//运算符重载 + friend CP3 operator -(const CP3 &,const CP3 &); + friend CP3 operator *(const CP3 &,double); + friend CP3 operator *(double,const CP3 &); + friend CP3 operator /(const CP3 &,double); + friend CP3 operator+=(CP3 &,CP3 &); + friend CP3 operator-=(CP3 &,CP3 &); + friend CP3 operator*=(CP3 &,double); + friend CP3 operator/=(CP3 &,double); + double Mag();//长度 +public: + double z; +}; + +#endif // !defined(AFX_P3_H__5B85FC65_6516_4259_941E_FAB30D13824E__INCLUDED_) diff --git a/PolyhedronHouse/Pi2.cpp b/PolyhedronHouse/Pi2.cpp new file mode 100644 index 0000000..a1192c0 --- /dev/null +++ b/PolyhedronHouse/Pi2.cpp @@ -0,0 +1,35 @@ +// Pi2.cpp: implementation of the CPi2 class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "Test.h" +#include "Pi2.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CPi2::CPi2() +{ + x=0.0; + y=0; + c=CRGB(0.0,0.0,0.0); +} + +CPi2::~CPi2() +{ + +} + +CPi2::CPi2(double x,int y) +{ + this->x=x; + this->y=y; +} \ No newline at end of file diff --git a/PolyhedronHouse/Pi2.h b/PolyhedronHouse/Pi2.h new file mode 100644 index 0000000..4181d25 --- /dev/null +++ b/PolyhedronHouse/Pi2.h @@ -0,0 +1,25 @@ +// Pi2.h: interface for the CPi2 class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_PI2_H__B80DAA04_DDC9_4F35_8BC8_B3DDDE62F21D__INCLUDED_) +#define AFX_PI2_H__B80DAA04_DDC9_4F35_8BC8_B3DDDE62F21D__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +#include "RGB.h" + +class CPi2 +{ +public: + CPi2(); + virtual ~CPi2(); + CPi2(double,int); +public: + double x; + int y; + CRGB c; +}; + +#endif // !defined(AFX_PI2_H__B80DAA04_DDC9_4F35_8BC8_B3DDDE62F21D__INCLUDED_) diff --git a/PolyhedronHouse/Pi3.cpp b/PolyhedronHouse/Pi3.cpp new file mode 100644 index 0000000..e125de3 --- /dev/null +++ b/PolyhedronHouse/Pi3.cpp @@ -0,0 +1,32 @@ +// Pi3.cpp: implementation of the CPi3 class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "Test.h" +#include "Pi3.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CPi3::CPi3() +{ + z=0.0; +} + +CPi3::~CPi3() +{ + +} + +CPi3::CPi3(double x,int y,double z):CPi2(x,y) +{ + this->z=z; +} \ No newline at end of file diff --git a/PolyhedronHouse/Pi3.h b/PolyhedronHouse/Pi3.h new file mode 100644 index 0000000..61bb38d --- /dev/null +++ b/PolyhedronHouse/Pi3.h @@ -0,0 +1,22 @@ +// Pi3.h: interface for the CPi3 class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_PI3_H__1DC85C9B_C92E_4165_9851_4C61236BF305__INCLUDED_) +#define AFX_PI3_H__1DC85C9B_C92E_4165_9851_4C61236BF305__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +#include "Pi2.h" + +class CPi3:public CPi2 +{ +public: + CPi3(); + virtual ~CPi3(); + CPi3(double,int,double); + double z; +}; + +#endif // !defined(AFX_PI3_H__1DC85C9B_C92E_4165_9851_4C61236BF305__INCLUDED_) diff --git a/PolyhedronHouse/RES/APP.ICO b/PolyhedronHouse/RES/APP.ICO new file mode 100644 index 0000000..ff42f3e Binary files /dev/null and b/PolyhedronHouse/RES/APP.ICO differ diff --git a/PolyhedronHouse/RES/EXIT.ICO b/PolyhedronHouse/RES/EXIT.ICO new file mode 100644 index 0000000..a2fcaed Binary files /dev/null and b/PolyhedronHouse/RES/EXIT.ICO differ diff --git a/PolyhedronHouse/RES/Help.ico b/PolyhedronHouse/RES/Help.ico new file mode 100644 index 0000000..b1aaffa Binary files /dev/null and b/PolyhedronHouse/RES/Help.ico differ diff --git a/PolyhedronHouse/RES/Test.ico b/PolyhedronHouse/RES/Test.ico new file mode 100644 index 0000000..168ef77 Binary files /dev/null and b/PolyhedronHouse/RES/Test.ico differ diff --git a/PolyhedronHouse/RES/Test.rc2 b/PolyhedronHouse/RES/Test.rc2 new file mode 100644 index 0000000..f3b43e0 --- /dev/null +++ b/PolyhedronHouse/RES/Test.rc2 @@ -0,0 +1,13 @@ +// +// TEST.RC2 - resources Microsoft Visual C++ does not edit directly +// + +#ifdef APSTUDIO_INVOKED + #error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// Add manually edited resources here... + +///////////////////////////////////////////////////////////////////////////// diff --git a/PolyhedronHouse/RES/TestDoc.ico b/PolyhedronHouse/RES/TestDoc.ico new file mode 100644 index 0000000..2a1f1ae Binary files /dev/null and b/PolyhedronHouse/RES/TestDoc.ico differ diff --git a/PolyhedronHouse/RES/Thumbs.db b/PolyhedronHouse/RES/Thumbs.db new file mode 100644 index 0000000..f1ac0a9 Binary files /dev/null and b/PolyhedronHouse/RES/Thumbs.db differ diff --git a/PolyhedronHouse/RES/Toolbar.bmp b/PolyhedronHouse/RES/Toolbar.bmp new file mode 100644 index 0000000..738aa37 Binary files /dev/null and b/PolyhedronHouse/RES/Toolbar.bmp differ diff --git a/PolyhedronHouse/RES/about.bmp b/PolyhedronHouse/RES/about.bmp new file mode 100644 index 0000000..40bc8c6 Binary files /dev/null and b/PolyhedronHouse/RES/about.bmp differ diff --git a/PolyhedronHouse/RES/draw.ico b/PolyhedronHouse/RES/draw.ico new file mode 100644 index 0000000..911bdce Binary files /dev/null and b/PolyhedronHouse/RES/draw.ico differ diff --git a/PolyhedronHouse/RGB.cpp b/PolyhedronHouse/RGB.cpp new file mode 100644 index 0000000..0e06fd3 --- /dev/null +++ b/PolyhedronHouse/RGB.cpp @@ -0,0 +1,129 @@ +// CRGB.cpp: implementation of the CRGB class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "Test.h" +#include "RGB.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CRGB::CRGB() +{ + red=1.0; + green=1.0; + blue=1.0; +} +CRGB::CRGB(double r,double g,double b)//重载构造函数 +{ + red=r; + green=g; + blue=b; +} + +CRGB::~CRGB() +{ + +} + +CRGB operator +(const CRGB &c1,const CRGB &c2)//+运算符重载 +{ + CRGB c; + c.red=c1.red+c2.red; + c.green=c1.green+c2.green; + c.blue=c1.blue+c2.blue; + return c; +} + +CRGB operator -(const CRGB &c1,const CRGB &c2)//-运算符重载 +{ + CRGB c; + c.red=c1.red-c2.red; + c.green=c1.green-c2.green; + c.blue=c1.blue-c2.blue; + return c; +} + +CRGB operator *(const CRGB &c1,const CRGB &c2)//*运算符重载 +{ + CRGB c; + c.red=c1.red*c2.red; + c.green=c1.green*c2.green; + c.blue=c1.blue*c2.blue; + return c; +} + +CRGB operator *(const CRGB &c1,double k)//*运算符重载 +{ + CRGB c; + c.red=k*c1.red; + c.green=k*c1.green; + c.blue=k*c1.blue; + return c; +} + +CRGB operator *(double k,const CRGB &c1)//*运算符重载 +{ + CRGB c; + c.red=k*c1.red; + c.green=k*c1.green; + c.blue=k*c1.blue; + return c; +} + +CRGB operator /(const CRGB &c1,double k)///运算符重载 +{ + CRGB c; + c.red=c1.red/k; + c.green=c1.green/k; + c.blue=c1.blue/k; + return c; +} + +CRGB operator +=(CRGB &c1,CRGB &c2)//+=运算符重载 +{ + c1.red=c1.red+c2.red; + c1.green=c1.green+c2.green; + c1.blue=c1.blue+c2.blue; + return c1; +} + +CRGB operator -=(CRGB &c1,CRGB &c2)//-=运算符重载 +{ + c1.red=c1.red-c2.red; + c1.green=c1.green-c2.green; + c1.blue=c1.blue-c2.blue; + return c1; +} + +CRGB operator *=(CRGB &c1,CRGB &c2)//*=运算符重载 +{ + c1.red=c1.red*c2.red; + c1.green=c1.green*c2.green; + c1.blue=c1.blue*c2.blue; + return c1; +} + +CRGB operator /=(CRGB &c1,double k)///=运算符重载 +{ + c1.red=c1.red/k; + c1.green=c1.green/k; + c1.blue=c1.blue/k; + return c1; +} + +void CRGB::Normalize()//归一化 +{ + red=(red < 0.0) ? 0.0 : ((red > 1.0) ? 1.0 : red); + green=(green < 0.0) ? 0.0 : ((green > 1.0) ? 1.0 : green); + blue=(blue < 0.0) ? 0.0 : ((blue > 1.0) ? 1.0 : blue); +} + diff --git a/PolyhedronHouse/RGB.h b/PolyhedronHouse/RGB.h new file mode 100644 index 0000000..c5cb879 --- /dev/null +++ b/PolyhedronHouse/RGB.h @@ -0,0 +1,35 @@ +// CRGB.h: interface for the CRGB class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_CRGB_H__F14E5B6C_E5FA_4DD9_8051_EB943E4929E7__INCLUDED_) +#define AFX_CRGB_H__F14E5B6C_E5FA_4DD9_8051_EB943E4929E7__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +class CRGB +{ +public: + CRGB(); + CRGB(double,double,double); + virtual ~CRGB(); + friend CRGB operator+(const CRGB &,const CRGB &);//运算符重载 + friend CRGB operator-(const CRGB &,const CRGB &); + friend CRGB operator*(const CRGB &,const CRGB &); + friend CRGB operator*(const CRGB &,double); + friend CRGB operator*(double,const CRGB &); + friend CRGB operator/(const CRGB &,double); + friend CRGB operator+=(CRGB &,CRGB &); + friend CRGB operator-=(CRGB &,CRGB &); + friend CRGB operator*=(CRGB &,CRGB &); + friend CRGB operator/=(CRGB &,double); + void Normalize(); //归一化到[0,1]区间 +public: + double red;//红色分量 + double green;//绿色分量 + double blue;//蓝色分量 +}; + +#endif // !defined(AFX_CRGB_H__F14E5B6C_E5FA_4DD9_8051_EB943E4929E7__INCLUDED_) diff --git a/PolyhedronHouse/ReadMe.txt b/PolyhedronHouse/ReadMe.txt new file mode 100644 index 0000000..a7f11b9 --- /dev/null +++ b/PolyhedronHouse/ReadMe.txt @@ -0,0 +1,105 @@ +======================================================================== + MICROSOFT FOUNDATION CLASS LIBRARY : Test +======================================================================== + + +AppWizard has created this Test application for you. This application +not only demonstrates the basics of using the Microsoft Foundation classes +but is also a starting point for writing your application. + +This file contains a summary of what you will find in each of the files that +make up your Test application. + +Test.dsp + This file (the project file) contains information at the project level and + is used to build a single project or subproject. Other users can share the + project (.dsp) file, but they should export the makefiles locally. + +Test.h + This is the main header file for the application. It includes other + project specific headers (including Resource.h) and declares the + CTestApp application class. + +Test.cpp + This is the main application source file that contains the application + class CTestApp. + +Test.rc + This is a listing of all of the Microsoft Windows resources that the + program uses. It includes the icons, bitmaps, and cursors that are stored + in the RES subdirectory. This file can be directly edited in Microsoft + Visual C++. + +Test.clw + This file contains information used by ClassWizard to edit existing + classes or add new classes. ClassWizard also uses this file to store + information needed to create and edit message maps and dialog data + maps and to create prototype member functions. + +res\Test.ico + This is an icon file, which is used as the application's icon. This + icon is included by the main resource file Test.rc. + +res\Test.rc2 + This file contains resources that are not edited by Microsoft + Visual C++. You should place all resources not editable by + the resource editor in this file. + + + +///////////////////////////////////////////////////////////////////////////// + +For the main frame window: + +MainFrm.h, MainFrm.cpp + These files contain the frame class CMainFrame, which is derived from + CFrameWnd and controls all SDI frame features. + +res\Toolbar.bmp + This bitmap file is used to create tiled images for the toolbar. + The initial toolbar and status bar are constructed in the CMainFrame + class. Edit this toolbar bitmap using the resource editor, and + update the IDR_MAINFRAME TOOLBAR array in Test.rc to add + toolbar buttons. +///////////////////////////////////////////////////////////////////////////// + +AppWizard creates one document type and one view: + +TestDoc.h, TestDoc.cpp - the document + These files contain your CTestDoc class. Edit these files to + add your special document data and to implement file saving and loading + (via CTestDoc::Serialize). + +TestView.h, TestView.cpp - the view of the document + These files contain your CTestView class. + CTestView objects are used to view CTestDoc objects. + + + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named Test.pch and a precompiled types file named StdAfx.obj. + +Resource.h + This is the standard header file, which defines new resource IDs. + Microsoft Visual C++ reads and updates this file. + +///////////////////////////////////////////////////////////////////////////// +Other notes: + +AppWizard uses "TODO:" to indicate parts of the source code you +should add to or customize. + +If your application uses MFC in a shared DLL, and your application is +in a language other than the operating system's current language, you +will need to copy the corresponding localized resources MFC42XXX.DLL +from the Microsoft Visual C++ CD-ROM onto the system or system32 directory, +and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation. +For example, MFC42DEU.DLL contains resources translated to German.) If you +don't do this, some of the UI elements of your application will remain in the +language of the operating system. + +///////////////////////////////////////////////////////////////////////////// diff --git a/PolyhedronHouse/StdAfx.cpp b/PolyhedronHouse/StdAfx.cpp new file mode 100644 index 0000000..0f878dd --- /dev/null +++ b/PolyhedronHouse/StdAfx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// Test.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + + diff --git a/PolyhedronHouse/StdAfx.h b/PolyhedronHouse/StdAfx.h new file mode 100644 index 0000000..227ba92 --- /dev/null +++ b/PolyhedronHouse/StdAfx.h @@ -0,0 +1,33 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__40591CFA_4C1D_4FD7_8414_6EA0BBACA787__INCLUDED_) +#define AFX_STDAFX_H__40591CFA_4C1D_4FD7_8414_6EA0BBACA787__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers + +#include // MFC core and standard components +#include // MFC extensions +#include // MFC Automation classes +#include // MFC support for Internet Explorer 4 Common Controls +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC support for Windows Common Controls +#endif // _AFX_NO_AFXCMN_SUPPORT +// 版权所有(2013) +// Copyright(2013) +// 编写者: 孔令德 +// Author: Kong Lingde +// 网址:www.klingde.com +// QQ:997796978 +// 地址:太原工业学院 计算机工程系 + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__40591CFA_4C1D_4FD7_8414_6EA0BBACA787__INCLUDED_) diff --git a/PolyhedronHouse/Test.aps b/PolyhedronHouse/Test.aps new file mode 100644 index 0000000..29e51c6 Binary files /dev/null and b/PolyhedronHouse/Test.aps differ diff --git a/PolyhedronHouse/Test.clw b/PolyhedronHouse/Test.clw new file mode 100644 index 0000000..19f53e5 --- /dev/null +++ b/PolyhedronHouse/Test.clw @@ -0,0 +1,101 @@ +; CLW file contains information for the MFC ClassWizard + +[General Info] +Version=1 +LastClass=CTestView +LastTemplate=CDialog +NewFileInclude1=#include "stdafx.h" +NewFileInclude2=#include "Test.h" +LastPage=0 + +ClassCount=5 +Class1=CTestApp +Class2=CTestDoc +Class3=CTestView +Class4=CMainFrame + +ResourceCount=2 +Resource1=IDR_MAINFRAME +Class5=CAboutDlg +Resource2=IDD_ABOUTBOX + +[CLS:CTestApp] +Type=0 +HeaderFile=Test.h +ImplementationFile=Test.cpp +Filter=N + +[CLS:CTestDoc] +Type=0 +HeaderFile=TestDoc.h +ImplementationFile=TestDoc.cpp +Filter=N + +[CLS:CTestView] +Type=0 +HeaderFile=TestView.h +ImplementationFile=TestView.cpp +Filter=C +BaseClass=CView +VirtualFilter=VWC +LastObject=CTestView + + +[CLS:CMainFrame] +Type=0 +HeaderFile=MainFrm.h +ImplementationFile=MainFrm.cpp +Filter=T +LastObject=ID_TWOPOINT + + + + +[CLS:CAboutDlg] +Type=0 +HeaderFile=Test.cpp +ImplementationFile=Test.cpp +Filter=D + +[DLG:IDD_ABOUTBOX] +Type=1 +Class=CAboutDlg +ControlCount=2 +Control1=IDOK,button,1342373889 +Control2=IDB_BITMAP1,static,1342177294 + +[MNU:IDR_MAINFRAME] +Type=1 +Class=CMainFrame +Command1=ID_APP_EXIT +Command2=IDM_PLAY +Command3=ID_APP_ABOUT +CommandCount=3 + +[ACL:IDR_MAINFRAME] +Type=1 +Class=CMainFrame +Command1=ID_FILE_NEW +Command2=ID_FILE_OPEN +Command3=ID_FILE_SAVE +Command4=ID_FILE_PRINT +Command5=ID_EDIT_UNDO +Command6=ID_EDIT_CUT +Command7=ID_EDIT_COPY +Command8=ID_EDIT_PASTE +Command9=ID_EDIT_UNDO +Command10=ID_EDIT_CUT +Command11=ID_EDIT_COPY +Command12=ID_EDIT_PASTE +Command13=ID_NEXT_PANE +Command14=ID_PREV_PANE +CommandCount=14 + +[TB:IDR_MAINFRAME] +Type=1 +Class=CMainFrame +Command1=ID_APP_EXIT +Command2=IDM_PLAY +Command3=ID_APP_ABOUT +CommandCount=3 + diff --git a/PolyhedronHouse/Test.cpp b/PolyhedronHouse/Test.cpp new file mode 100644 index 0000000..3ab387d --- /dev/null +++ b/PolyhedronHouse/Test.cpp @@ -0,0 +1,154 @@ +// Test.cpp : Defines the class behaviors for the application. +// + +#include "stdafx.h" +#include "Test.h" + +#include "MainFrm.h" +#include "TestDoc.h" +#include "TestView.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CTestApp + +BEGIN_MESSAGE_MAP(CTestApp, CWinApp) + //{{AFX_MSG_MAP(CTestApp) + ON_COMMAND(ID_APP_ABOUT, OnAppAbout) + // NOTE - the ClassWizard will add and remove mapping macros here. + // DO NOT EDIT what you see in these blocks of generated code! + //}}AFX_MSG_MAP + // Standard file based document commands + ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) + ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) + // Standard print setup command + ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CTestApp construction + +CTestApp::CTestApp() +{ + // TODO: add construction code here, + // Place all significant initialization in InitInstance +} + +///////////////////////////////////////////////////////////////////////////// +// The one and only CTestApp object + +CTestApp theApp; + +///////////////////////////////////////////////////////////////////////////// +// CTestApp initialization + +BOOL CTestApp::InitInstance() +{ + AfxEnableControlContainer(); + + // Standard initialization + // If you are not using these features and wish to reduce the size + // of your final executable, you should remove from the following + // the specific initialization routines you do not need. + +#ifdef _AFXDLL + Enable3dControls(); // Call this when using MFC in a shared DLL +#else + Enable3dControlsStatic(); // Call this when linking to MFC statically +#endif + + // Change the registry key under which our settings are stored. + // TODO: You should modify this string to be something appropriate + // such as the name of your company or organization. + SetRegistryKey(_T("Local AppWizard-Generated Applications")); + + LoadStdProfileSettings(); // Load standard INI file options (including MRU) + + // Register the application's document templates. Document templates + // serve as the connection between documents, frame windows and views. + + CSingleDocTemplate* pDocTemplate; + pDocTemplate = new CSingleDocTemplate( + IDR_MAINFRAME, + RUNTIME_CLASS(CTestDoc), + RUNTIME_CLASS(CMainFrame), // main SDI frame window + RUNTIME_CLASS(CTestView)); + AddDocTemplate(pDocTemplate); + + // Parse command line for standard shell commands, DDE, file open + CCommandLineInfo cmdInfo; + ParseCommandLine(cmdInfo); + + // Dispatch commands specified on the command line + if (!ProcessShellCommand(cmdInfo)) + return FALSE; + + // The one and only window has been initialized, so show and update it. + m_pMainWnd->ShowWindow(SW_MAXIMIZE); + m_pMainWnd->SetWindowText("案例44:Z-Buffer算法"); + m_pMainWnd->UpdateWindow(); + return TRUE; +} + + +///////////////////////////////////////////////////////////////////////////// +// CAboutDlg dialog used for App About + +class CAboutDlg : public CDialog +{ +public: + CAboutDlg(); + +// Dialog Data + //{{AFX_DATA(CAboutDlg) + enum { IDD = IDD_ABOUTBOX }; + //}}AFX_DATA + + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CAboutDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + //{{AFX_MSG(CAboutDlg) + // No message handlers + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) +{ + //{{AFX_DATA_INIT(CAboutDlg) + //}}AFX_DATA_INIT +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CAboutDlg) + //}}AFX_DATA_MAP +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) + //{{AFX_MSG_MAP(CAboutDlg) + // No message handlers + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +// App command to run the dialog +void CTestApp::OnAppAbout() +{ + CAboutDlg aboutDlg; + aboutDlg.DoModal(); +} + +///////////////////////////////////////////////////////////////////////////// +// CTestApp message handlers + diff --git a/PolyhedronHouse/Test.dsp b/PolyhedronHouse/Test.dsp new file mode 100644 index 0000000..bcc3ffa --- /dev/null +++ b/PolyhedronHouse/Test.dsp @@ -0,0 +1,278 @@ +# Microsoft Developer Studio Project File - Name="Test" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=Test - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "Test.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "Test.mak" CFG="Test - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "Test - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "Test - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "Test - Win32 Release" + +# PROP BASE Use_MFC 6 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 6 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x804 /d "NDEBUG" /d "_AFXDLL" +# ADD RSC /l 0x804 /d "NDEBUG" /d "_AFXDLL" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386 +# ADD LINK32 /nologo /subsystem:windows /machine:I386 + +!ELSEIF "$(CFG)" == "Test - Win32 Debug" + +# PROP BASE Use_MFC 6 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 6 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /Yu"stdafx.h" /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x804 /d "_DEBUG" /d "_AFXDLL" +# ADD RSC /l 0x804 /d "_DEBUG" /d "_AFXDLL" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "Test - Win32 Release" +# Name "Test - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\AET.cpp +# End Source File +# Begin Source File + +SOURCE=.\Bucket.cpp +# End Source File +# Begin Source File + +SOURCE=.\Face.cpp +# End Source File +# Begin Source File + +SOURCE=.\MainFrm.cpp +# End Source File +# Begin Source File + +SOURCE=.\P2.cpp +# End Source File +# Begin Source File + +SOURCE=.\P3.cpp +# End Source File +# Begin Source File + +SOURCE=.\Pi2.cpp +# End Source File +# Begin Source File + +SOURCE=.\Pi3.cpp +# End Source File +# Begin Source File + +SOURCE=.\RGB.cpp +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.cpp +# ADD CPP /Yc"stdafx.h" +# End Source File +# Begin Source File + +SOURCE=.\Test.cpp +# End Source File +# Begin Source File + +SOURCE=.\Test.rc +# End Source File +# Begin Source File + +SOURCE=.\TestDoc.cpp +# End Source File +# Begin Source File + +SOURCE=.\TestView.cpp +# End Source File +# Begin Source File + +SOURCE=".\Transform .cpp" +# End Source File +# Begin Source File + +SOURCE=.\Vector.cpp +# End Source File +# Begin Source File + +SOURCE=.\ZBuffer.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\AET.h +# End Source File +# Begin Source File + +SOURCE=.\Bucket.h +# End Source File +# Begin Source File + +SOURCE=.\Face.h +# End Source File +# Begin Source File + +SOURCE=.\MainFrm.h +# End Source File +# Begin Source File + +SOURCE=.\P2.h +# End Source File +# Begin Source File + +SOURCE=.\P3.h +# End Source File +# Begin Source File + +SOURCE=.\Pi2.h +# End Source File +# Begin Source File + +SOURCE=.\Pi3.h +# End Source File +# Begin Source File + +SOURCE=.\Resource.h +# End Source File +# Begin Source File + +SOURCE=.\RGB.h +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# Begin Source File + +SOURCE=.\Test.h +# End Source File +# Begin Source File + +SOURCE=.\TestDoc.h +# End Source File +# Begin Source File + +SOURCE=.\TestView.h +# End Source File +# Begin Source File + +SOURCE=.\Transform.h +# End Source File +# Begin Source File + +SOURCE=.\Vector.h +# End Source File +# Begin Source File + +SOURCE=.\ZBuffer.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\RES\about.bmp +# End Source File +# Begin Source File + +SOURCE=.\res\app.ico +# End Source File +# Begin Source File + +SOURCE=.\res\draw.ico +# End Source File +# Begin Source File + +SOURCE=.\res\exit.ico +# End Source File +# Begin Source File + +SOURCE=.\res\Help.ico +# End Source File +# Begin Source File + +SOURCE=.\res\Test.ico +# End Source File +# Begin Source File + +SOURCE=.\res\Test.rc2 +# End Source File +# Begin Source File + +SOURCE=.\res\TestDoc.ico +# End Source File +# Begin Source File + +SOURCE=.\res\Toolbar.bmp +# End Source File +# End Group +# Begin Source File + +SOURCE=.\ReadMe.txt +# End Source File +# End Target +# End Project diff --git a/PolyhedronHouse/Test.dsw b/PolyhedronHouse/Test.dsw new file mode 100644 index 0000000..d4e2b94 --- /dev/null +++ b/PolyhedronHouse/Test.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "Test"=.\Test.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/PolyhedronHouse/Test.h b/PolyhedronHouse/Test.h new file mode 100644 index 0000000..15c93e0 --- /dev/null +++ b/PolyhedronHouse/Test.h @@ -0,0 +1,49 @@ +// Test.h : main header file for the TEST application +// + +#if !defined(AFX_TEST_H__687EC7D4_477F_4BD3_BCC6_BD41AD64322D__INCLUDED_) +#define AFX_TEST_H__687EC7D4_477F_4BD3_BCC6_BD41AD64322D__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#ifndef __AFXWIN_H__ + #error include 'stdafx.h' before including this file for PCH +#endif + +#include "resource.h" // main symbols + +///////////////////////////////////////////////////////////////////////////// +// CTestApp: +// See Test.cpp for the implementation of this class +// + +class CTestApp : public CWinApp +{ +public: + CTestApp(); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CTestApp) + public: + virtual BOOL InitInstance(); + //}}AFX_VIRTUAL + +// Implementation + //{{AFX_MSG(CTestApp) + afx_msg void OnAppAbout(); + // NOTE - the ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_TEST_H__687EC7D4_477F_4BD3_BCC6_BD41AD64322D__INCLUDED_) diff --git a/PolyhedronHouse/Test.ncb b/PolyhedronHouse/Test.ncb new file mode 100644 index 0000000..903b568 Binary files /dev/null and b/PolyhedronHouse/Test.ncb differ diff --git a/PolyhedronHouse/Test.opt b/PolyhedronHouse/Test.opt new file mode 100644 index 0000000..efde261 Binary files /dev/null and b/PolyhedronHouse/Test.opt differ diff --git a/PolyhedronHouse/Test.plg b/PolyhedronHouse/Test.plg new file mode 100644 index 0000000..259c176 --- /dev/null +++ b/PolyhedronHouse/Test.plg @@ -0,0 +1,16 @@ + + +
+

Build Log

+

+--------------------Configuration: Test - Win32 Debug-------------------- +

+

Command Lines

+ + + +

Results

+Test.exe - 0 error(s), 0 warning(s) +
+ + diff --git a/PolyhedronHouse/Test.positions b/PolyhedronHouse/Test.positions new file mode 100644 index 0000000..a8f3a88 Binary files /dev/null and b/PolyhedronHouse/Test.positions differ diff --git a/PolyhedronHouse/Test.rc b/PolyhedronHouse/Test.rc new file mode 100644 index 0000000..6dee2ff --- /dev/null +++ b/PolyhedronHouse/Test.rc @@ -0,0 +1,377 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Chinese (P.R.C.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS) +#ifdef _WIN32 +LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED +#pragma code_page(936) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "#define _AFX_NO_SPLITTER_RESOURCES\r\n" + "#define _AFX_NO_OLE_RESOURCES\r\n" + "#define _AFX_NO_TRACKER_RESOURCES\r\n" + "#define _AFX_NO_PROPERTY_RESOURCES\r\n" + "\r\n" + "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)\r\n" + "#ifdef _WIN32\r\n" + "LANGUAGE 4, 2\r\n" + "#pragma code_page(936)\r\n" + "#endif //_WIN32\r\n" + "#include ""res\\Test.rc2"" // non-Microsoft Visual C++ edited resources\r\n" + "#include ""l.chs\\afxres.rc"" // Standard components\r\n" + "#include ""l.chs\\afxprint.rc"" // printing/print preview resources\r\n" + "#endif\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDR_MAINFRAME ICON DISCARDABLE "res\\Test.ico" +IDR_TESTTYPE ICON DISCARDABLE "res\\TestDoc.ico" +IDI_ICON1 ICON DISCARDABLE "res\\Help.ico" +IDI_ICON2 ICON DISCARDABLE "res\\app.ico" +IDI_ICON3 ICON DISCARDABLE "res\\exit.ico" +IDI_ICON4 ICON DISCARDABLE "res\\draw.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp" +IDB_ABOUT BITMAP DISCARDABLE "res\\about.bmp" + +///////////////////////////////////////////////////////////////////////////// +// +// Toolbar +// + +IDR_MAINFRAME TOOLBAR DISCARDABLE 32, 32 +BEGIN + BUTTON ID_APP_EXIT + BUTTON IDM_PLAY + BUTTON ID_APP_ABOUT +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDR_MAINFRAME MENU PRELOAD DISCARDABLE +BEGIN + POPUP "文件(&F)" + BEGIN + MENUITEM "退出(&X)", ID_APP_EXIT + END + POPUP "绘图(&D)" + BEGIN + MENUITEM "Play", IDM_PLAY + END + POPUP "帮助(&H)" + BEGIN + MENUITEM "关于 Test(&A)...", ID_APP_ABOUT + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE +BEGIN + "N", ID_FILE_NEW, VIRTKEY, CONTROL + "O", ID_FILE_OPEN, VIRTKEY, CONTROL + "S", ID_FILE_SAVE, VIRTKEY, CONTROL + "P", ID_FILE_PRINT, VIRTKEY, CONTROL + "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL + "X", ID_EDIT_CUT, VIRTKEY, CONTROL + "C", ID_EDIT_COPY, VIRTKEY, CONTROL + "V", ID_EDIT_PASTE, VIRTKEY, CONTROL + VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT + VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT + VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL + VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT + VK_F6, ID_NEXT_PANE, VIRTKEY + VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 216, 180 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "关于 Test" +FONT 9, "宋体" +BEGIN + DEFPUSHBUTTON "确定",IDOK,85,159,50,14,WS_GROUP + CONTROL 134,IDB_BITMAP1,"Static",SS_BITMAP,7,7,200,150 +END + + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "080404B0" + BEGIN + VALUE "CompanyName", "\0" + VALUE "FileDescription", "Test Microsoft 基础类应用程序\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "Test\0" + VALUE "LegalCopyright", "版权所有 (C) 2006\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename", "Test.EXE\0" + VALUE "ProductName", "Test 应用程序\0" + VALUE "ProductVersion", "1, 0, 0, 1\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x804, 1200 + END +END + +#endif // !_MAC + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO DISCARDABLE +BEGIN + IDD_ABOUTBOX, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 208 + TOPMARGIN, 7 + BOTTOMMARGIN, 173 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE PRELOAD DISCARDABLE +BEGIN + IDR_MAINFRAME "Test\n\nTest\n\n\nTest.Document\nTest Document" +END + +STRINGTABLE PRELOAD DISCARDABLE +BEGIN + AFX_IDS_APP_TITLE "Test" + AFX_IDS_IDLEMESSAGE "就绪" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_INDICATOR_EXT "扩展名" + ID_INDICATOR_CAPS "大写" + ID_INDICATOR_NUM "数字" + ID_INDICATOR_SCRL "滚动" + ID_INDICATOR_OVR "改写" + ID_INDICATOR_REC "记录" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_FILE_NEW "建立新文档\n新建" + ID_FILE_OPEN "打开一个现有文档\n打开" + ID_FILE_CLOSE "关闭活动文档\n关闭" + ID_FILE_SAVE "保存活动文档\n保存" + ID_FILE_SAVE_AS "将活动文档以一个新文件名保存\n另存为" + ID_FILE_PAGE_SETUP "改变打印选项\n页面设置" + ID_FILE_PRINT_SETUP "改变打印机及打印选项\n打印设置" + ID_FILE_PRINT "打印活动文档\n打印" + ID_FILE_PRINT_PREVIEW "显示整页\n打印预览" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_APP_ABOUT "开发人员信息\n关于" + ID_APP_EXIT "退出应用程序\n退出" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_FILE_MRU_FILE1 "打开该文档" + ID_FILE_MRU_FILE2 "打开该文档" + ID_FILE_MRU_FILE3 "打开该文档" + ID_FILE_MRU_FILE4 "打开该文档" + ID_FILE_MRU_FILE5 "打开该文档" + ID_FILE_MRU_FILE6 "打开该文档" + ID_FILE_MRU_FILE7 "打开该文档" + ID_FILE_MRU_FILE8 "打开该文档" + ID_FILE_MRU_FILE9 "打开该文档" + ID_FILE_MRU_FILE10 "打开该文档" + ID_FILE_MRU_FILE11 "打开该文档" + ID_FILE_MRU_FILE12 "打开该文档" + ID_FILE_MRU_FILE13 "打开该文档" + ID_FILE_MRU_FILE14 "打开该文档" + ID_FILE_MRU_FILE15 "打开该文档" + ID_FILE_MRU_FILE16 "打开该文档" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_NEXT_PANE "切换到下一个窗格\n下一窗格" + ID_PREV_PANE "切换回前一个窗格\n前一窗格" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_WINDOW_SPLIT "将活动的窗口分隔成窗格\n分隔" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_EDIT_CLEAR "删除被选对象\n删除" + ID_EDIT_CLEAR_ALL "全部删除\n全部删除" + ID_EDIT_COPY "复制被选对象并将其置于剪贴板上\n复制" + ID_EDIT_CUT "剪切被选对象并将其置于剪贴板上\n剪切" + ID_EDIT_FIND "查找指定的正文\n查找" + ID_EDIT_PASTE "插入剪贴板内容\n粘贴" + ID_EDIT_REPEAT "重复上一步操作\n重复" + ID_EDIT_REPLACE "用不同的正文替换指定的正文\n替换" + ID_EDIT_SELECT_ALL "选择整个文档\n选择全部" + ID_EDIT_UNDO "撤消最后一步操作\n撤消" + ID_EDIT_REDO "重新执行先前已撤消的操作\n重新执行" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_VIEW_TOOLBAR "显示或隐藏工具栏\n显隐工具栏" + ID_VIEW_STATUS_BAR "显示或隐藏状态栏\n显隐状态栏" +END + +STRINGTABLE DISCARDABLE +BEGIN + AFX_IDS_SCSIZE "改变窗口大小" + AFX_IDS_SCMOVE "改变窗口位置" + AFX_IDS_SCMINIMIZE "将窗口缩小成图标" + AFX_IDS_SCMAXIMIZE "把窗口放大到最大尺寸" + AFX_IDS_SCNEXTWINDOW "切换到下一个文档窗口" + AFX_IDS_SCPREVWINDOW "切换到先前的文档窗口" + AFX_IDS_SCCLOSE "关闭活动的窗口并提示保存所有文档" +END + +STRINGTABLE DISCARDABLE +BEGIN + AFX_IDS_SCRESTORE "把窗口恢复到正常大小" + AFX_IDS_SCTASKLIST "激活任务表" +END + +STRINGTABLE DISCARDABLE +BEGIN + AFX_IDS_PREVIEW_CLOSE "关闭打印预览模式\n取消预阅" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_MENUPlay "动画演示\n动画" +END + +STRINGTABLE DISCARDABLE +BEGIN + IDM_PLAY "动画演示\n动画" +END + +#endif // Chinese (P.R.C.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +#define _AFX_NO_SPLITTER_RESOURCES +#define _AFX_NO_OLE_RESOURCES +#define _AFX_NO_TRACKER_RESOURCES +#define _AFX_NO_PROPERTY_RESOURCES + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS) +#ifdef _WIN32 +LANGUAGE 4, 2 +#pragma code_page(936) +#endif //_WIN32 +#include "res\Test.rc2" // non-Microsoft Visual C++ edited resources +#include "l.chs\afxres.rc" // Standard components +#include "l.chs\afxprint.rc" // printing/print preview resources +#endif + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/PolyhedronHouse/Test.sdf b/PolyhedronHouse/Test.sdf new file mode 100644 index 0000000..a6abb44 Binary files /dev/null and b/PolyhedronHouse/Test.sdf differ diff --git a/PolyhedronHouse/Test.sln b/PolyhedronHouse/Test.sln new file mode 100644 index 0000000..03078f3 --- /dev/null +++ b/PolyhedronHouse/Test.sln @@ -0,0 +1,20 @@ +锘� +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test", "Test.vcxproj", "{E775224E-9A87-D355-D27F-226ABBCB72AA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E775224E-9A87-D355-D27F-226ABBCB72AA}.Debug|Win32.ActiveCfg = Debug|Win32 + {E775224E-9A87-D355-D27F-226ABBCB72AA}.Debug|Win32.Build.0 = Debug|Win32 + {E775224E-9A87-D355-D27F-226ABBCB72AA}.Release|Win32.ActiveCfg = Release|Win32 + {E775224E-9A87-D355-D27F-226ABBCB72AA}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/PolyhedronHouse/Test.suo b/PolyhedronHouse/Test.suo new file mode 100644 index 0000000..f03d2b1 Binary files /dev/null and b/PolyhedronHouse/Test.suo differ diff --git a/PolyhedronHouse/Test.vcxproj b/PolyhedronHouse/Test.vcxproj new file mode 100644 index 0000000..50506a3 --- /dev/null +++ b/PolyhedronHouse/Test.vcxproj @@ -0,0 +1,197 @@ +锘� + + + + Debug + Win32 + + + Release + Win32 + + + + + + MFCProj + {E775224E-9A87-D355-D27F-226ABBCB72AA} + 10.0 + + + + Application + Dynamic + MultiByte + v143 + + + Application + Dynamic + MultiByte + v143 + + + + + + + + + + + + + + + .\Release\ + .\Release\ + false + + + .\Debug\ + .\Debug\ + true + + + + MultiThreadedDLL + OnlyExplicitInline + true + true + MaxSpeed + true + Level3 + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + .\Release\ + .\Release\Test.pch + Use + stdafx.h + .\Release\ + .\Release\ + + + true + NDEBUG;%(PreprocessorDefinitions) + .\Release\Test.tlb + true + Win32 + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + + + true + .\Release\Test.bsc + + + true + Windows + .\Release\Test.exe + + + + + MultiThreadedDebugDLL + Default + true + Disabled + true + Level3 + true + EditAndContinue + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + .\Debug\ + true + .\Debug\Test.pch + Use + stdafx.h + .\Debug\ + .\Debug\ + EnableFastChecks + + + true + _DEBUG;%(PreprocessorDefinitions) + .\Debug\Test.tlb + true + Win32 + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + + + true + .\Debug\Test.bsc + + + true + true + Windows + .\Debug\Test.exe + + + + + + + + + + + + + + Create + stdafx.h + Create + stdafx.h + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RC + + + + + + + + + \ No newline at end of file diff --git a/PolyhedronHouse/Test.vcxproj.filters b/PolyhedronHouse/Test.vcxproj.filters new file mode 100644 index 0000000..ee257ad --- /dev/null +++ b/PolyhedronHouse/Test.vcxproj.filters @@ -0,0 +1,155 @@ +锘� + + + + {0c9175ef-f708-4c6d-ae5b-0a09125507c8} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {1a22d2c6-3abe-4d80-9e17-2e50248c417b} + h;hpp;hxx;hm;inl + + + {e833959b-a75e-4bf0-b678-825608f000e0} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + + \ No newline at end of file diff --git a/PolyhedronHouse/Test.vcxproj.user b/PolyhedronHouse/Test.vcxproj.user new file mode 100644 index 0000000..ace9a86 --- /dev/null +++ b/PolyhedronHouse/Test.vcxproj.user @@ -0,0 +1,3 @@ +锘� + + \ No newline at end of file diff --git a/PolyhedronHouse/TestDoc.cpp b/PolyhedronHouse/TestDoc.cpp new file mode 100644 index 0000000..b35f16f --- /dev/null +++ b/PolyhedronHouse/TestDoc.cpp @@ -0,0 +1,84 @@ +// TestDoc.cpp : implementation of the CTestDoc class +// + +#include "stdafx.h" +#include "Test.h" + +#include "TestDoc.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CTestDoc + +IMPLEMENT_DYNCREATE(CTestDoc, CDocument) + +BEGIN_MESSAGE_MAP(CTestDoc, CDocument) + //{{AFX_MSG_MAP(CTestDoc) + // NOTE - the ClassWizard will add and remove mapping macros here. + // DO NOT EDIT what you see in these blocks of generated code! + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CTestDoc construction/destruction + +CTestDoc::CTestDoc() +{ + // TODO: add one-time construction code here + +} + +CTestDoc::~CTestDoc() +{ +} + +BOOL CTestDoc::OnNewDocument() +{ + if (!CDocument::OnNewDocument()) + return FALSE; + + // TODO: add reinitialization code here + // (SDI documents will reuse this document) + + return TRUE; +} + + + +///////////////////////////////////////////////////////////////////////////// +// CTestDoc serialization + +void CTestDoc::Serialize(CArchive& ar) +{ + if (ar.IsStoring()) + { + // TODO: add storing code here + } + else + { + // TODO: add loading code here + } +} + +///////////////////////////////////////////////////////////////////////////// +// CTestDoc diagnostics + +#ifdef _DEBUG +void CTestDoc::AssertValid() const +{ + CDocument::AssertValid(); +} + +void CTestDoc::Dump(CDumpContext& dc) const +{ + CDocument::Dump(dc); +} +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CTestDoc commands diff --git a/PolyhedronHouse/TestDoc.h b/PolyhedronHouse/TestDoc.h new file mode 100644 index 0000000..2638266 --- /dev/null +++ b/PolyhedronHouse/TestDoc.h @@ -0,0 +1,57 @@ +// TestDoc.h : interface of the CTestDoc class +// +///////////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_TESTDOC_H__72DBD624_92AB_462A_B0FD_D3F54BA45097__INCLUDED_) +#define AFX_TESTDOC_H__72DBD624_92AB_462A_B0FD_D3F54BA45097__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + + +class CTestDoc : public CDocument +{ +protected: // create from serialization only + CTestDoc(); + DECLARE_DYNCREATE(CTestDoc) + +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CTestDoc) + public: + virtual BOOL OnNewDocument(); + virtual void Serialize(CArchive& ar); + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CTestDoc(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + +// Generated message map functions +protected: + //{{AFX_MSG(CTestDoc) + // NOTE - the ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_TESTDOC_H__72DBD624_92AB_462A_B0FD_D3F54BA45097__INCLUDED_) diff --git a/PolyhedronHouse/TestView.cpp b/PolyhedronHouse/TestView.cpp new file mode 100644 index 0000000..9336746 --- /dev/null +++ b/PolyhedronHouse/TestView.cpp @@ -0,0 +1,375 @@ +// TestView.cpp : implementation of the CTestView class +// + +#include "stdafx.h" +#include "Test.h" +#include "TestDoc.h" +#include "TestView.h" +#include "math.h" +#define Round(d) int(floor(d + 0.5)) // 四舍五入宏定义 +#define PI 3.1415926 // 圆周率 +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CTestView + +IMPLEMENT_DYNCREATE(CTestView, CView) + +BEGIN_MESSAGE_MAP(CTestView, CView) +//{{AFX_MSG_MAP(CTestView) +ON_WM_LBUTTONDOWN() +ON_WM_RBUTTONDBLCLK() +ON_WM_TIMER() +ON_WM_KEYDOWN() +ON_WM_ERASEBKGND() +ON_COMMAND(IDM_PLAY, OnPlay) +ON_UPDATE_COMMAND_UI(IDM_PLAY, OnUpdatePlay) +//}}AFX_MSG_MAP +// Standard printing commands +ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) +ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) +ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CTestView construction/destruction + +CTestView::CTestView() { + // TODO: add construction code here + bPlay = FALSE; + R = 1000.0, d = 800.0, Phi = 90.0, Theta = 0.0; // 视点位于正前方 + Near = 800.0, Far = 1200.0; // 近剪切面与远剪切面 + Alpha = 0.0; + Beta = 0.0; +} + +CTestView::~CTestView() { +} + +BOOL CTestView::PreCreateWindow(CREATESTRUCT &cs) { + // TODO: Modify the Window class or styles here by modifying + // the CREATESTRUCT cs + + return CView::PreCreateWindow(cs); +} + +///////////////////////////////////////////////////////////////////////////// +// CTestView drawing + +void CTestView::OnDraw(CDC *pDC) { + CTestDoc *pDoc = GetDocument(); + ASSERT_VALID(pDoc); + // TODO: add draw code for native data here + DoubleBuffer(); +} + +///////////////////////////////////////////////////////////////////////////// +// CTestView printing + +BOOL CTestView::OnPreparePrinting(CPrintInfo *pInfo) { + // default preparation + return DoPreparePrinting(pInfo); +} + +void CTestView::OnBeginPrinting(CDC * /*pDC*/, CPrintInfo * /*pInfo*/) { + // TODO: add extra initialization before printing +} + +void CTestView::OnEndPrinting(CDC * /*pDC*/, CPrintInfo * /*pInfo*/) { + // TODO: add cleanup after printing +} + +///////////////////////////////////////////////////////////////////////////// +// CTestView diagnostics + +#ifdef _DEBUG +void CTestView::AssertValid() const { + CView::AssertValid(); +} + +void CTestView::Dump(CDumpContext &dc) const { + CView::Dump(dc); +} + +CTestDoc *CTestView::GetDocument() // non-debug version is inline +{ + ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTestDoc))); + return (CTestDoc *)m_pDocument; +} +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CTestView message handlers + +void CTestView::ReadVertex() // 点表 +{ + // 顶点的三维坐标(x,y,z),立方体边长为2a + double a = 150; + V[0].z = 0; + V[0].x = 0; + V[0].y = 0; + V[1].z = 100; + V[1].x = 0; + V[1].y = 0; + V[2].z = 100; + V[2].x = 200; + V[2].y = 0; + V[3].z = 0; + V[3].x = 200; + V[3].y = 0; + V[4].z = 0; + V[4].x = 0; + V[4].y = 100; + V[5].z = 100; + V[5].x = 0; + V[5].y = 100; + V[6].z = 100; + V[6].x = 200; + V[6].y = 100; + V[7].z = 0; + V[7].x = 200; + V[7].y = 100; + V[8].z = 50; + V[8].x = 0; + V[8].y = 150; + V[9].z = 50; + V[9].x = 200; + V[9].y = 150; +} + +void CTestView::ReadFace() // 面表 +{ + // 面的顶点数、面的顶点索引号与面的颜色 + F[0].SetNum(4); + F[0].vI[0] = 1; + F[0].vI[1] = 2; + F[0].vI[2] = 6; + F[0].vI[3] = 5; // 前面 + F[1].SetNum(4); + F[1].vI[0] = 0; + F[1].vI[1] = 4; + F[1].vI[2] = 7; + F[1].vI[3] = 3; // 后面 + F[2].SetNum(5); + F[2].vI[0] = 0; + F[2].vI[1] = 1; + F[2].vI[2] = 5; + F[2].vI[3] = 8; + F[2].vI[4] = 4; // 左面 + F[3].SetNum(5); + F[3].vI[0] = 2; + F[3].vI[1] = 3; + F[3].vI[2] = 7; + F[3].vI[3] = 9; + F[3].vI[4] = 6; // 右面 + F[4].SetNum(4); + F[4].vI[0] = 4; + F[4].vI[1] = 8; + F[4].vI[2] = 9; + F[4].vI[3] = 7; // 顶面1 + F[5].SetNum(4); + F[5].vI[0] = 0; + F[5].vI[1] = 3; + F[5].vI[2] = 2; + F[5].vI[3] = 1; // 底面 + F[6].SetNum(4); + F[6].vI[0] = 5; + F[6].vI[1] = 6; + F[6].vI[2] = 9; + F[6].vI[3] = 8; // 顶面2 + + F[0].fClr = CRGB(0.98, 0.68, 0.48); + F[1].fClr = CRGB(0.29, 0.58, 0.38); + F[2].fClr = CRGB(0.69, 0.27, 0.88); + F[3].fClr = CRGB(0.92, 0.78, 0.68); + F[4].fClr = CRGB(0.49, 0.38, 0.28); + F[5].fClr = CRGB(0.89, 0.78, 0.68); + F[6].fClr = CRGB(0.39, 0.28, 0.18); +} + +void CTestView::InitParameter() // 透视变换参数初始化 +{ + k[1] = sin(PI * Theta / 180); + k[2] = sin(PI * Phi / 180); + k[3] = cos(PI * Theta / 180); + k[4] = cos(PI * Phi / 180); + k[5] = k[2] * k[3]; + k[6] = k[2] * k[1]; + k[7] = k[4] * k[3]; + k[8] = k[4] * k[1]; + ViewPoint.x = R * k[6]; // 用户坐标系的视点球坐标 + ViewPoint.y = R * k[4]; + ViewPoint.z = R * k[5]; +} + +void CTestView::PerProject(CP3 P) // 透视变换 +{ + CP3 ViewP; + ViewP.x = k[3] * P.x - k[1] * P.z; // 观察坐标系三维坐标 + ViewP.y = -k[8] * P.x + k[2] * P.y - k[7] * P.z; + ViewP.z = -k[6] * P.x - k[4] * P.y - k[5] * P.z + R; + ScreenP.x = d * ViewP.x / ViewP.z; // 屏幕坐标系三维坐标 + ScreenP.y = Round(d * ViewP.y / ViewP.z); + ScreenP.z = Far * (1 - Near / ViewP.z) / (Far - Near); +} + +void CTestView::DoubleBuffer() // 双缓冲 +{ + CDC *pDC = GetDC(); + CRect rect; // 定义客户区 + GetClientRect(&rect); // 获得客户区的大小 + pDC->SetMapMode(MM_ANISOTROPIC); // pDC自定义坐标系 + pDC->SetWindowExt(rect.Width(), rect.Height()); // 设置窗口范围 + pDC->SetViewportExt(rect.Width(), -rect.Height()); // x轴水平向右,y轴垂直向上 + pDC->SetViewportOrg(rect.Width() / 2, rect.Height() / 2); // 屏幕中心为原点 + CDC MemDC; // 内存DC + CBitmap NewBitmap, *pOldBitmap; // 内存中承载图像的临时位图 + MemDC.CreateCompatibleDC(pDC); // 建立与屏幕pDC兼容的MemDC + NewBitmap.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height()); // 创建兼容位图 + pOldBitmap = MemDC.SelectObject(&NewBitmap); // 将兼容位图选入MemDC + MemDC.FillSolidRect(&rect, pDC->GetBkColor()); // 按原来背景填充客户区,否则是黑色 + MemDC.SetMapMode(MM_ANISOTROPIC); // MemDC自定义坐标系 + MemDC.SetWindowExt(rect.Width(), rect.Height()); + MemDC.SetViewportExt(rect.Width(), -rect.Height()); + MemDC.SetViewportOrg(rect.Width() / 2, rect.Height() / 2); + DrawObject(&MemDC); + pDC->BitBlt(-rect.Width() / 2, -rect.Height() / 2, rect.Width(), rect.Height(), &MemDC, -rect.Width() / 2, -rect.Height() / 2, SRCCOPY); // 将内存位图拷贝到屏幕 + MemDC.SelectObject(pOldBitmap); // 恢复位图 + NewBitmap.DeleteObject(); // 删除位图 + ReleaseDC(pDC); // 释放DC +} + +void CTestView::DrawObject(CDC *pDC) { + CPi3 Point[5]; // 透视投影后面的二维顶点数组 + CZBuffer *zbuf = new CZBuffer; // 申请内存 + zbuf->InitDeepBuffer(1000, 1000, 1000); // 初始化深度缓存器 + for (int nFace = 0; nFace < 7; nFace++) // 面循环 + { + // 计算视向量和面法向量,判断是否需要绘制 + CP3 p0 = V[F[nFace].vI[0]]; + CP3 p1 = V[F[nFace].vI[1]]; + CP3 p2 = V[F[nFace].vI[2]]; + + // 计算视向量 + CVector ViewVector(p0, ViewPoint); + ViewVector = ViewVector.Normalize(); + + // 计算面法向量 + CFace f; + f.SetFaceNormal(p0, p1, p2); + f.fNormal.Normalize(); + + // 如果视向量和法向量的点积大于等于0,说明面朝向观察者,需要绘制 + if (Dot(ViewVector, f.fNormal) >= 0) { + for (int nVertex = 0; nVertex < F[nFace].vN; nVertex++) // 顶点循环 + { + PerProject(V[F[nFace].vI[nVertex]]); // 透视投影 + Point[nVertex] = ScreenP; + Point[nVertex].c = F[nFace].fClr; + } + zbuf->SetPoint(Point, F[nFace].vN); // 设置顶点 + zbuf->CreateBucket(); // 建立桶表 + zbuf->CreateEdge(); // 建立边表 + zbuf->Gouraud(pDC); // 填充多边形 + zbuf->ClearMemory(); // 内存清理 + } + } + delete zbuf; // 释放内存 +} + +void CTestView::OnLButtonDown(UINT nFlags, CPoint point) // 鼠标左键函数 +{ + // TODO: Add your message handler code here and/or call default + R = R + 100; + InitParameter(); + Invalidate(FALSE); + CView::OnLButtonDown(nFlags, point); +} + +void CTestView::OnRButtonDblClk(UINT nFlags, CPoint point) // 鼠标右键函数 +{ + // TODO: Add your message handler code here and/or call default + R = R - 100; + InitParameter(); + Invalidate(FALSE); + CView::OnRButtonDblClk(nFlags, point); +} + +void CTestView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { + // TODO: Add your message handler code here and/or call default + if (!bPlay) { + switch (nChar) { + case VK_UP: + Alpha = -5; + tran.RotateX(Alpha); + break; + case VK_DOWN: + Alpha = 5; + tran.RotateX(Alpha); + break; + case VK_LEFT: + Beta = -5; + tran.RotateY(Beta); + break; + case VK_RIGHT: + Beta = 5; + tran.RotateY(Beta); + break; + default: + break; + } + Invalidate(FALSE); + } + CView::OnKeyDown(nChar, nRepCnt, nFlags); +} + +void CTestView::OnTimer(UINT nIDEvent) // 动画时间函数 +{ + // TODO: Add your message handler code here and/or call default + // Phi-=5;//设定步长 + Theta -= 5; + InitParameter(); + Invalidate(FALSE); + CView::OnTimer(nIDEvent); +} + +void CTestView::OnPlay() // 菜单函数 +{ + // TODO: Add your command handler code here + bPlay = bPlay ? FALSE : TRUE; + if (bPlay) // 设置定时器 + SetTimer(1, 150, NULL); + else + KillTimer(1); +} + +void CTestView::OnUpdatePlay(CCmdUI *pCmdUI) // 菜单控制函数 +{ + // TODO: Add your command update UI handler code here + if (bPlay) { + pCmdUI->SetCheck(TRUE); + pCmdUI->SetText("停止"); + } + else { + pCmdUI->SetCheck(FALSE); + pCmdUI->SetText("开始"); + } +} + +BOOL CTestView::OnEraseBkgnd(CDC *pDC) { + // TODO: Add your message handler code here and/or call default + return TRUE; +} + +void CTestView::OnInitialUpdate() { + CView::OnInitialUpdate(); + // TODO: Add your specialized code here and/or call the base class + ReadVertex(); + ReadFace(); + tran.SetMat(V, 8); + InitParameter(); +} diff --git a/PolyhedronHouse/TestView.h b/PolyhedronHouse/TestView.h new file mode 100644 index 0000000..5f2b3ce --- /dev/null +++ b/PolyhedronHouse/TestView.h @@ -0,0 +1,90 @@ +// TestView.h : interface of the CTestView class +// +///////////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_TESTVIEW_H__A75FDCFB_621C_4E38_A154_C344803E6372__INCLUDED_) +#define AFX_TESTVIEW_H__A75FDCFB_621C_4E38_A154_C344803E6372__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +#include "Face.h" +#include "ZBuffer.h" +#include "Transform.h" + +class CTestView : public CView +{ +protected: // create from serialization only + CTestView(); + DECLARE_DYNCREATE(CTestView) + +// Attributes +public: + CTestDoc* GetDocument(); + +// Operations +public: + void ReadVertex();//读入点表 + void ReadFace();//读入面表 + void InitParameter();//参数初始化 + void PerProject(CP3);//透视投影 + void DoubleBuffer();//双缓冲绘图 + void DrawObject(CDC *);//绘制立方体表面 +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CTestView) + public: + virtual void OnDraw(CDC* pDC); // overridden to draw this view + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + virtual void OnInitialUpdate(); + protected: + virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); + virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); + virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CTestView(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + CP3 V[10];//点表 + CFace F[7];//面表 + double R,Theta,Phi;//视点在用户坐标系中的球坐标 + double d;//视距 + double Near,Far;//远近剪切面 + double k[9];//运算常量 + CP3 ViewPoint;//视点球坐标 + CPi3 ScreenP;//屏幕坐标系的三维坐标点 + BOOL bPlay;//动画开关 + double Alpha,Beta;//x方向旋转α角,y方向旋转β角 + CTransform tran;//变换对象 + // Generated message map functions +protected: + //{{AFX_MSG(CTestView) + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point); + afx_msg void OnTimer(UINT nIDEvent); + afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + afx_msg void OnPlay(); + afx_msg void OnUpdatePlay(CCmdUI* pCmdUI); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +#ifndef _DEBUG // debug version in TestView.cpp +inline CTestDoc* CTestView::GetDocument() + { return (CTestDoc*)m_pDocument; } +#endif + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_TESTVIEW_H__A75FDCFB_621C_4E38_A154_C344803E6372__INCLUDED_) diff --git a/PolyhedronHouse/Transform .cpp b/PolyhedronHouse/Transform .cpp new file mode 100644 index 0000000..1a3c445 --- /dev/null +++ b/PolyhedronHouse/Transform .cpp @@ -0,0 +1,200 @@ +// Transform.cpp: implementation of the CTransForm class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "Test.h" +#include "Transform.h" +#include "math.h" +#define PI 3.14159 +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CTransform::CTransform() +{ + +} + +CTransform::~CTransform() +{ + +} + +void CTransform::SetMat(CP3 *p,int n) +{ + POld=p; + num=n; +} + +void CTransform::Identity()//单位矩阵 +{ + T[0][0]=1.0;T[0][1]=0.0;T[0][2]=0.0;T[0][3]=0.0; + T[1][0]=0.0;T[1][1]=1.0;T[1][2]=0.0;T[1][3]=0.0; + T[2][0]=0.0;T[2][1]=0.0;T[2][2]=1.0;T[2][3]=0.0; + T[3][0]=0.0;T[3][1]=0.0;T[3][2]=0.0;T[3][3]=1.0; +} + +void CTransform::Translate(double tx,double ty,double tz)//平移变换矩阵 +{ + Identity(); + T[3][0]=tx; + T[3][1]=ty; + T[3][2]=tz; + MultiMatrix(); +} + +void CTransform::Scale(double sx,double sy,double sz)//比例变换矩阵 +{ + Identity(); + T[0][0]=sx; + T[1][1]=sy; + T[2][2]=sz; + MultiMatrix(); +} + +void CTransform::Scale(double sx,double sy,double sz,CP3 p)//相对于任意点的比例变换矩阵 +{ + Translate(-p.x,-p.y,-p.z); + Scale(sx,sy,sz); + Translate(p.x,p.y,p.z); +} + +void CTransform::RotateX(double beta)//绕X轴旋转变换矩阵 +{ + Identity(); + double rad=beta*PI/180; + T[1][1]=cos(rad); T[1][2]=sin(rad); + T[2][1]=-sin(rad);T[2][2]=cos(rad); + MultiMatrix(); +} + +void CTransform::RotateX(double beta,CP3 p)//相对于任意点的绕X轴旋转变换矩阵 +{ + Translate(-p.x,-p.y,-p.z); + RotateX(beta); + Translate(p.x,p.y,p.z); +} + +void CTransform::RotateY(double beta)//绕Y轴旋转变换矩阵 +{ + Identity(); + double rad=beta*PI/180; + T[0][0]=cos(rad);T[0][2]=-sin(rad); + T[2][0]=sin(rad);T[2][2]=cos(rad); + MultiMatrix(); +} + +void CTransform::RotateY(double beta,CP3 p)//相对于任意点的绕Y轴旋转变换矩阵 +{ + Translate(-p.x,-p.y,-p.z); + RotateY(beta); + Translate(p.x,p.y,p.z); +} + +void CTransform::RotateZ(double beta)//绕Z轴旋转变换矩阵 +{ + Identity(); + double rad=beta*PI/180; + T[0][0]=cos(rad); T[0][1]=sin(rad); + T[1][0]=-sin(rad);T[1][1]=cos(rad); + MultiMatrix(); +} + +void CTransform::RotateZ(double beta,CP3 p)//相对于任意点的绕Z轴旋转变换矩阵 +{ + Translate(-p.x,-p.y,-p.z); + RotateZ(beta); + Translate(p.x,p.y,p.z); +} + +void CTransform::ReflectX()//X轴反射变换矩阵 +{ + Identity(); + T[1][1]=-1; + T[2][2]=-1; + MultiMatrix(); +} + +void CTransform::ReflectY()//Y轴反射变换矩阵 +{ + Identity(); + T[0][0]=-1; + T[2][2]=-1; + MultiMatrix(); +} + +void CTransform::ReflectZ()//Z轴反射变换矩阵 +{ + Identity(); + T[0][0]=-1; + T[1][1]=-1; + MultiMatrix(); +} + +void CTransform::ReflectXOY()//XOY面反射变换矩阵 +{ + Identity(); + T[2][2]=-1; + MultiMatrix(); +} + +void CTransform::ReflectYOZ()//YOZ面反射变换矩阵 +{ + Identity(); + T[0][0]=-1; + MultiMatrix(); +} + +void CTransform::ReflectZOX()//ZOX面反射变换矩阵 +{ + Identity(); + T[1][1]=-1; + MultiMatrix(); +} + +void CTransform::ShearX(double d,double g)//X方向错切变换矩阵 +{ + Identity(); + T[1][0]=d; + T[2][0]=g; + MultiMatrix(); +} + +void CTransform::ShearY(double b,double h)//Y方向错切变换矩阵 +{ + Identity(); + T[0][1]=b; + T[2][1]=h; + MultiMatrix(); +} + +void CTransform::ShearZ(double c,double f)//Z方向错切变换矩阵 +{ + Identity(); + T[0][2]=c; + T[1][2]=f; + MultiMatrix(); +} +void CTransform::MultiMatrix()//矩阵相乘 +{ + CP3 *PNew=new CP3[num]; + for(int i=0;i 1000 +#pragma once +#endif // _MSC_VER > 1000 +#include "P3.h" + +class CTransform//三维变换 +{ +public: + CTransform(); + virtual ~CTransform(); + void SetMat(CP3 *,int); + void Identity(); + void Translate(double,double,double);//平移变换矩阵 + void Scale(double,double,double);//比例变换矩阵 + void Scale(double,double,double,CP3);//相对于任意点的比例变换矩阵 + void RotateX(double);//旋转变换矩阵 + void RotateX(double,CP3);//相对于任意点的X旋转变换矩阵 + void RotateY(double);//旋转变换矩阵 + void RotateY(double,CP3);//相对于任意点的Y旋转变换矩阵 + void RotateZ(double);//旋转变换矩阵 + void RotateZ(double,CP3);//相对于任意点的Z旋转变换矩阵 + void ReflectX();//X轴反射变换矩阵 + void ReflectY();//Y轴反射变换矩阵 + void ReflectZ();//Z轴反射变换矩阵 + void ReflectXOY();//XOY面反射变换矩阵 + void ReflectYOZ();//YOZ面反射变换矩阵 + void ReflectZOX();//ZOX面反射变换矩阵 + void ShearX(double,double);//X方向错切变换矩阵 + void ShearY(double,double);//Y方向错切变换矩阵 + void ShearZ(double,double);//Z方向错切变换矩阵 + void MultiMatrix();//矩阵相乘 +public: + double T[4][4]; + CP3 *POld; + int num; +}; +#endif // !defined(AFX_TRANSFORM_H__C4FA86B2_0AF5_409A_94EB_B02A1EE13E05__INCLUDED_) diff --git a/PolyhedronHouse/Vector.cpp b/PolyhedronHouse/Vector.cpp new file mode 100644 index 0000000..8ef8d99 --- /dev/null +++ b/PolyhedronHouse/Vector.cpp @@ -0,0 +1,175 @@ +// Vector.cpp: implementation of the CVector class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "Test.h" +#include "Vector.h" +#include "math.h" +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CVector::CVector()//z轴正向 +{ + x=0.0; + y=0.0; + z=1.0; +} + +CVector::~CVector() +{ + +} + +CVector::CVector(const CP3 &p) +{ + x=p.x; + y=p.y; + z=p.z; +} + +CVector::CVector(const CPi3 &p) +{ + x=p.x; + y=p.y; + z=p.z; +} + +CVector::CVector(double x,double y,double z) +{ + this->x=x; + this->y=y; + this->z=z; +} + +CVector::CVector(const CP3 &p0,const CP3 &p1) +{ + x=p1.x-p0.x; + y=p1.y-p0.y; + z=p1.z-p0.z; +} + +CVector::CVector(const CPi3 &p0,const CPi3 &p1) +{ + x=p1.x-p0.x; + y=p1.y-p0.y; + z=p1.z-p0.z; +} + +double CVector::Mag()//矢量的模 +{ + return sqrt(x*x+y*y+z*z); +} + +CVector CVector::Normalize()//归一化到单位矢量 +{ + CVector vector; + double Mag=sqrt(x*x+y*y+z*z); + if(fabs(Mag)<1e-6) + Mag=1.0; + vector.x=x/Mag; + vector.y=y/Mag; + vector.z=z/Mag; + return vector; +} + +CVector operator +(const CVector &v0,const CVector &v1)//矢量的和 +{ + CVector vector; + vector.x=v0.x+v1.x; + vector.y=v0.y+v1.y; + vector.z=v0.z+v1.z; + return vector; +} + +CVector operator -(const CVector &v0,const CVector &v1)//矢量的差 +{ + CVector vector; + vector.x=v0.x-v1.x; + vector.y=v0.y-v1.y; + vector.z=v0.z-v1.z; + return vector; +} + +CVector operator *(const CVector &v,double k)//矢量与常量的积 +{ + CVector vector; + vector.x=v.x*k; + vector.y=v.y*k; + vector.z=v.z*k; + return vector; +} + +CVector operator *(double k,const CVector &v)//常量与矢量的积 +{ + CVector vector; + vector.x=v.x*k; + vector.y=v.y*k; + vector.z=v.z*k; + return vector; +} + +CVector operator /(const CVector &v,double k)//矢量数除 +{ + if(fabs(k)<1e-6) + k=1.0; + CVector vector; + vector.x=v.x/k; + vector.y=v.y/k; + vector.z=v.z/k; + return vector; +} + +CVector operator +=(CVector &v0,CVector &v1)//+=运算符重载 +{ + v0.x=v0.x+v1.x; + v0.y=v0.y+v1.y; + v0.z=v0.z+v1.z; + return v1; +} + +CVector operator -=(CVector &v0,CVector &v1)//-=运算符重载 +{ + v0.x=v0.x-v1.x; + v0.y=v0.y-v1.y; + v0.z=v0.z-v1.z; + return v0; +} + +CVector operator *=(CVector &v0,CVector &v1)//*=运算符重载 +{ + v0.x=v0.x*v1.x; + v0.y=v0.y*v1.y; + v0.z=v0.z*v1.z; + return v0; +} + +CVector operator /=(CVector &v,double k)///=运算符重载 +{ + v.x=v.x/k; + v.y=v.y/k; + v.z=v.z/k; + return v; +} + +double Dot(const CVector &v0,const CVector &v1)//矢量的点积 +{ + return(v0.x*v1.x+v0.y*v1.y+v0.z*v1.z); +} + +CVector Cross(const CVector &v0,const CVector &v1)//矢量的叉积 +{ + CVector vector; + vector.x=v0.y*v1.z-v0.z*v1.y; + vector.y=v0.z*v1.x-v0.x*v1.z; + vector.z=v0.x*v1.y-v0.y*v1.x; + return vector; +} + diff --git a/PolyhedronHouse/Vector.h b/PolyhedronHouse/Vector.h new file mode 100644 index 0000000..b73f04b --- /dev/null +++ b/PolyhedronHouse/Vector.h @@ -0,0 +1,41 @@ +// Vector.h: interface for the CVector class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_VECTOR_H__8C972371_1C22_4E15_A2A8_3CE42319C9CB__INCLUDED_) +#define AFX_VECTOR_H__8C972371_1C22_4E15_A2A8_3CE42319C9CB__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +#include "P3.h" +#include "Pi3.h" + +class CVector +{ +public: + CVector(); + virtual ~CVector(); + CVector(double x,double y,double z); + CVector(const CP3 &); + CVector(const CPi3 &); + CVector(const CP3 &,const CP3 &); + CVector(const CPi3 &,const CPi3 &); + double Mag();//矢量的模 + CVector Normalize();//单位矢量 + friend CVector operator +(const CVector &,const CVector &);//运算符重载 + friend CVector operator -(const CVector &,const CVector &); + friend CVector operator *(const CVector &,double); + friend CVector operator *(double,const CVector &); + friend CVector operator /(const CVector &,double); + friend CVector operator+=(CVector &,CVector &); + friend CVector operator-=(CVector &,CVector &); + friend CVector operator*=(CVector &,CVector &); + friend CVector operator/=(CVector &,double); + friend double Dot(const CVector &,const CVector &); //矢量点积 + friend CVector Cross(const CVector &,const CVector &);//矢量叉积 +public: + double x,y,z;//公有数据成员,方便外部访问 +}; + +#endif // !defined(AFX_VECTOR_H__8C972371_1C22_4E15_A2A8_3CE42319C9CB__INCLUDED_) diff --git a/PolyhedronHouse/ZBuffer.cpp b/PolyhedronHouse/ZBuffer.cpp new file mode 100644 index 0000000..373b8ae --- /dev/null +++ b/PolyhedronHouse/ZBuffer.cpp @@ -0,0 +1,348 @@ +// ZBuffer.cpp: implementation of the CZBuffer class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "Test.h" +#include "ZBuffer.h" +#include "math.h" +#define Round(d) int(floor(d+0.5))//四舍五入宏定义 +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CZBuffer::CZBuffer() +{ + P=NULL; + pHeadE=NULL; + pCurrentB=NULL; + pEdge=NULL; + pCurrentE=NULL; + pHeadB=NULL; + zBuffer=NULL; +} + +CZBuffer::~CZBuffer() +{ + if(P!=NULL) + { + delete []P; + P=NULL; + } + for(int i=0;iyMax) + yMax=P[i].y;//扫描线的最大值 + } + for(int y=yMin;y<=yMax;y++) + { + if(yMin==y)//建立桶头结点 + { + pHeadB=new CBucket;//建立桶的头结点 + pCurrentB=pHeadB;//pCurrentB为CBucket当前结点指针 + pCurrentB->ScanLine=yMin; + pCurrentB->pET=NULL;//没有链接边表 + pCurrentB->pNext=NULL; + } + else//其他扫描线 + { + pCurrentB->pNext=new CBucket;//建立桶的其他结点 + pCurrentB=pCurrentB->pNext; + pCurrentB->ScanLine=y; + pCurrentB->pET=NULL; + pCurrentB->pNext=NULL; + } + } +} + +void CZBuffer::CreateEdge()//创建边表 +{ + for(int i=0;ix=P[i].x;//计算ET表的值 + pEdge->yMax=P[j].y; + pEdge->k=(P[j].x-P[i].x)/(P[j].y-P[i].y);//代表1/k + pEdge->ps=P[i];//绑定顶点和颜色 + pEdge->pe=P[j]; + pEdge->pNext=NULL; + while(pCurrentB->ScanLine!=P[i].y)//在桶内寻找该边的yMin + { + pCurrentB=pCurrentB->pNext;//移到yMin所在的桶结点 + } + } + if(P[j].yx=P[j].x; + pEdge->yMax=P[i].y; + pEdge->k=(P[i].x-P[j].x)/(P[i].y-P[j].y); + pEdge->ps=P[i]; + pEdge->pe=P[j]; + pEdge->pNext=NULL; + while(pCurrentB->ScanLine!=P[j].y) + { + pCurrentB=pCurrentB->pNext; + } + } + if(int(P[j].y)!=P[i].y) + { + pCurrentE=pCurrentB->pET; + if(pCurrentE==NULL) + { + pCurrentE=pEdge; + pCurrentB->pET=pCurrentE; + } + else + { + while(pCurrentE->pNext!=NULL) + { + pCurrentE=pCurrentE->pNext; + } + pCurrentE->pNext=pEdge; + } + } + } +} + +void CZBuffer::Gouraud(CDC *pDC)//填充多边形 +{ + double CurDeep=0.0;//当前扫描线的深度 + double DeepStep=0.0;//当前扫描线随着x增长的深度步长 + double A,B,C,D;//平面方程Ax+By+Cz+D=0的系数 + CVector V01(P[0],P[1]),V02(P[0],P[2]); + CVector VN=Cross(V01,V02); + A=VN.x;B=VN.y;C=VN.z; + D=-A*P[0].x-B*P[0].y-C*P[0].z; + DeepStep=-A/C;//计算扫描线深度步长增量 + CAET *pT1,*pT2; + pHeadE=NULL; + for(pCurrentB=pHeadB;pCurrentB!=NULL;pCurrentB=pCurrentB->pNext) + { + for(pCurrentE=pCurrentB->pET;pCurrentE!=NULL;pCurrentE=pCurrentE->pNext) + { + pEdge=new CAET; + pEdge->x=pCurrentE->x; + pEdge->yMax=pCurrentE->yMax; + pEdge->k=pCurrentE->k; + pEdge->ps=pCurrentE->ps; + pEdge->pe=pCurrentE->pe; + pEdge->pNext=NULL; + AddEt(pEdge); + } + ETOrder(); + pT1=pHeadE; + if(pT1==NULL) + return; + while(pCurrentB->ScanLine>=pT1->yMax)//下闭上开 + { + CAET * pAETTEmp=pT1; + pT1=pT1->pNext; + delete pAETTEmp; + pHeadE=pT1; + if(pHeadE==NULL) + return; + } + if(pT1->pNext!=NULL) + { + pT2=pT1; + pT1=pT2->pNext; + } + while(pT1!=NULL) + { + if(pCurrentB->ScanLine>=pT1->yMax)//下闭上开 + { + CAET* pAETTemp =pT1; + pT2->pNext=pT1->pNext; + pT1=pT2->pNext; + delete pAETTemp; + } + else + { + pT2=pT1; + pT1=pT2->pNext; + } + } + CRGB ca,cb,cf;//ca、cb代边上任意点的颜色,cf代表面上任意点的颜色 + ca=Interpolation(pCurrentB->ScanLine,pHeadE->ps.y,pHeadE->pe.y,pHeadE->ps.c,pHeadE->pe.c); + cb=Interpolation(pCurrentB->ScanLine,pHeadE->pNext->ps.y,pHeadE->pNext->pe.y,pHeadE->pNext->ps.c,pHeadE->pNext->pe.c); + BOOL bInFlag=FALSE;//区间内外测试标志,初始值为假表示区间外部 + double xleft,xright;//扫描线和有效边相交区间的起点和终点坐标 + for(pT1=pHeadE;pT1!=NULL;pT1=pT1->pNext) + { + if(FALSE==bInFlag) + { + xleft=pT1->x; + CurDeep=-(xleft*A+pCurrentB->ScanLine*B+D)/C;//z=-(Ax+By-D)/C + bInFlag=TRUE; + } + else + { + xright=pT1->x; + for(double x=xleft;xScanLine+Height/2])//如果当前采样点的深度小于帧缓冲器中原采样点的深度 + { + zBuffer[Round(x)+Width/2][pCurrentB->ScanLine+Height/2]=CurDeep;//使用当前采样点的深度更新深度缓冲器 + pDC->SetPixelV(Round(x),pCurrentB->ScanLine,RGB(cf.red*255,cf.green*255,cf.blue*255));//绘制当前采样点 + } + CurDeep+=DeepStep; + } + bInFlag=FALSE; + } + } + for(pT1=pHeadE;pT1!=NULL;pT1=pT1->pNext)//边的连续性 + pT1->x=pT1->x+pT1->k; + } +} + +void CZBuffer::AddEt(CAET *pNewEdge)//合并ET表 +{ + CAET *pCE; + pCE=pHeadE; + if(pCE==NULL) + { + pHeadE=pNewEdge; + pCE=pHeadE; + } + else + { + while(pCE->pNext!=NULL) + { + pCE=pCE->pNext; + } + pCE->pNext=pNewEdge; + } +} + +void CZBuffer::ETOrder()//边表的冒泡排序算法 +{ + CAET *pT1,*pT2; + int Count=1; + pT1=pHeadE; + if(pT1==NULL) + return; + if(pT1->pNext==NULL)//如果该ET表没有再连ET表 + return;//桶结点只有一条边,不需要排序 + while(pT1->pNext!=NULL)//统计边结点的个数 + { + Count++; + pT1=pT1->pNext; + } + for(int i=0;ipNext; + + if ((pT1->x>pT2->x)||((pT1->x==pT2->x)&&(pT1->k>pT2->k))) + { + pT1->pNext=pT2->pNext; + pT2->pNext=pT1; + *pPre=pT2; + pPre=&(pT2->pNext);//调整位置为下次遍历准备 + } + else + { + pPre=&(pT1->pNext); + pT1=pT1->pNext; + } + } + } +} + +CRGB CZBuffer::Interpolation(double t,double t1,double t2,CRGB clr1,CRGB clr2)//颜色线性插值 +{ + CRGB color; + color=(t-t2)/(t1-t2)*clr1+(t-t1)/(t2-t1)*clr2; + return color; +} + +void CZBuffer::InitDeepBuffer(int Width,int Height,double Depth)//初始化深度缓冲 +{ + int i; + this->Width=Width,this->Height=Height; + zBuffer=new double *[Width]; + for( i=0;ipNext; + DeleteAETChain(pBucket->pET); + delete pBucket; + pBucket=pBucketTemp; + } + pHeadB=NULL; + pHeadE=NULL; +} + +void CZBuffer::DeleteAETChain(CAET* pAET) +{ + while (pAET!=NULL) + { + CAET *pAETTemp=pAET->pNext; + delete pAET; + pAET=pAETTemp; + } +} \ No newline at end of file diff --git a/PolyhedronHouse/ZBuffer.h b/PolyhedronHouse/ZBuffer.h new file mode 100644 index 0000000..4a67dc8 --- /dev/null +++ b/PolyhedronHouse/ZBuffer.h @@ -0,0 +1,38 @@ +// ZBuffer.h: interface for the CZBuffer class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_ZBUFFER_H__ED93E842_7399_49B8_B579_6A52FBA1289D__INCLUDED_) +#define AFX_ZBUFFER_H__ED93E842_7399_49B8_B579_6A52FBA1289D__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +#include "Bucket.h"//桶头文件 +#include "Vector.h"//矢量头文件 + +class CZBuffer +{ +public: + CZBuffer(); + virtual ~CZBuffer(); + void CreateBucket();//创建桶 + void CreateEdge();//边表 + void AddEt(CAET *);//合并ET表 + void ETOrder(); + void Gouraud(CDC *);//填充 + void InitDeepBuffer(int,int,double);//初始化深度缓冲器 + CRGB Interpolation(double,double,double,CRGB,CRGB);//线性插值 + void SetPoint(CPi3 *,int); + void ClearMemory();//清理内存 + void DeleteAETChain(CAET* pAET);//删除边表 +protected: + int PNum;//顶点个数 + CPi3 *P;//顶点数组 + CAET *pHeadE,*pCurrentE,*pEdge;//有效边表结点指针 + CBucket *pCurrentB,*pHeadB; + double **zBuffer;//缓深度冲区 + int Width,Height;//缓冲区参数 +}; + +#endif // !defined(AFX_ZBUFFER_H__ED93E842_7399_49B8_B579_6A52FBA1289D__INCLUDED_) diff --git a/PolyhedronHouse/resource.h b/PolyhedronHouse/resource.h new file mode 100644 index 0000000..a8de7d5 --- /dev/null +++ b/PolyhedronHouse/resource.h @@ -0,0 +1,36 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by Test.rc +// +#define IDD_ABOUTBOX 100 +#define IDR_MAINFRAME 128 +#define IDR_TESTTYPE 129 +#define IDI_ICON1 130 +#define IDI_ICON2 131 +#define IDI_ICON3 132 +#define IDI_ICON4 133 +#define IDB_BITMAP1 134 +#define IDB_ABOUT 134 +#define IDI_ICON5 138 +#define IDB_BITMAP2 139 +#define IDI_ICON6 142 +#define IDI_ICON7 145 +#define IDI_ICON8 146 +#define IDI_ICON9 147 +#define ID_MENUPlay 32781 +#define ID_ONEPOINT 32783 +#define ID_TWOPOINT 32784 +#define ID_THREEPOINT 32785 +#define IDM_PLAY 32786 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_3D_CONTROLS 1 +#define _APS_NEXT_RESOURCE_VALUE 148 +#define _APS_NEXT_COMMAND_VALUE 32788 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif