亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? main.cpp

?? Quake中的MD2模型導入
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
//***********************************************************************//
//																		 //
//		- "Talk to me like I'm a 3 year old!" Programming Lessons -		 //
//                                                                       //
//		$Author:		DigiBen		digiben@gametutorials.com			 //
//																		 //
//		$Program:		MD2 Loader										 //
//																		 //
//		$Description:	Demonstrates how to load a Quake2 MD2 Model		 //
//																		 //
//		$Date:			2/6/02											 //
//																		 //
//***********************************************************************//

// This is a compiler directive that includes libraries (For Visual Studio)
// You can manually include the libraries in the "Project->settings" menu under
// the "Link" tab.  You need these libraries to compile this program.
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")
#pragma comment(lib, "glaux.lib")

#include "main.h"										// This includes our header file
#include "Md2.h"										// Include the MD2 header file.

bool  g_bFullScreen = true;								// Set full screen as default
HWND  g_hWnd;											// This is the handle for the window
RECT  g_rRect;											// This holds the window dimensions
HDC   g_hDC;											// General HDC - (handle to device context)
HGLRC g_hRC;											// General OpenGL_DC - Our Rendering Context for OpenGL
HINSTANCE g_hInstance;									// This holds the global hInstance for UnregisterClass() in DeInit()

//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////

// This tutorial will demonstrate how to load a .Md2 file.  This 3D file format
// was created for Quake2 character models with key frame animation.  
// If you have any desire to create your own file, I suggest finding MilkShape 3D.
// This program allows you to import and export almost every popular 3D format,
// along with the ability to use it as a modeler.  It's a $20 shareware program,
// you can't beat that!  I chose the .Md2 format after viewing the internet and
// see the countless characters already on the internet for free download.
// This is good news for programmers that don't have art programs or can't
// do any art.  All the animations and weapons are done for you!  This is a
// great start to learning animation as well, since the Quake formats are so
// simple it makes me shed a tear of joy.  This tutorial only loads the model,
// where as the next tutorial will show how to do key frame animation using
// interpolation.  Next, we will tackle skeletal animation with the famous
// Quake3 .Md3 format.  This makes learning animation easy because it isn't
// complicated by a $3000 modeler.  Plus, there are hundreds of models out
// there on the internet to test and put in your own games (with permission of course).
// The best place to find models is at www.planetquake.com.  Usually there are
// featured models weekly to download.
//
// Since there is no animation for the model, we just have it spinning in the
// center of the screen.  The controls are: 
//
// Left Mouse Button - Changes the Render mode from normal to wireframe.
// Right Mouse Button - Turns lighting On/Off
// Left Arrow Key - Spins the model to the left
// Right Arrow Key - Spins the model to the right
// Escape - Quits
//
// If you decide to go find models you might find them in a format like .pk3.
// This is just a .zip format, so rename it to .zip and unzip it.  There should
// be .Md2 and texture files.  I think the textures are normally in .pcx, so you
// will have to save them as BMP's to run in here.
//
//
//
//

#define FILE_NAME  "tris.md2"							// This is the 3D file we will load.
#define TEXTURE_NAME "hobgoblin.bmp"

UINT g_Texture[MAX_TEXTURES] = {0};						// This holds the texture info, referenced by an ID

CLoadMD2 g_LoadMd2;										// This is MD2 class.  This should go in a good model class.
t3DModel g_3DModel;										// This holds the 3D Model info that we load in

int   g_ViewMode	  = GL_TRIANGLES;					// We want the default drawing mode to be normal
bool  g_bLighting     = true;							// Turn lighting on initially
float g_RotateX		  = 0.0f;							// This is the current value at which the model is rotated
float g_RotationSpeed = 0.5f;							// This is the speed that our model rotates.  (-speed rotates left)

//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////


///////////////////////////////// INIT GAME WINDOW \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
/////	This function initializes the game window.
/////
///////////////////////////////// INIT GAME WINDOW \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*

