⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plane.cpp

📁 刚上传内容的相关CODEC不能单独上传。于是
💻 CPP
字号:
// Plane.cpp: implementation of the CPlane class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "MagicScissors.h"
#include "Plane.h"
#include "EdgeList.h"
#include "EdgePoint.h"

#include "Image/Image.h"
#include "Image/ColorPixel.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CPlane::CPlane()
{
	m_nType = PLANE;
	m_pList = NULL;	
}

CPlane::CPlane(CPlane* pSrc)
{
	m_nType = PLANE;
	m_pList = pSrc->m_pList;	
	m_Rect = pSrc->m_Rect;
	m_ptCenter = pSrc->m_ptCenter;
	m_fDepth = pSrc->m_fDepth;
	m_bValidate = TRUE;
}

CPlane::~CPlane()
{
	
}

void CPlane::Render(GLUquadricObj* pQuad, CImage* pImage, BOOL bGlobal)
{
	if( !m_bValidate || !m_pList ) return;

	int n  = m_pList->GetLength();
	int i,h;
	int sx = m_Rect.left;
	int sy = m_Rect.top;
	CPoint pt;

	if( bGlobal )
	{
		glPushMatrix();

		h = m_nY;

	
		glTranslatef( 0, 0, -(500+m_fDepth) );
		glBegin(GL_TRIANGLE_FAN  );
		
			glColor3f(0.5f,0.5f,0.f);			
			
			glVertex3f( (float)m_ptCenter.x, (float)h-m_ptCenter.y, 0 );
			for( i = 0 ; i < n ; i++ )
			{
				pt = *(m_pList->GetPoint(i));
				pt.y = h-pt.y;				
				glVertex3f( (float)pt.x, (float)pt.y, 0 );
				//glVertex2f( pt.x, pt.y);
			}
			pt = *(m_pList->GetPoint(0));
			pt.y = h-pt.y;						
			glVertex3f( (float)pt.x, (float)pt.y, 0 );			
			
		glEnd();		
		glPopMatrix();
	}
	else
	{	
		h = m_Rect.Height();		
		glBegin(GL_POLYGON );
			glColor3f(0.5f,0.5f,0.f);
			glVertex3f((float)m_Rect.Width()/2, (float)m_Rect.Height()/2, 0 );
			for( i = 0 ; i < n ; i++ )
			{
				pt = *(m_pList->GetPoint(i));
				pt.x -= sx;
				pt.y -= sy;
				pt.y = h - pt.y;				
				glVertex3f( (float)pt.x, (float)pt.y, 0 );
				//glVertex2f( pt.x, pt.y);
			}
			pt = *(m_pList->GetPoint(0));
			pt.x -= sx;
			pt.y -= sy;
			pt.y = h - pt.y;			
			glVertex3f( (float)pt.x, (float)pt.y, 0 );
			//glVertex2f( pt.x, pt.y);
		glEnd();		
	}

}

BOOL CPlane::Create(CEdgeList* pList,CRect rect, int height)
{
	m_pList = pList;
	m_Rect = rect;
	m_nY = height;
	m_bValidate = TRUE;
	m_ptCenter.x = m_Rect.left + m_Rect.Width()/2;
	m_ptCenter.y = m_Rect.top + m_Rect.Height()/2;
	return TRUE;
}

BOOL CPlane::Write(CFile* pFile)
{
	return C3DObject::Write(pFile);
}

BOOL CPlane::Read(CFile* pFile)
{
	return C3DObject::Read(pFile);
}

BOOL CPlane::CopyParam(C3DObject* pObject)
{
	if( !pObject ) return FALSE;

	CPlane* pSrc = (CPlane*)pObject;

	m_fDepth = pSrc->m_fDepth;
	return TRUE;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -