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

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

?? md2.cpp

?? Quake中的MD2模型導入
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
		currentFrame.pTexVerts[j].x = m_pTexCoords[j].u / float(m_Header.skinWidth);
		currentFrame.pTexVerts[j].y = 1 - m_pTexCoords[j].v / float(m_Header.skinHeight);
	}

	// Go through all of the face data and assign it over to OUR structure
	for(j=0; j < currentFrame.numOfFaces; j++)
	{
		// Assign the vertex indices to our face data
		currentFrame.pFaces[j].vertIndex[0] = m_pTriangles[j].vertexIndices[0];
		currentFrame.pFaces[j].vertIndex[1] = m_pTriangles[j].vertexIndices[1];
		currentFrame.pFaces[j].vertIndex[2] = m_pTriangles[j].vertexIndices[2];

		// Assign the texture coord indices to our face data
		currentFrame.pFaces[j].coordIndex[0] = m_pTriangles[j].textureIndices[0];
		currentFrame.pFaces[j].coordIndex[1] = m_pTriangles[j].textureIndices[1];
		currentFrame.pFaces[j].coordIndex[2] = m_pTriangles[j].textureIndices[2];
	}

	// Here we add the current object (or frame) to our list object list
	pModel->pObject.push_back(currentFrame);
}


///////////////////////////////// CLEAN UP \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
/////	This function cleans up our allocated memory and closes the file
/////
///////////////////////////////// CLEAN UP \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*

void CLoadMD2::CleanUp()
{
	// This just just the regular cleanup or our md2 model class.  We can free
	// all of this data because we already have it stored in our own structures.

	fclose(m_FilePointer);						// Close the current file pointer

	if(m_pSkins)	 delete [] m_pSkins;		// Free the skins data
	if(m_pTexCoords) delete m_pTexCoords;		// Free the texture coord data
	if(m_pTriangles) delete m_pTriangles;		// Free the triangle face data
	if(m_pFrames)	 delete m_pFrames;			// Free the frames of animation
}



// *Note* 
//
// Below are some math functions for calculating vertex normals.  We want vertex normals
// because it makes the lighting look really smooth and life like.  You probably already
// have these functions in the rest of your engine, so you can delete these and call
// your own.  I wanted to add them so I could show how to calculate vertex normals.

//////////////////////////////	Math Functions  ////////////////////////////////*

// This computes the magnitude of a normal.   (magnitude = sqrt(x^2 + y^2 + z^2)
#define Mag(Normal) (sqrt(Normal.x*Normal.x + Normal.y*Normal.y + Normal.z*Normal.z))

// This calculates a vector between 2 points and returns the result
CVector3 Vector(CVector3 vPoint1, CVector3 vPoint2)
{
	CVector3 vVector;							// The variable to hold the resultant vector

	vVector.x = vPoint1.x - vPoint2.x;			// Subtract point1 and point2 x's
	vVector.y = vPoint1.y - vPoint2.y;			// Subtract point1 and point2 y's
	vVector.z = vPoint1.z - vPoint2.z;			// Subtract point1 and point2 z's

	return vVector;								// Return the resultant vector
}

// This adds 2 vectors together and returns the result
CVector3 AddVector(CVector3 vVector1, CVector3 vVector2)
{
	CVector3 vResult;							// The variable to hold the resultant vector
	
	vResult.x = vVector2.x + vVector1.x;		// Add Vector1 and Vector2 x's
	vResult.y = vVector2.y + vVector1.y;		// Add Vector1 and Vector2 y's
	vResult.z = vVector2.z + vVector1.z;		// Add Vector1 and Vector2 z's

	return vResult;								// Return the resultant vector
}

// This divides a vector by a single number (scalar) and returns the result
CVector3 DivideVectorByScaler(CVector3 vVector1, float Scaler)
{
	CVector3 vResult;							// The variable to hold the resultant vector
	
	vResult.x = vVector1.x / Scaler;			// Divide Vector1's x value by the scaler
	vResult.y = vVector1.y / Scaler;			// Divide Vector1's y value by the scaler
	vResult.z = vVector1.z / Scaler;			// Divide Vector1's z value by the scaler

	return vResult;								// Return the resultant vector
}

// This returns the cross product between 2 vectors
CVector3 Cross(CVector3 vVector1, CVector3 vVector2)
{
	CVector3 vCross;								// The vector to hold the cross product
												// Get the X value
	vCross.x = ((vVector1.y * vVector2.z) - (vVector1.z * vVector2.y));
												// Get the Y value
	vCross.y = ((vVector1.z * vVector2.x) - (vVector1.x * vVector2.z));
												// Get the Z value
	vCross.z = ((vVector1.x * vVector2.y) - (vVector1.y * vVector2.x));

	return vCross;								// Return the cross product
}

