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

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

?? md3.cpp

?? Direct3D游戲編程入門教程源代碼.rar
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
	for(int j = 0; j < iNumMeshes; j++)
	{
			delete[] pMd3Meshes[j].pTexNames;
			delete[] pMd3Meshes[j].pTriangles;
			delete[] pMd3Meshes[j].pfTextureCoords;
			delete[] pMd3Meshes[j].vMeshFrames;
	}

	if (iNumMeshes)
		delete[] pMd3Meshes;
}

//-----------------------------------------------------------------------------
// Name: InitDeviceObjects(LPDIRECT3DDEVICE8 lpD3Ddevice)
// Desc: Handles the vertex buffer and textures stuff
//-----------------------------------------------------------------------------
void CMD3Model::InitDeviceObjects(LPDIRECT3DDEVICE8 lpD3Ddevice)
{
	CreateVB(lpD3Ddevice);
	CreateTextures(lpD3Ddevice);
}

//-----------------------------------------------------------------------------
// Name: InitDeviceObjects(LPDIRECT3DDEVICE8 lpD3Ddevice)
// Desc: Handles the vertex buffer and textures stuff
//-----------------------------------------------------------------------------
void CMD3Model::DeleteDeviceObjects()
{
	DeleteVB();
	DeleteTextures();
}

//----------------------------------------------------------------
// Name: CreateVB()
// Desc: Creates vertex buffer with all meshframes one 
//       after another.
//----------------------------------------------------------------
void CMD3Model::CreateVB(LPDIRECT3DDEVICE8 lpD3Ddevice)
{
	DWORD m_dwNumofVertices = 0;
	int iVertexNum;

	// get the indices number to provide the size of the vertex buffer
	for(int k = 0; k < iNumMeshes; k++)
			for(int i = 0; i < pMd3Meshes[k].iNumTriangles; i++)
				for(int j = 0; j < 3; j++)
				m_dwNumofVertices++;

	// create vertex buffer
    lpD3Ddevice->CreateVertexBuffer(m_dwNumofVertices * sizeof(MD3VERTEXBUFFERSTRUCT),
                                    D3DUSAGE_WRITEONLY, 0, D3DPOOL_MANAGED,
                                    &m_pVB);
    MD3VERTEXBUFFERSTRUCT* v;
	m_dwNumofVertices = 0;
	int iAnimationFrameNum = 0;

    m_pVB->Lock( 0, 0, (BYTE**)&v, 0 );
	for(k = 0; k < iNumMeshes; k++)
	{
		for(int i = 0; i < pMd3Meshes[k].iNumTriangles; i++)
		{
			for(int j = 0; j < 3; j++)
			{
				iVertexNum = pMd3Meshes[k].pTriangles[i][j];

				v[m_dwNumofVertices].p= D3DXVECTOR3(
				   pMd3Meshes[k].vMeshFrames[iAnimationFrameNum][iVertexNum].x,	
  				   pMd3Meshes[k].vMeshFrames[iAnimationFrameNum][iVertexNum].y, 
				   pMd3Meshes[k].vMeshFrames[iAnimationFrameNum][iVertexNum].z);
				v[m_dwNumofVertices].tu = pMd3Meshes[k].pfTextureCoords[iVertexNum].u;
				v[m_dwNumofVertices].tv = pMd3Meshes[k].pfTextureCoords[iVertexNum].v;
				m_dwNumofVertices++;
			}
		}
	}
	m_pVB->Unlock();

}

//-----------------------------------------------------------------------------
// Name: DeleteVB()
// Desc: Destroys the vertex buffer for the model
//-----------------------------------------------------------------------------
void CMD3Model::DeleteVB()
{
	if (m_pVB != NULL)
		SAFE_RELEASE( m_pVB );
}

