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

📄 plane.h

📁 小游戏 有碰撞检测和音乐 使用键盘openal
💻 H
字号:
#pragma once
#include "object.h"


class CPlane : public CObject
{
	public:
	CVector v[4];
	float r, g, b;
	int tid;
	float df;
	CVector normal;
	CPlane( float x1, float y1, float z1,
	float x2, float y2, float z2,
	float x3, float y3, float z3,
	float x4, float y4, float z4,
	float r, float g, float b , int tid , float df)	: r( r ), g( g ), b( b ), tid( tid ),df( df )
	{
		type = "plane";
		v[ 0 ].x = x1; v[ 0 ].y = y1; v[ 0 ].z = z1;
		v[ 1 ].x = x2; v[ 1 ].y = y2; v[ 1 ].z = z2;
		v[ 2 ].x = x3; v[ 2 ].y = y3; v[ 2 ].z = z3;
		v[ 3 ].x = x4; v[ 3 ].y = y4; v[ 3 ].z = z4;

		normal = (v[1] - v[0]) ^ (v[3] - v[0]);
	}
	~CPlane()
	{}
	void Render()
	{
		glEnable( GL_TEXTURE_2D );
		glBindTexture( GL_TEXTURE_2D, textures[tid].id );
		glColor3f( r, g, b );
		glBegin( GL_QUADS );
		for ( int i = 0; i < 4; i++ )
		{
			if ( i == 0 ) glTexCoord2f( 0.0f , 0.0f );
			if ( i == 1 ) glTexCoord2f( 1.0f*df , 0.0f );
			if ( i == 2 ) glTexCoord2f( 1.0f*df , 1.0f );
			if ( i == 3 ) glTexCoord2f( 0.0f , 1.0f );
			glVertex3f( v[i].x, v[i].y, v[i].z );
		}
		glEnd();
		glDisable( GL_TEXTURE_2D );
	}
};

⌨️ 快捷键说明

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