// This returns the normal of a vector
CVector3 Normalize(CVector3 vNormal)
{
	double Magnitude;							// This holds the magitude			

	Magnitude = Mag(vNormal);					// Get the magnitude

	vNormal.x /= (float)Magnitude;				// Divide the vector's X by the magnitude
	vNormal.y /= (float)Magnitude;				// Divide the vector's Y by the magnitude
	vNormal.z /= (float)Magnitude;				// Divide the vector's Z by the magnitude

	return vNormal;								// Return the normal
}

///////////////////////////////// COMPUTER NORMALS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
/////	This function computes the normals and vertex normals of the objects
/////
///////////////////////////////// COMPUTER NORMALS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*

void CLoadMD2::ComputeNormals(t3DModel *pModel)
{
	CVector3 vVector1, vVector2, vNormal, vPoly[3];

	// If there are no objects, we can skip this part
	if(pModel->numOfObjects <= 0)
		return;

	// What are vertex normals?  And how are they different from other normals?
	// Well, if you find the normal to a triangle, you are finding a "Face Normal".
	// If you give OpenGL a face normal for lighting, it will make your object look
	// really flat and not very round.  If we find the normal for each vertex, it makes
	// the smooth lighting look.  This also covers up blocky looking objects and they appear
	// to have more polygons than they do.    Basically, what you do is first
	// calculate the face normals, then you take the average of all the normals around each
	// vertex.  It's just averaging.  That way you get a better approximation for that vertex.

	// Go through each of the objects to calculate their normals
	for(int index = 0; index < pModel->numOfObjects; index++)
	{
		// Get the current object
		t3DObject *pObject = &(pModel->pObject[index]);

		// Here we allocate all the memory we need to calculate the normals
		CVector3 *pNormals		= new CVector3 [pObject->numOfFaces];
		CVector3 *pTempNormals	= new CVector3 [pObject->numOfFaces];
		pObject->pNormals		= new CVector3 [pObject->numOfVerts];

		// Go though all of the faces of this object
		for(int i=0; i < pObject->numOfFaces; i++)
		{												
			// To cut down LARGE code, we extract the 3 points of this face
			vPoly[0] = pObject->pVerts[pObject->pFaces[i].vertIndex[0]];
			vPoly[1] = pObject->pVerts[pObject->pFaces[i].vertIndex[1]];
			vPoly[2] = pObject->pVerts[pObject->pFaces[i].vertIndex[2]];

			// Now let's calculate the face normals (Get 2 vectors and find the cross product of those 2)

			vVector1 = Vector(vPoly[0], vPoly[2]);		// Get the vector of the polygon (we just need 2 sides for the normal)
			vVector2 = Vector(vPoly[2], vPoly[1]);		// Get a second vector of the polygon

			vNormal  = Cross(vVector1, vVector2);		// Return the cross product of the 2 vectors (normalize vector, but not a unit vector)
			pTempNormals[i] = vNormal;					// Save the un-normalized normal for the vertex normals
			vNormal  = Normalize(vNormal);				// Normalize the cross product to give us the polygons normal

			pNormals[i] = vNormal;						// Assign the normal to the list of normals
		}

		//////////////// Now Get The Vertex Normals /////////////////

		CVector3 vSum = {0.0, 0.0, 0.0};
		CVector3 vZero = vSum;
		int shared=0;

		for (i = 0; i < pObject->numOfVerts; i++)			// Go through all of the vertices
		{
			for (int j = 0; j < pObject->numOfFaces; j++)	// Go through all of the triangles
			{												// Check if the vertex is shared by another face
				if (pObject->pFaces[j].vertIndex[0] == i || 
					pObject->pFaces[j].vertIndex[1] == i || 
					pObject->pFaces[j].vertIndex[2] == i)
				{
					vSum = AddVector(vSum, pTempNormals[j]);// Add the un-normalized normal of the shared face
					shared++;								// Increase the number of shared triangles
				}
			}      
			
			// Get the normal by dividing the sum by the shared.  We negate the shared so it has the normals pointing out.
			pObject->pNormals[i] = DivideVectorByScaler(vSum, float(-shared));

			// Normalize the normal for the final vertex normal
			pObject->pNormals[i] = Normalize(pObject->pNormals[i]);	

			vSum = vZero;									// Reset the sum
			shared = 0;										// Reset the shared
		}
	
		// Free our memory and start over on the next object
		delete [] pTempNormals;
		delete [] pNormals;
	}
}