//-----------------------------------------------------------------------------
// Name: CreateTextures(LPDIRECT3DDEVICE8 lpD3Ddevice)
// Desc: Creates all the textures of a mesh
// How to open a texture for a *.md3 file:
//	1. The number and the path of the textures is stored in 
//	   the *.md3 file. The number of provided textures is stored on 
//	   a per mesh basis. 
//	2. The name of the texture should be provided in the *.skin 
//	   files. Try to get it.
//	3. If there's no texture entry in the *.md3 file and it exists 
//	   no *.skin file, try to catch the texture by searching through 
//	   the directory, where the *.md3 file is located. 
//	4. If there's no texture entry in the *.md3 file, a *.skin file
//	   is non-existance and the texture is not located in the directory
//	   where the *.md3 file is located ... try to talk to your graphic 
//	   artist :-)
//-----------------------------------------------------------------------------
void CMD3Model::CreateTextures(LPDIRECT3DDEVICE8 lpD3Ddevice)
{
	// create and open log file
	LogFile = fopen("md3 textures.txt","w");

	fprintf(LogFile,"--- Textures --- \n");
	fprintf(LogFile,"Number of meshes: %d\n", iNumMeshes);

	for(int j = 0; j < iNumMeshes; j++)
	{
		pMd3Meshes[j].pTexturesInterfaces = 
			new LPDIRECT3DTEXTURE8[pMd3Meshes[j].iNumTextures];

		fprintf(LogFile,"Number of textures in mesh %s: %d\n", 
				pMd3Meshes[j].cName ,pMd3Meshes[j].iNumTextures);

		// load and create pMd3Meshes->iNumTextures
		for (int i = 0; i < pMd3Meshes[j].iNumTextures; i++)
		{
			// temporary: holds the texture path, which is stored in *.md3
			CHAR *cTempTexturePath;
			
			// to store the texture name f.e. plasma.tga without path
			// because D3DTextr_CreateTextureFromFile() only accepts
			// textures this way
			CHAR *cTextureName;
		
			cTempTexturePath = pMd3Meshes[j].pTexNames[i];
			int length=strlen(cTempTexturePath);

			// hardcode alert !!
			// models/players/ == 15 chars
			// if the texture path is shorter than 15 chars, there isn't
			// any entry in the *.md3 file at all ... 
			if (length > 15) 
			{
				int count = 0;
				int iTempLength = length;

				// count down until /
				while (cTempTexturePath[iTempLength--] != '/')
					count++;

				// allocate memory for the texture name
				cTextureName = new CHAR[count];

				// copy the texture name
				while (count--)
				{
					cTextureName[count] = cTempTexturePath[length];
					length--;
				}

				// show the used texture path and texture name 
				fprintf(LogFile,"texture path: %s\n", cTempTexturePath);
				fprintf(LogFile,"texture name: %s\n\n", cTextureName);

				if( FAILED( D3DXCreateTextureFromFile(lpD3Ddevice, 
											cTextureName, 
											&pMd3Meshes[j].pTexturesInterfaces[i])))
				{
					fprintf(LogFile,"D3DXCreateTextureFromFile: could not create texture: %s\n", cTextureName);
	
					pMd3Meshes[j].iNumTextures = 0;
					pMd3Meshes[j].pTexturesInterfaces[i] = 0;
				}
				delete[] cTextureName;
			}
			/* else 
				1. open skin file, read tex name and load texture as above
				2. try to catch the texture from the directory, where the md3 file
				resides, with the name of this file as tex name.
			*/
			else
			{
				pMd3Meshes[j].iNumTextures = 0;
				pMd3Meshes[j].pTexturesInterfaces[i] = 0;
			}

		}
  }
	// close the LogFile
	fclose(LogFile);
}

//-----------------------------------------------------------------------------
// Name: DestroyTextures()
// Desc: Destroys the textures created by CreateTextures()
//-----------------------------------------------------------------------------
void CMD3Model::DeleteTextures()
{
	for(int j = 0; j < iNumMeshes; j++)
	{
	  // destroy textures
	  for (int i = 0; i < pMd3Meshes[j].iNumTextures; i++)
	  {
		SAFE_RELEASE(pMd3Meshes[j].pTexturesInterfaces[i]);
	  }
	}
}

