Files
2024-11-14 10:48:14 +08:00

100 lines
3.0 KiB
C++

// 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 "Vector.h"
#include "ZBuffer.h"
#include "Lighting.h"
#include "Transform.h"
class CTestView : public CView {
protected: // create from serialization only
CTestView();
DECLARE_DYNCREATE(CTestView)
// Attributes
public:
CTestDoc *GetDocument();
// Operations
public:
void ReadCubeVertex(); // 读入立方体顶点
void ReadCubeFace(); // 读入立方体面表
void ReadGroundVertex(); // 读入地面顶点
void InitParameter(); // 变换参数
void PerProject(CP3); // 透视投影
void DoubleBuffer(); // 双缓冲
void DrawObject(CDC *); // 绘制物体
void DrawCube(CDC *, CZBuffer *); // 绘制立方体
void DrawGround(CDC *); // 绘制地面
void DrawShadow(CDC *pDC, CZBuffer *); // 绘制阴影
CP3 CalculateCrossPoint(CP3, CP3); // 计算光线与地面的交点
// 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:
double R, Theta, Phi; // 视点在用户坐标系中的球坐标
double d; // 视距
double Near, Far; // 远近剪切面
double k[9]; // 透视变换参数
CP3 ViewPoint; // 视点球坐标位置
CPi3 ScreenP; // 屏幕坐标系的三维坐标点
double Beta; // y方向旋转β角
CP3 VCube[10]; // 立方体点表
CFace FCube[7]; // 立方体面表
CP3 VGround[4]; // 地面顶点表
int N1, N2; // N1为纬度区间,N2为经度区间
int LightNum; // 光源数量
CLighting *pLight; // 光照环境
CMaterial *pMaterial; // 物体材质
BOOL bPlay; // 动画开关
CTransform tran; // 变换对象
// Generated message map functions
public:
//{{AFX_MSG(CTestView)
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnTimer(UINT nIDEvent);
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_)