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

📄 mlrtriangleclipping.hpp

📁 机甲指挥官2源代码
💻 HPP
📖 第 1 页 / 共 4 页
字号:
					, state.GetFogMode()
	#endif	//	FOG_HACK

				);
//				CheckVertices1( gos_vertices2uv+numGOSVertices, 1 );
			}
			else
			{
				GOSCopyData(
					&gos_vertices[numGOSVertices],
					transformedCoords->GetData(),
	#ifdef I_SAY_YES_TO_COLOR
					actualColors->GetData(),
	#endif	//	I_SAY_YES_TO_COLOR

	#ifdef I_SAY_YES_TO_TERRAIN
					clipTexCoords->GetData(),
	#else	//	I_SAY_YES_TO_TERRAIN
					texCoords.GetData(),
	#endif	//	I_SAY_YES_TO_TERRAIN
					j
	#if FOG_HACK
					, state.GetFogMode()
	#endif	//	FOG_HACK

				);
				(*texCoords2)[tex2count++] = texCoords[numVertices + j];
			}
#else	//	I_SAY_YES_TO_DUAL_TEXTURES
	#ifdef I_SAY_YES_TO_DETAIL_TEXTURES
			if(	MLRState::GetMultitextureLightMap() == true &&
				state.GetMultiTextureMode()!=MLRState::MultiTextureOffMode &&
				gEnableDetailTexture==1
			)
			{
				GOSCopyData(
					&gos_vertices2uv[numGOSVertices],
					transformedCoords->GetData(),
		#ifdef I_SAY_YES_TO_COLOR
					actualColors->GetData(),
		#endif	//	I_SAY_YES_TO_COLOR

		#ifdef I_SAY_YES_TO_TERRAIN
					clipTexCoords->GetData(),
		#else	//	I_SAY_YES_TO_TERRAIN
					texCoords.GetData(),
		#endif	//	I_SAY_YES_TO_TERRAIN
		#ifdef I_SAY_YES_TO_TERRAIN
					clipTexCoords->GetData(),
		#else	//	I_SAY_YES_TO_TERRAIN
					texCoords.GetData(),
		#endif	//	I_SAY_YES_TO_TERRAIN
					j
		#if FOG_HACK
					, state.GetFogMode()
		#endif	//	FOG_HACK
				);
			}
			else
	#endif	//	I_SAY_YES_TO_DETAIL_TEXTURES
			{
				GOSCopyData(
					&gos_vertices[numGOSVertices],
					transformedCoords->GetData(),
		#ifdef I_SAY_YES_TO_COLOR
					actualColors->GetData(),
		#endif	//	I_SAY_YES_TO_COLOR

		#ifdef I_SAY_YES_TO_TERRAIN
					clipTexCoords->GetData(),
		#else	//	I_SAY_YES_TO_TERRAIN
					texCoords.GetData(),
		#endif	//	I_SAY_YES_TO_TERRAIN
					j
		#if FOG_HACK
					, state.GetFogMode()
		#endif	//	FOG_HACK
				);
			}
#endif	//	I_SAY_YES_TO_DUAL_TEXTURES

			if(textureAnimation)
			{
				gos_vertices[numGOSVertices].u += deltaU;
				gos_vertices[numGOSVertices].v += deltaV;
			}

#ifdef LAB_ONLY
			if(gShowClippedPolys)
			{
				gos_vertices[numGOSVertices].argb = 0xff0000ff;
				gos_vertices[numGOSVertices].u = 0.0f;
				gos_vertices[numGOSVertices].v = 0.0f;
			}
#endif	//	LAB_ONLY

#ifdef I_SAY_YES_TO_MULTI_TEXTURES
			for(m=1;m<currentNrOfPasses;m++)
			{
				extraMultiTexCoords[m][tex2count[m]++] = multiTexCoordsPointers[m][j];
			}