void Init(HWND hWnd)
{
	g_hWnd = hWnd;										// Assign the window handle to a global window handle
	GetClientRect(g_hWnd, &g_rRect);					// Assign the windows rectangle to a global RECT
	InitializeOpenGL(g_rRect.right, g_rRect.bottom);	// Init OpenGL with the global rect

//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////

	// First we need to actually load the .MD2 file.  We just pass in an address to
	// our t3DModel structure and the file name string we want to load ("tris.md2").
	// We also need to give the texture name we will be using.  This is because there
	// are usually a lot of textures with each character.  You choose the best one.
	// It seems that all of the Quake2 characters .md2 files are called: "tris.md2"

	g_LoadMd2.ImportMD2(&g_3DModel, FILE_NAME, TEXTURE_NAME);		

	// There is no color information for these models, as well as only one
	// texture.  If everything goes well, it should load the TEXTURE_NAME file.

	// Go through all the materials
	for(int i = 0; i < g_3DModel.numOfMaterials; i++)
	{
		// Check to see if there is a file name to load in this material
		if(strlen(g_3DModel.pMaterials[i].strFile) > 0)
		{
			// Use the name of the texture file to load the bitmap, with a texture ID (i).
			// We pass in our global texture array, the name of the texture, and an ID to reference it.	
			CreateTexture(g_Texture, g_3DModel.pMaterials[i].strFile, i);			
		}

		// Set the texture ID for this material
		g_3DModel.pMaterials[i].texureId = i;
	}

	// Here, we turn on a lighting and enable lighting.  We don't need to
	// set anything else for lighting because we will just take the defaults.
	// We also want color, so we turn that on

	glEnable(GL_LIGHT0);								// Turn on a light with defaults set
	glEnable(GL_LIGHTING);								// Turn on lighting
	glEnable(GL_COLOR_MATERIAL);						// Allow color

	// To make our model render somewhat faster, we do some front back culling.
	// It seems that Quake2 orders their polygons clock-wise.

	glEnable(GL_CULL_FACE);								// Turn culling on
	glCullFace(GL_FRONT);								// Quake2 uses front face culling apparently

//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////

}


///////////////////////////////// MAIN GAME LOOP \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
/////	This function Handles the main game loop
/////
///////////////////////////////// MAIN GAME LOOP \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*

WPARAM MainLoop()
{
	MSG msg;

	while(1)											// Do our infinate loop
	{													// Check if there was a message
		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) 
        { 
			if(msg.message == WM_QUIT)					// If the message wasnt to quit
				break;
            TranslateMessage(&msg);						// Find out what the message does
            DispatchMessage(&msg);						// Execute the message
        }
		else											// if there wasn't a message
		{ 
			RenderScene();								// Update the screen	
        } 
	}

//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////

	// When we are done, we need to free all the model data
	// We do this by walking through all the objects and freeing their information

	// Go through all the objects in the scene
	for(int i = 0; i < g_3DModel.numOfObjects; i++)
	{
		// Free the faces, normals, vertices, and texture coordinates.
		if(g_3DModel.pObject[i].pFaces)		delete [] g_3DModel.pObject[i].pFaces;
		if(g_3DModel.pObject[i].pNormals)	delete [] g_3DModel.pObject[i].pNormals;
		if(g_3DModel.pObject[i].pVerts)		delete [] g_3DModel.pObject[i].pVerts;
		if(g_3DModel.pObject[i].pTexVerts)	delete [] g_3DModel.pObject[i].pTexVerts;
	}

//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////

	DeInit();											// Clean up and free all allocated memory

	return(msg.wParam);									// Return from the program
}

///////////////////////////////// RENDER SCENE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
/////	This function renders the entire scene.
/////
///////////////////////////////// RENDER SCENE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*