//-----------------------------------------------------------------------------
// Name: Render()
// Desc: Renders the model
//-----------------------------------------------------------------------------
void CMD3Model::Render(LPDIRECT3DDEVICE8 lpD3Ddevice)
{
	for(int k = 0; k < iNumMeshes; k++)
	{
		DWORD dwStartVertex;
		if (k != 0)
		  dwStartVertex += pMd3Meshes[k-1].iNumTriangles * 3;
		else 
		  dwStartVertex = 0;

		if (pMd3Meshes[k].iNumTextures > 0)
		{
			for (int i = 0; i < pMd3Meshes[k].iNumTextures; i++)
			{
			lpD3Ddevice->SetTexture( 0, pMd3Meshes[k].pTexturesInterfaces[i]);
			lpD3Ddevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
			lpD3Ddevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );

			lpD3Ddevice->SetVertexShader( FVF_MD3VERTEXBUFFERSTRUCT);
			lpD3Ddevice->SetStreamSource( 0, m_pVB, sizeof(MD3VERTEXBUFFERSTRUCT) );
			lpD3Ddevice->DrawPrimitive( D3DPT_TRIANGLELIST, dwStartVertex, pMd3Meshes[k].iNumTriangles);
			}
		}
		else // just in case there are no textures in the mesh
		{
			lpD3Ddevice->SetTexture( 0, 0);

			lpD3Ddevice->SetVertexShader( FVF_MD3VERTEXBUFFERSTRUCT);
			lpD3Ddevice->SetStreamSource( 0, m_pVB, sizeof(MD3VERTEXBUFFERSTRUCT) );
			lpD3Ddevice->DrawPrimitive( D3DPT_TRIANGLELIST, dwStartVertex, pMd3Meshes[k].iNumTriangles);
		}
	}
}

//----------------------------------------------------------------------------
// Name: ReadLong()
// Desc: reads a long from FILE
//----------------------------------------------------------------------------
long CMD3Model::ReadLong(FILE* File)
{
	unsigned char x[4];
	fread(x, sizeof(x), 1, File);
	return (x[3] << 24) + (x[2] << 16) + (x[1] << 8) + x[0];
}

//----------------------------------------------------------------------------
// Name: ReadShort()
// Desc: reads a short from FILE
//----------------------------------------------------------------------------
short CMD3Model::ReadShort(FILE* File)
{
	unsigned char x[2];
	fread(x, sizeof(x), 1, File);
	return (x[1] << 8) + x[0];
}