#endif	//	I_SAY_YES_TO_MULTI_TEXTURES
			numGOSVertices++;
		}
	}

	for(i=0,j=0;i<numOfTriangles;j+=3,++i)
	{
		if(testList[i] == 0)
		{
			continue;
		}

		if(db==false)
		{
			Verify((vt->GetLastIndex() + 3 + numGOSIndices) < vt->GetLength());
		}
		else
		{
			Verify(3 + numGOSIndices < 2*Limits::Max_Number_Vertices_Per_Mesh);
		}

		Verify(indexOffset[index[j]] < numGOSVertices);
		gos_indices[numGOSIndices] = indexOffset[index[j]];

		Verify(indexOffset[index[j+2]] < numGOSVertices);
		gos_indices[numGOSIndices+1] = indexOffset[index[j+2]];

		Verify(indexOffset[index[j+1]] < numGOSVertices);
		gos_indices[numGOSIndices+2] = indexOffset[index[j+1]];

		numGOSIndices += 3;
	}

	unsigned short stride;
	if(myNumberUsedClipLength > 0)
	{
		for(i=0,j=0;i<myNumberUsedClipLength;i++)
		{
#ifdef _ARMOR
			stride = static_cast<unsigned short>((*clipExtraLength)[i] & 0x7fff);
#else	//	_ARMOR
			stride = (*clipExtraLength)[i];
#endif	//	_ARMOR
			for(k=1;k<stride-1;k++)
			{
				if(db==false)
				{
					Verify((vt->GetLast() + 3 + numGOSVertices) < vt->GetLength());
					Verify((vt->GetLastIndex() + 3 + numGOSIndices) < vt->GetLength());
				}
				else
				{
					Verify(3 + numGOSVertices < 2*Limits::Max_Number_Vertices_Per_Mesh);
					Verify(3 + numGOSIndices < 2*Limits::Max_Number_Vertices_Per_Mesh);
				}

#ifdef I_SAY_YES_TO_DUAL_TEXTURES
				if(MLRState::GetMultitextureLightMap() == true && state.GetMultiTextureMode()!=MLRState::MultiTextureOffMode)
				{
					GOSCopyTriangleData(
						&gos_vertices2uv[numGOSVertices],
						clipExtraCoords->GetData(),
	#ifdef I_SAY_YES_TO_COLOR
						clipExtraColors->GetData(),
	#endif	//	I_SAY_YES_TO_COLOR
						clipExtraTexCoords->GetData(),
						clipExtraTexCoords2->GetData(),
						j, j+k+1, j+k
	#if FOG_HACK
						, state.GetFogMode()
	#endif	//	FOG_HACK
					);
//					CheckVertices1( gos_vertices2uv+numGOSVertices, 3 );
				}
				else
				{
					GOSCopyTriangleData(
						&gos_vertices[numGOSVertices],
						clipExtraCoords->GetData(),
	#ifdef I_SAY_YES_TO_COLOR
						clipExtraColors->GetData(),
	#endif	//	I_SAY_YES_TO_COLOR
						clipExtraTexCoords->GetData(),
						j, j+k+1, j+k
	#if FOG_HACK
						, state.GetFogMode()
	#endif	//	FOG_HACK
					);

					(*texCoords2)[tex2count++] = (*clipExtraTexCoords2)[j];
					(*texCoords2)[tex2count++] = (*clipExtraTexCoords2)[j+k+1];
					(*texCoords2)[tex2count++] = (*clipExtraTexCoords2)[j+k];
				}
#else //	I_SAY_YES_TO_DUAL_TEXTURES
	#ifdef I_SAY_YES_TO_DETAIL_TEXTURES
				if(	MLRState::GetMultitextureLightMap() == true &&
					state.GetMultiTextureMode()!=MLRState::MultiTextureOffMode &&
					gEnableDetailTexture==1
				)
				{
					GOSCopyTriangleData(
						&gos_vertices2uv[numGOSVertices],
						clipExtraCoords->GetData(),
		#ifdef I_SAY_YES_TO_COLOR
						clipExtraColors->GetData(),
		#endif	//	I_SAY_YES_TO_COLOR
						clipExtraTexCoords->GetData(),
						clipExtraTexCoords->GetData(),
						j, j+k+1, j+k
		#if FOG_HACK
						, state.GetFogMode()
		#endif	//	FOG_HACK
					);
				}
				else
	#endif	//	I_SAY_YES_TO_DETAIL_TEXTURES
				{
					GOSCopyTriangleData(
						&gos_vertices[numGOSVertices],
						clipExtraCoords->GetData(),
		#ifdef I_SAY_YES_TO_COLOR
						clipExtraColors->GetData(),
		#endif	//	I_SAY_YES_TO_COLOR
						clipExtraTexCoords->GetData(),
						j, j+k+1, j+k
		#if FOG_HACK
						, state.GetFogMode()
		#endif	//	FOG_HACK
					);
				}
#endif //	I_SAY_YES_TO_DUAL_TEXTURES

				if(textureAnimation)
				{
					gos_vertices[numGOSVertices].u += deltaU;
					gos_vertices[numGOSVertices].v += deltaV;

					gos_vertices[numGOSVertices+1].u += deltaU;
					gos_vertices[numGOSVertices+1].v += deltaV;

					gos_vertices[numGOSVertices+2].u += deltaU;
					gos_vertices[numGOSVertices+2].v += deltaV;
				}

#ifdef LAB_ONLY
				if(gShowClippedPolys)
				{
					if((*clipExtraLength)[i] & 0x8000)
					{
						gos_vertices[numGOSVertices].argb = 0xffff0000;
						gos_vertices[numGOSVertices].u = 0.0f;
						gos_vertices[numGOSVertices].v = 0.0f;

						gos_vertices[numGOSVertices+1].argb = 0xffff0000;
						gos_vertices[numGOSVertices+1].u = 0.0f;
						gos_vertices[numGOSVertices+1].v = 0.0f;

						gos_vertices[numGOSVertices+2].argb = 0xffff0000;
						gos_vertices[numGOSVertices+2].u = 0.0f;
						gos_vertices[numGOSVertices+2].v = 0.0f;
					}
					else
					{
						gos_vertices[numGOSVertices].argb = 0xffff9999;
						gos_vertices[numGOSVertices].u = 0.0f;
						gos_vertices[numGOSVertices].v = 0.0f;

						gos_vertices[numGOSVertices+1].argb = 0xffff9999;
						gos_vertices[numGOSVertices+1].u = 0.0f;
						gos_vertices[numGOSVertices+1].v = 0.0f;

						gos_vertices[numGOSVertices+2].argb = 0xffff9999;
						gos_vertices[numGOSVertices+2].u = 0.0f;
						gos_vertices[numGOSVertices+2].v = 0.0f;
					}
				}
#endif	//	LAB_ONLY

#ifdef I_SAY_YES_TO_MULTI_TEXTURES
				for(m=1;m<currentNrOfPasses;m++)
				{
					extraMultiTexCoords[m][tex2count[m]++] = clipExtraMultiTexCoords[m][j];
					extraMultiTexCoords[m][tex2count[m]++] = clipExtraMultiTexCoords[m][j+k+1];
					extraMultiTexCoords[m][tex2count[m]++] = clipExtraMultiTexCoords[m][j+k];
				}
#endif	//	I_SAY_YES_TO_MULTI_TEXTURES

				if(db==false)
				{
					Verify((vt->GetLastIndex() + 3 + numGOSIndices) < vt->GetLength());
				}
				else
				{
					Verify(3 + numGOSIndices < 2*Limits::Max_Number_Vertices_Per_Mesh);
				}
				Verify(numGOSIndices%3 == 0);

				gos_indices[numGOSIndices] = numGOSVertices;
				gos_indices[numGOSIndices+1] = (unsigned short)(numGOSVertices + 1);
				gos_indices[numGOSIndices+2] = (unsigned short)(numGOSVertices + 2);

				numGOSVertices += 3;
				numGOSIndices += 3;
			}

			j += stride;
		}
#if HUNT_CLIP_ERROR
		DEBUG_STREAM << "***" << endl << endl;
#endif	//	HUNT_CLIP_ERROR

	}