void RenderScene() 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品美女久久久久久| 不卡av在线网| 成人在线综合网| 欧美日韩视频在线第一区 | 国产欧美日韩精品一区| 亚洲精品欧美综合四区| 韩国精品主播一区二区在线观看| 欧美亚洲高清一区二区三区不卡| 久久久精品免费免费| 日韩高清不卡一区二区| 91小视频在线免费看| 久久久久99精品国产片| 三级在线观看一区二区| 在线观看亚洲精品视频| 国产精品久久久久影院色老大 | 精品国产免费视频| 亚洲成在人线在线播放| 99国产精品久久久| 国产三级精品在线| 国产一区二区三区在线观看免费 | 91欧美一区二区| 欧美国产成人精品| 国产精品综合一区二区三区| 日韩一级大片在线| 亚洲成人免费视| 欧美三级午夜理伦三级中视频| 亚洲天堂免费看| 一本色道久久综合亚洲精品按摩| 欧美激情一区二区三区| 国产精品一级二级三级| 久久亚洲一级片| 国产一区视频网站| 国产亲近乱来精品视频| 国产精品系列在线播放| 久久精品男人的天堂| 国产成人亚洲综合a∨猫咪| 欧美国产一区在线| 成人av在线播放网址| 亚洲另类春色校园小说| 日本精品一区二区三区高清 | 韩国毛片一区二区三区| 久久免费的精品国产v∧| 国产精品原创巨作av| 国产日韩欧美a| 91在线云播放| 国产亚洲欧美一级| 日韩精品最新网址| 看电视剧不卡顿的网站| 精品日韩欧美在线| 国产91精品入口| 国产精品污污网站在线观看| av在线这里只有精品| 一区二区日韩电影| 欧美一区二区三区四区高清| 激情深爱一区二区| 国产欧美视频在线观看| 99久久精品国产导航| 亚洲一区二区三区四区的| 91精品国产色综合久久不卡蜜臀| 国模少妇一区二区三区| 亚洲另类在线一区| 日韩欧美一级二级三级久久久| 国产成人精品1024| 亚洲丶国产丶欧美一区二区三区| 欧美精品一区二区三区高清aⅴ| 国产aⅴ综合色| 日韩精品亚洲专区| 国产精品久久午夜| 日韩精品专区在线影院重磅| 99re热这里只有精品视频| 日本免费在线视频不卡一不卡二| 国产丝袜欧美中文另类| 欧美亚洲精品一区| 国产成人综合亚洲网站| 一区在线观看免费| 久久亚洲一级片| 欧美日韩视频第一区| 丁香婷婷综合五月| 免费视频一区二区| 伊人性伊人情综合网| 久久精品综合网| 欧美精品高清视频| 成人性生交大片| 另类小说图片综合网| 亚洲已满18点击进入久久| 精品久久久久久久久久久久久久久 | 欧美一区二区三区精品| 99久久伊人网影院| 国产精品一区二区在线观看不卡| 日韩精品一二三| 亚洲国产精品人人做人人爽| 国产精品久久久久久妇女6080| 欧美大片在线观看| 欧美日本视频在线| 欧美性受xxxx| 91免费视频网| 成人免费毛片高清视频| 国产在线精品一区在线观看麻豆| 视频一区在线视频| 亚洲高清不卡在线观看| 亚洲精品视频免费看| 亚洲欧洲制服丝袜| 亚洲另类在线视频| 亚洲精品视频免费看| 亚洲另类中文字| 夜夜嗨av一区二区三区网页| 亚洲人成在线观看一区二区| 国产精品网曝门| 国产精品免费久久| ㊣最新国产の精品bt伙计久久| 欧美国产成人在线| 中文字幕在线一区免费| 亚洲国产精品av| 国产精品久久久久久久久久免费看 | 欧美肥妇bbw| 欧美日韩亚洲另类| 欧美精品在线视频| 欧美一区二区三区四区久久| 欧美一区二区三区色| 日韩免费高清电影| 欧美精品一区二区在线播放| 久久久九九九九| 国产精品嫩草久久久久| 亚洲欧美激情小说另类| 一区二区三区在线不卡| 婷婷六月综合网| 青娱乐精品视频在线| 久久91精品国产91久久小草| 国产一区二区电影| av一区二区三区四区| 在线免费精品视频| 51精品秘密在线观看| 26uuu另类欧美亚洲曰本| 国产日本亚洲高清| 一区二区三区在线影院| 日本特黄久久久高潮| 激情久久五月天| 不卡的av网站| 欧美日本韩国一区| 国产亚洲综合在线| 一区二区三区国产精品| 蜜臀va亚洲va欧美va天堂| 国产白丝精品91爽爽久久| 在线免费观看日本一区| 日韩精品综合一本久道在线视频| 中日韩av电影| 午夜天堂影视香蕉久久| 黑人精品欧美一区二区蜜桃| 一本色道**综合亚洲精品蜜桃冫| 欧美剧情片在线观看| 久久久亚洲精品石原莉奈| 中文字幕一区在线观看| 青青国产91久久久久久| 国产成人三级在线观看| 欧美亚一区二区| 国产日韩欧美精品综合| 亚洲777理论| av在线不卡免费看| 日韩免费观看高清完整版在线观看| 中文字幕日韩av资源站| 久久精品国产精品亚洲红杏| 91久久免费观看| 国产嫩草影院久久久久| 日韩电影在线免费看| 波多野结衣一区二区三区 | 91麻豆精品在线观看| 91精品国产丝袜白色高跟鞋| 中文字幕亚洲电影| 九九精品视频在线看| 欧美日韩国产欧美日美国产精品| 国产欧美日韩久久| 激情小说欧美图片| 3d动漫精品啪啪一区二区竹菊| 亚洲欧洲一区二区三区| 国产成人综合在线| 欧美sm极限捆绑bd| 日本不卡1234视频| 7777精品伊人久久久大香线蕉最新版| 1000精品久久久久久久久| 国产一区二区三区精品视频| 欧美麻豆精品久久久久久| 一区二区三区中文字幕电影| 99精品国产99久久久久久白柏| 国产校园另类小说区| 精品一区二区三区免费| 日韩视频在线你懂得| 石原莉奈在线亚洲二区| 欧美日韩视频在线第一区| 亚洲国产裸拍裸体视频在线观看乱了 | 欧美日韩一区视频| 亚洲精品乱码久久久久久黑人| 成人免费视频播放| 国产精品不卡在线观看| 国产成人综合在线播放| 日本一区免费视频| 成人小视频在线| 国产精品久久国产精麻豆99网站 | 麻豆久久久久久久| 7777精品伊人久久久大香线蕉的 | 中文在线一区二区|