Esempio n. 1
0
TextureData* TextureData::FromDDS(char* source)
{
	Textures.InitReader();
	while(Textures.Read())
	{
		if(strcasecmp(Textures.Cur->Name,source))
			return Textures.Cur;
	}

	TextureData* Texture = new TextureData();
	Texture->CreateData();
	DDSLoader::loadDds(source);
	strcpy(Texture->Name,source);
	//Textures.Add(textureData);

	return Texture;
}
Esempio n. 2
0
// Generate Subtriangles for each Face
void Brush::PerformIntersections(ListContainer<SimpleTriangle>* resultingTriangles)
{
	ListContainer<SimpleTriangle>* subTriangles;

	if(!PerformedIntersections)
	{
		ListContainer<MapTriangle> IntersectionTriangles;
		IntersectionTriangles.PerformCleanup = false;
		ListContainer<MapTriangle>* curTriangles;
		bool isHidden;
		vec3 curCenter;
		float threshold = 0.01f;

		// Make a Local list with possible intersections
		IntersectingBrushes.InitReader();
		while(IntersectingBrushes.Read())
		{
			curTriangles = &IntersectingBrushes.Cur->Triangles;
			curTriangles->InitReader();
			while(curTriangles->Read())
			{
				IntersectionTriangles.Add(curTriangles->Cur);
			}
		}

		// Perform Operations Per Triangle
		Triangles.GetIndex();
		for (int i = 0; i < Triangles.Length; i++)
		{
			Triangles.Index[i]->GenerateSubTriangles(&IntersectionTriangles);

			// Perform Operations Per Sub Triangle
			subTriangles = &Triangles.Index[i]->SubTriangles;
			subTriangles->GetIndex();
			int currentLength = subTriangles->Length;
			for (int j = 0; j < currentLength; j++)
			{
				//Visibility Testing
				isHidden = false;
				curCenter = subTriangles->Index[j]->Center();
				curCenter += subTriangles->Index[j]->Normal()*threshold;
				IntersectingBrushes.InitReader();
				while (IntersectingBrushes.Read())
				{
					if(IntersectingBrushes.Cur->PointTest(curCenter))
					{
						subTriangles->RemoveDelete(subTriangles->Index[j]);
						break;
					}
				}
			}
		}
		PerformedIntersections = true;
	}

	// Return Subtriangles
	Triangles.InitReader();
	while(Triangles.Read())
	{
		subTriangles = &Triangles.Cur->SubTriangles;
		subTriangles->InitReader();
		while(subTriangles->Read())
		{
			resultingTriangles->Add(subTriangles->Cur->Copy());
		}
	}
}