#ifdef I_SAY_YES_TO_DUAL_TEXTURES
	if(MLRState::GetMultitextureLightMap() == false || state.GetMultiTextureMode()==MLRState::MultiTextureOffMode)
	{
		Verify (tex2count == numGOSVertices);
		if(db==false)
		{
			Verify (vt->GetLast() + 2*numGOSVertices < vt->GetLength());
		}
		else
		{
			Verify (2*numGOSVertices < 2*Limits::Max_Number_Vertices_Per_Mesh);
		}

		memcpy(gos_vertices + numGOSVertices, gos_vertices, numGOSVertices * sizeof(GOSVertex));

		if(textureAnimation2)
		{
			for(i=0,j=numGOSVertices;i<numGOSVertices;i++,j++)
			{
				gos_vertices[j].u = (*texCoords2)[i][0] + deltaU2;
				gos_vertices[j].v = (*texCoords2)[i][1] + deltaV2;
			}
		}
		else
		{
			for(i=0,j=numGOSVertices;i<numGOSVertices;i++,j++)
			{
				gos_vertices[j].u = (*texCoords2)[i][0];
				gos_vertices[j].v = (*texCoords2)[i][1];
			}
		}

		if(db==false)
		{
			vt->Increase(2*numGOSVertices);
		}
	}
	else
	{
		if(db==false)
		{
			vt->Increase2UV(numGOSVertices);
		}
	}