/////////////////////////////////////////////////////////////////////////////////
//
// * QUICK NOTES * 
//
// Pretty simple huh?  This is probably the easiest 3D file format I have ever
// worked with, so good job Carmack!  Once again, the next Md2 tutorial will cover
// the key frame animation that is associated with these models.  Then you can 
// actually say you have worked with real quake characters and know how they did
// their animation.  Let's go over a brief explanation of this loader:
//
// The structures MUST be the same size and data types in order to load the
// Quake2 data.  First we load the Header information.  This tells us everything
// about the file and it's contents.
// 
// After the header is loaded, we need to check if the ID is 8.  This is a must.
// Don't ask me why it's 8, ask John Carmack!  If the version ID checks out, then
// we can start loading the data.
// 
// For each set of data you want to load is, we use an fseek() to move the file
// pointer to that location in the file that is given in the header.
//
// After you load the data, you can then convert the data structures to your own
// format, that way you don't have ot be stuck with theirs.  I decided to make it
// like the other loaders for future purposes.  We also compute our own normals.
//
// There is one thing I didn't mention that was NOT loaded in.  There is an array
// of OpenGL commands that allow you to render the vertices in triangle strips and
// a triangle fan.  This is the ugliest code I have ever seen to implement it, so
// I left it out :)
//
// I would like to thank Daniel E. Schoenblum <dansch@hops.cs.jhu.edu> for help
// with explaining the file format.
//
// Let me know if this helps you out!
// 
// 
// Ben Humphrey (DigiBen)
// Game Programmer
// DigiBen@GameTutorials.com
// Co-Web Host of www.GameTutorials.com
//
// The Quake2 .Md2 file format is owned by ID Software.  This tutorial is being used 
// as a teaching tool to help understand model loading and animation.  This should
// not be sold or used under any way for commercial use with out written conset
// from ID Software.
//
// Quake and Quake2 are trademarks of id Software.
// All trademarks used are properties of their respective owners. 
//
//

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国v精品久久久网| 久久亚区不卡日本| 精品国精品自拍自在线| 《视频一区视频二区| 美国欧美日韩国产在线播放| 国产69精品久久99不卡| 欧美一区二区精品在线| 亚洲美女屁股眼交| 国产成人精品亚洲777人妖 | 欧美日韩专区在线| 久久久99免费| 久久精品国产亚洲高清剧情介绍| 色婷婷久久综合| 国产精品久久影院| 国产精品一区二区久久精品爱涩| 欧美精选在线播放| 亚洲国产精品一区二区www在线| 成人三级伦理片| 久久久五月婷婷| 国产精品资源在线| 亚洲精品一区在线观看| 蜜臀av一区二区在线免费观看| 欧美在线制服丝袜| 亚洲一二三四在线| 在线观看免费成人| 亚洲一区二区美女| 欧美午夜片在线观看| 亚洲一区二区三区四区在线免费观看| av不卡在线播放| 国产精品成人免费| 97久久久精品综合88久久| 国产精品欧美极品| 成人a区在线观看| 亚洲欧洲日韩女同| 色噜噜夜夜夜综合网| 一区二区三区在线观看网站| 91老师国产黑色丝袜在线| 亚洲免费资源在线播放| 欧美亚州韩日在线看免费版国语版| 最新国产精品久久精品| 色婷婷av一区二区三区软件 | 精品剧情在线观看| 韩国精品主播一区二区在线观看| 91精品国产综合久久蜜臀| 石原莉奈在线亚洲三区| 日韩欧美国产三级| 国产91清纯白嫩初高中在线观看| 国产欧美精品国产国产专区| 91蜜桃视频在线| 亚洲一区二区三区四区在线观看| 欧美一区二区三区在线视频| 国产精品系列在线观看| 日韩伦理免费电影| 69av一区二区三区| 国产一区二区精品久久| 成人免费小视频| 欧美高清视频一二三区| 激情六月婷婷久久| 亚洲欧美电影院| 91精品国产综合久久精品| 国产精品一区二区视频| 亚洲激情欧美激情| 精品剧情v国产在线观看在线| 99免费精品视频| 日本成人中文字幕在线视频| 中文字幕巨乱亚洲| 欧美精品vⅰdeose4hd| 国产一区二区电影| 亚洲国产精品久久人人爱蜜臀| 日韩美女视频一区二区在线观看| aaa欧美大片| 另类小说综合欧美亚洲| 一区二区在线观看视频在线观看| 欧美一区二区三区视频在线| 99久久精品一区二区| 看片的网站亚洲| 一区二区视频在线看| 欧美大黄免费观看| 91视频.com| 国产精品91xxx| 日本aⅴ亚洲精品中文乱码| 亚洲色图视频网| 精品国产精品一区二区夜夜嗨| 色老汉一区二区三区| 国产精品一级在线| 蜜臀久久久99精品久久久久久| 一区二区三区四区亚洲| 国产婷婷色一区二区三区在线| 亚洲精品在线电影| 在线亚洲精品福利网址导航| 国产99一区视频免费| 乱中年女人伦av一区二区| 亚洲综合成人网| 亚洲欧美一区二区三区孕妇| 久久久久久久久久电影| 日韩免费福利电影在线观看| 欧美群妇大交群的观看方式| 91麻豆精东视频| 成人av电影免费在线播放| 国产一区二区久久| 国产在线国偷精品免费看| 免费欧美高清视频| 日本女人一区二区三区| 婷婷久久综合九色综合伊人色| 综合婷婷亚洲小说| 17c精品麻豆一区二区免费| 国产精品护士白丝一区av| 国产精品污污网站在线观看| 久久久精品日韩欧美| 国产婷婷色一区二区三区| 久久精品人人做人人爽人人| 久久久久久久综合色一本| 久久久久久一二三区| 久久免费美女视频| 国产午夜亚洲精品羞羞网站| 国产午夜亚洲精品理论片色戒| 2017欧美狠狠色| 久久久99精品免费观看不卡| 久久精品欧美一区二区三区不卡| www成人在线观看| 国产午夜亚洲精品理论片色戒| 国产日韩欧美一区二区三区综合| 国产网站一区二区| 中文字幕亚洲精品在线观看| 国产精品久久久久久久久免费樱桃| 国产欧美日韩中文久久| 亚洲欧洲av色图| 亚洲一二三四在线| 免费在线观看一区| 国产成人啪免费观看软件| 成人天堂资源www在线| 91女人视频在线观看| 欧美亚洲高清一区| 精品国产网站在线观看| 中文字幕av一区二区三区免费看| 亚洲精品日韩综合观看成人91| 亚洲第一搞黄网站| 久久99精品国产麻豆婷婷 | 欧美在线观看视频一区二区三区| 在线视频一区二区三| 日韩一级完整毛片| 中文字幕av在线一区二区三区| 樱花影视一区二区| 另类小说综合欧美亚洲| 成年人网站91| 欧美一级欧美一级在线播放| 久久综合狠狠综合久久综合88| 中文字幕亚洲电影| 奇米色777欧美一区二区| 国产毛片精品国产一区二区三区| jlzzjlzz亚洲日本少妇| 欧美一三区三区四区免费在线看| 久久久久久久精| 亚洲成人先锋电影| 国产电影一区二区三区| 欧美无砖专区一中文字| 久久久久久久久久久黄色| 亚洲亚洲精品在线观看| 麻豆91在线观看| 在线免费不卡视频| 久久精品在线观看| 日韩av不卡在线观看| jvid福利写真一区二区三区| 精品国产一区久久| 亚洲一区二区五区| 久久久久久99久久久精品网站| 国产亚洲1区2区3区| 免费在线观看精品| 国产a区久久久| www久久精品| 美女诱惑一区二区| 精品日韩一区二区三区免费视频| 伊人婷婷欧美激情| 欧美日韩激情一区二区| 欧美不卡一区二区| 亚洲乱码日产精品bd| 日本福利一区二区| 国产一区视频在线看| 麻豆精品久久精品色综合| 91视视频在线观看入口直接观看www| 亚洲精品在线观看网站| 五月激情丁香一区二区三区| 色伊人久久综合中文字幕| 欧美国产激情二区三区| 精品夜夜嗨av一区二区三区| 91精品黄色片免费大全| 五月天视频一区| 欧美日韩一区二区在线视频| 亚洲综合在线五月| 91社区在线播放| 亚洲人快播电影网| 99精品欧美一区| 国产精品久99| 91日韩一区二区三区| 亚洲欧美影音先锋| 91麻豆高清视频| 亚洲男人的天堂网| 色婷婷av久久久久久久| 亚洲国产一区二区a毛片| 91国产福利在线|