コード例 #1
0
bool UCubiquityMeshComponent::ClearMeshTriangles()
{
	//UE_LOG(CubiquityLog, Log, TEXT("UCubiquityMeshComponent::ClearMeshTriangles"));
	terrainVertices.Empty();
	coloredCubesVertices.Empty();
	indices.Empty();

	if (ModelBodySetup)
	{
		ModelBodySetup->InvalidatePhysicsData(); // This is required for the first time after creation
	}

	UpdateCollision();

	// Need to recreate scene proxy to send it over
	MarkRenderStateDirty();

	return true;
}
コード例 #2
0
ファイル: World.cpp プロジェクト: DeaDSandro/shadowfade
void World::UpdateWorld(time_t diff)
{
	UpdateSessions(diff);
	UpdateCollision(diff);
}
コード例 #3
0
ファイル: ZanshinBasicArrow.cpp プロジェクト: JuanCCS/Zanshin
void AZanshinBasicArrow::Tick(float DeltaTime) 
{
	Super::Tick(DeltaTime);
	UpdateCollision();  
}
コード例 #4
0
bool UCubiquityMeshComponent::SetGeneratedMeshTrianglesTerrain(const Cubiquity::OctreeNode& octreeNode)
{
	//UE_LOG(CubiquityLog, Log, TEXT("UCubiquityMeshComponent::SetGeneratedMeshTrianglesTerrain"));

	uint32_t noOfIndices;
	uint16_t* cubuquityIndices;
	uint16_t noOfVertices;
	const Cubiquity::TerrainVertex* cubiquityVertices;
	octreeNode.getMesh(&noOfVertices, &cubiquityVertices, &noOfIndices, &cubuquityIndices);

	for (uint32_t i = 0; i < noOfVertices; ++i)
	{
		const auto& cubiquityVertex = cubiquityVertices[i];

		FDynamicMeshVertex Vert;

		const auto position = cubiquityVertex.position();
		Vert.Position = FVector(position.x, position.y, position.z);

		const auto normal = cubiquityVertex.normal();
		Vert.TangentZ = FVector(normal.x, normal.y, normal.z);// .SafeNormal();

		const auto materials = cubiquityVertex.materials();
		Vert.Color = FColor(materials[0], materials[1], materials[2], materials[3]); //TODO make this from materials

		Vert.TextureCoordinate.Set(Vert.Position.X, Vert.Position.Y);

		terrainVertices.Add(Vert);
	}

	//The normals are already set but we need the tangents and bitangents. Set these on a per-triangle basis based on the geometry
	for (uint16_t i = 0; i < noOfIndices; ++i)
	{
		const uint16_t index0 = cubuquityIndices[i];
		const uint16_t index1 = cubuquityIndices[++i];
		const uint16_t index2 = cubuquityIndices[++i];

		FDynamicMeshVertex& vertex0 = terrainVertices[index0];
		FDynamicMeshVertex& vertex1 = terrainVertices[index1];
		FDynamicMeshVertex& vertex2 = terrainVertices[index2];

		//Reverse winding order
		indices.Add(index2);
		indices.Add(index1);
		indices.Add(index0);

		//Now calculate the tangent vectors
		const FVector Edge01 = (vertex1.Position - vertex0.Position);
		const FVector Edge02 = (vertex2.Position - vertex0.Position);
		const FVector TangentX = Edge01.GetSafeNormal() * 256.0; //Tangent
		const FVector TangentZ = vertex0.TangentZ; //Normal
		const FVector TangentY = (TangentX ^ TangentZ); //Binormal (bitangent) I assume?

		vertex1.SetTangents(TangentX, TangentY, vertex1.TangentZ);
		vertex2.SetTangents(TangentX, TangentY, vertex2.TangentZ);
	}

	if (ModelBodySetup)
	{
		ModelBodySetup->InvalidatePhysicsData(); // This is required for the first time after creation
	}

	UpdateCollision();

	// Need to recreate scene proxy to send it over
	MarkRenderStateDirty();

	return true;
}
コード例 #5
0
bool UCubiquityMeshComponent::SetGeneratedMeshTrianglesColoredCubes(const Cubiquity::OctreeNode& octreeNode)
{
	//UE_LOG(CubiquityLog, Log, TEXT("UCubiquityMeshComponent::SetGeneratedMeshTrianglesColoredCubes"));

	uint32_t noOfIndices;
	uint16_t* cubuquityIndices;
	uint16_t noOfVertices;
	Cubiquity::ColoredCubesVertex* cubiquityVertices;
	octreeNode.getMesh(&noOfVertices, &cubiquityVertices, &noOfIndices, &cubuquityIndices);

	for (uint32_t i = 0; i < noOfVertices; ++i)
	{
		const auto& cubiquityVertex = cubiquityVertices[i];

		FColoredCubesVertex Vert;

		const auto& position = cubiquityVertex.position();
		Vert.Position = FVector(position.x, position.y, position.z);

		const auto& color = cubiquityVertex.color();
		Vert.Color = FColor(color.red(), color.green(), color.blue(), color.alpha());

		coloredCubesVertices.Add(Vert);
	}

	//TODO: Could we do these 6 at at time for each quad?
	for (uint16_t i = 0; i < noOfIndices; ++i)
	{
		const uint16_t index0 = cubuquityIndices[i];
		const uint16_t index1 = cubuquityIndices[++i];
		const uint16_t index2 = cubuquityIndices[++i];

		const FColoredCubesVertex& vertex0 = coloredCubesVertices[index0];
		const FColoredCubesVertex& vertex1 = coloredCubesVertices[index1];
		const FColoredCubesVertex& vertex2 = coloredCubesVertices[index2];

		//Reverse winding order
		indices.Add(index2);
		indices.Add(index1);
		indices.Add(index0);

		//Now calculate the tangent vectors
		const FVector Edge01 = (vertex1.Position - vertex0.Position);
		const FVector Edge02 = (vertex2.Position - vertex0.Position);
		const FVector normal = (Edge02 ^ Edge01); //Normal

		/*vertex0.SetTangents(TangentX, TangentY, TangentZ);
		vertex1.SetTangents(TangentX, TangentY, TangentZ);
		vertex2.SetTangents(TangentX, TangentY, TangentZ);*/
	}

	if (ModelBodySetup)
	{
		ModelBodySetup->InvalidatePhysicsData(); // This is required for the first time after creation
	}

	UpdateCollision();

	// Need to recreate scene proxy to send it over
	MarkRenderStateDirty();

	return true;
}
コード例 #6
0
ファイル: Number.cpp プロジェクト: KNTGPolygon/3Man
void Number::UpdateSystem()
{
	UpdateCollision();
}