#else	//	I_SAY_YES_TO_DUAL_TEXTURES
	#ifdef I_SAY_YES_TO_DETAIL_TEXTURES
		if(gEnableDetailTexture==1)
		{
			if(	MLRState::GetMultitextureLightMap() == true &&
				state.GetMultiTextureMode()!=MLRState::MultiTextureOffMode 
			)
			{
				for(i=0;i<numGOSVertices;i++)
				{
			#ifdef I_SAY_YES_TO_TERRAIN2
					gos_vertices2uv[i].u2 = gos_vertices2uv[i].u1*xScale;
					gos_vertices2uv[i].v2 = gos_vertices2uv[i].v1*yScale;
			#else	//	I_SAY_YES_TO_TERRAIN2
					gos_vertices2uv[i].u2 = gos_vertices2uv[i].u1*xScale + xOffset + deltaU2;
					gos_vertices2uv[i].v2 = gos_vertices2uv[i].v1*yScale + yOffset + deltaV2;
			#endif	//	I_SAY_YES_TO_TERRAIN2
					Verify(	MLRState::GetHasMaxUVs() ? (gos_vertices2uv[i].u2>=-MLRState::GetMaxUV() && gos_vertices2uv[i].u2<=MLRState::GetMaxUV()) : 1);
					Verify(	MLRState::GetHasMaxUVs() ? (gos_vertices2uv[i].v2>=-MLRState::GetMaxUV() && gos_vertices2uv[i].v2<=MLRState::GetMaxUV()) : 1);

					if(gos_vertices2uv[i].rhw < fadeDetailEnd)
					{
						gos_vertices2uv[i].argb &= 0x00ffffff;
					}
					else
					{
						if(gos_vertices2uv[i].rhw<fadeDetailStart)
						{
							gos_vertices2uv[i].argb &= ((Stuff::Truncate_Float_To_Word((gos_vertices2uv[i].rhw - fadeDetailEnd)*fadeMultiplicator)) << 24) | 0x00ffffff;
						}
					}
				}

				if(db==false)
				{
					vt->Increase2UV(numGOSVertices);
				}
			}
			else
			{
				if(db==false)
				{
					Verify (vt->GetLast() + 2*numGOSVertices < vt->GetLength());
				}
				else
				{
					Verify (2*numGOSVertices < 2*Limits::Max_Number_Vertices_Per_Mesh);
				}

				memcpy(gos_vertices + numGOSVertices, gos_vertices, numGOSVertices * sizeof(GOSVertex));

				stride = 0;
				for(i=0,j=numGOSVertices;i<numGOSVertices;i++,j++)
				{
			#ifdef I_SAY_YES_TO_TERRAIN2
					gos_vertices[j].u = gos_vertices[i].u*xScale;
					gos_vertices[j].v = gos_vertices[i].v*yScale;
			#else	//	I_SAY_YES_TO_TERRAIN2
					gos_vertices[j].u = gos_vertices[i].u*xScale + xOffset + deltaU2;
					gos_vertices[j].v = gos_vertices[i].v*yScale + yOffset + deltaV2;
			#endif	//	I_SAY_YES_TO_TERRAIN2
					Verify(	MLRState::GetHasMaxUVs() ? (gos_vertices[j].u>=-MLRState::GetMaxUV() && gos_vertices[j].u<=MLRState::GetMaxUV()) : 1);
					Verify(	MLRState::GetHasMaxUVs() ? (gos_vertices[j].v>=-MLRState::GetMaxUV() && gos_vertices[j].v<=MLRState::GetMaxUV()) : 1);

					if(gos_vertices[j].rhw < fadeDetailEnd)
					{
						gos_vertices[j].argb &= 0x00ffffff;
					}
					else
					{
						stride++;
						if(gos_vertices[j].rhw<fadeDetailStart)
						{
							gos_vertices[j].argb &= ((Stuff::Truncate_Float_To_Word((gos_vertices[j].rhw - fadeDetailEnd)*fadeMultiplicator)) << 24) | 0x00ffffff;
						}
					}
				}

				if(stride==0)
				{
					detTextureVisible=false;
				}
				else
				{
					detTextureVisible=true;
				}

				if(db==false)
				{
					vt->Increase(2*numGOSVertices);
				}
			}
		}
		else
		{
			if(db==false)
			{
				vt->Increase(numGOSVertices);
			}
		}
	#else	//	I_SAY_YES_TO_DETAIL_TEXTURES
		if(db==false)
		{
			vt->Increase(numGOSVertices);
		}
	#endif	//	I_SAY_YES_TO_DETAIL_TEXTURES