//----------------------------------------------------------------------------
// Name: ReadFloat()
// Desc: reads a float from FILE
//----------------------------------------------------------------------------
float CMD3Model::ReadFloat(FILE* File)
{
	unsigned char x[4];
	unsigned long l;
	fread(x, sizeof(x), 1, File);
	l = (x[3] << 24) + (x[2] << 16) + (x[1] << 8) + x[0];
	return *(float *)&l;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产成人av一区二区三区在线| 偷拍亚洲欧洲综合| 精品三级av在线| 日韩写真欧美这视频| 4438x成人网最大色成网站| 欧美另类高清zo欧美| 欧美日韩视频在线观看一区二区三区| 色偷偷成人一区二区三区91| 色综合久久中文综合久久牛| 色一情一乱一乱一91av| 欧美三日本三级三级在线播放| 色婷婷av久久久久久久| 欧美日韩黄色一区二区| 欧美精品日日鲁夜夜添| 亚洲精品一区二区三区香蕉| 国产蜜臀av在线一区二区三区| 亚洲欧美怡红院| 亚洲激情av在线| 亚洲电影激情视频网站| 美女免费视频一区二区| 国产不卡高清在线观看视频| 99久久er热在这里只有精品66| 欧美性受xxxx| 2020国产精品久久精品美国| 中文字幕在线观看一区| 婷婷中文字幕一区三区| 精品亚洲aⅴ乱码一区二区三区| 国产福利91精品一区二区三区| 91丨九色丨蝌蚪丨老版| 欧美精品视频www在线观看| 久久色视频免费观看| 亚洲视频1区2区| 琪琪一区二区三区| 高清av一区二区| 日本高清无吗v一区| 精品成人佐山爱一区二区| 综合久久给合久久狠狠狠97色| 亚洲一区二区免费视频| 国产麻豆精品在线观看| 欧美无人高清视频在线观看| 欧美精品一区二区三区久久久 | 国产精品亚洲第一区在线暖暖韩国 | 成人av在线电影| 777久久久精品| 亚洲婷婷综合久久一本伊一区| 日精品一区二区三区| 99久久精品免费看| 久久久久久夜精品精品免费| 亚洲国产欧美在线| 成人av综合在线| 久久亚洲精精品中文字幕早川悠里| 亚洲精品老司机| 高清不卡在线观看av| 精品国产一区二区三区忘忧草| 亚洲夂夂婷婷色拍ww47| 99精品久久99久久久久| 久久欧美一区二区| 日韩av一级电影| 在线观看国产91| 亚洲欧美二区三区| 成人美女视频在线观看| 精品黑人一区二区三区久久| 婷婷成人综合网| 欧美日韩一区二区三区免费看| 136国产福利精品导航| 成人高清伦理免费影院在线观看| 2023国产精华国产精品| 韩国成人福利片在线播放| 欧美精品国产精品| 亚洲国产成人高清精品| 欧洲av在线精品| 一区二区三区免费| 欧洲色大大久久| 一区二区三区四区乱视频| 色噜噜久久综合| 亚洲女人****多毛耸耸8| 91性感美女视频| 亚洲精品国产一区二区精华液| 91啪在线观看| 一区二区三区视频在线观看| 欧洲在线/亚洲| 亚洲成人精品在线观看| 欧美肥大bbwbbw高潮| 丝袜美腿亚洲色图| 欧美大白屁股肥臀xxxxxx| 九色综合狠狠综合久久| 2023国产精品自拍| 成人黄色大片在线观看| 国产精品白丝在线| 欧美在线观看视频一区二区| 一区二区成人在线视频| 欧美福利视频一区| 久久精品国产成人一区二区三区| 精品国产乱码久久久久久图片| 懂色av一区二区三区免费观看| 中文字幕不卡三区| 在线观看www91| 性感美女极品91精品| 日韩精品一区二区三区视频| 国产综合色在线视频区| 国产精品久久久久桃色tv| 91麻豆精东视频| 日韩成人一区二区三区在线观看| 久久久久久99久久久精品网站| 97久久精品人人做人人爽50路| 一区二区三区四区不卡在线| 精品美女在线观看| 成人av高清在线| 婷婷中文字幕综合| 欧美激情一区二区三区四区 | 亚洲一区二区三区四区在线免费观看 | 在线观看91精品国产入口| 日本亚洲欧美天堂免费| 亚洲国产成人自拍| 欧美精品久久99久久在免费线 | 精品无人区卡一卡二卡三乱码免费卡| 国产午夜久久久久| 欧美日韩国产中文| 国产91在线|亚洲| 亚洲午夜久久久久久久久电影网| 精品福利二区三区| 欧美日韩国产高清一区二区三区| 国产精品456| 午夜不卡av在线| 国产精品色一区二区三区| 4438x成人网最大色成网站| av亚洲精华国产精华精| 麻豆一区二区三区| 亚洲成人资源网| 亚洲人成网站在线| 欧美国产乱子伦| 日韩欧美久久久| 在线不卡中文字幕播放| 色呦呦国产精品| 成人av在线一区二区三区| 韩国三级在线一区| 免费黄网站欧美| 亚洲r级在线视频| 亚洲激情网站免费观看| 成人欧美一区二区三区视频网页| 精品久久久久一区| 91精品国产乱码| 欧美在线观看一区| 在线视频欧美精品| 99久久精品国产一区| 成人综合激情网| 精品一区二区三区免费毛片爱| 亚洲一区二区免费视频| 亚洲综合色区另类av| 亚洲欧洲日韩av| 国产精品久久久久久久久快鸭| 久久五月婷婷丁香社区| 久久亚洲影视婷婷| 久久精品在线免费观看| 久久久精品国产免大香伊| 2023国产精品自拍| 久久蜜臀精品av| 欧美国产日韩亚洲一区| 欧美激情综合网| 国产精品乱码一区二三区小蝌蚪| 中文在线一区二区| 中文字幕一区二| 亚洲制服丝袜一区| 日韩国产欧美在线观看| 精品一区二区三区影院在线午夜| 精品亚洲国内自在自线福利| 国产精品99久久久久| 99精品桃花视频在线观看| 91在线精品一区二区| 欧美性猛交xxxx黑人交| 欧美一区二区视频在线观看| 日韩女优制服丝袜电影| 久久美女艺术照精彩视频福利播放| 国产亚洲欧美日韩在线一区| 亚洲欧美在线另类| 婷婷夜色潮精品综合在线| 久久国产精品99久久人人澡| 精品一区二区三区香蕉蜜桃| 成人亚洲精品久久久久软件| 色系网站成人免费| 欧美一区二区三区不卡| 国产女主播一区| 亚洲午夜影视影院在线观看| 奇米一区二区三区av| 成人午夜免费视频| 在线亚洲人成电影网站色www| 91精品久久久久久久99蜜桃| 久久久久久97三级| 亚洲国产精品影院| 国产风韵犹存在线视精品| 99视频精品全部免费在线| 91精品国产免费久久综合| 国产精品午夜免费| 视频一区欧美精品| 成人午夜激情在线| 91精品在线观看入口| 国产精品国产自产拍高清av王其 | 国产欧美久久久精品影院| 亚洲一区二区三区小说| 岛国精品一区二区|