#endif	//		//	I_SAY_YES_TO_DUAL_TEXTURES

#ifdef I_SAY_YES_TO_MULTI_TEXTURES
	for(m=1;m<currentNrOfPasses;m++)
	{
		Verify (tex2count[m] == numGOSVertices);
		if(db==false)
		{
			Verify (vt->GetLast() + numGOSVertices < vt->GetLength());
		}
		else
		{
			Verify (numGOSVertices < 2*Limits::Max_Number_Vertices_Per_Mesh);
		}

		memcpy(gos_vertices + m*numGOSVertices, gos_vertices, numGOSVertices * sizeof(GOSVertex));

		for(i=0,j=numGOSVertices;i<numGOSVertices;i++,j++)
		{
			gos_vertices[j].u = extraMultiTexCoords[m][i][0];
			gos_vertices[j].v = extraMultiTexCoords[m][i][1];
		}

		if(db==false)
		{
			vt->Increase(numGOSVertices);
		}
	}
#endif	//	I_SAY_YES_TO_MULTI_TEXTURES

	if(db==false)
	{
		vt->IncreaseIndex(numGOSIndices);
	}

	visible = numGOSVertices ? (unsigned char)1 : (unsigned char)0;

	if(visible)
	{
	}
	else
	{
	}


#if	0	//def	I_SAY_YES_TO_DUAL_TEXTURES
	if(MLRState::GetMultitextureLightMap() == true && state.GetMultiTextureMode()!=MLRState::MultiTextureOffMode)
	{
		CheckVertices1( gos_vertices2uv, numGOSVertices );
	}
	else
	{
		CheckVertices( gos_vertices, numGOSVertices, false );
	}
#endif	//		//	I_SAY_YES_TO_DUAL_TEXTURES


	Stop_Timer(Clipping_Time);

	return ret;
}

⌨️ 快捷键说明

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