Example #1
0
	void LineRenderer::DrawLines(CU::GrowingArray<CU::RenderCommandLine, unsigned int>& someLines)
	{
		if (someLines.Size() > 0)
		{
			D3D11_MAPPED_SUBRESOURCE resource;
			ZeroMemory(&resource, sizeof(resource));
			myEngine->GetContext()->Map(myLineDummyBuffer.myVertexBuffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &resource);

			memcpy(resource.pData, reinterpret_cast<void*>(&(someLines[0].myFirstPoint.x)), someLines.Size() * sizeof(float) * 8);

			myEngine->GetContext()->Unmap(myLineDummyBuffer.myVertexBuffer.Get(), 0);
			myEngine->GetContext()->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_LINELIST);
			myEngine->GetContext()->IASetVertexBuffers(0, 1, &myLineDummyBuffer.myVertexBuffer, &myLineDummyBuffer.myStride, &myLineDummyBuffer.myByteOffset);
			myEngine->GetContext()->IASetInputLayout(myLineInputLayout.Get());

			COMObjectPointer<ID3DX11EffectPass> pass = myLineTechnique->GetPassByIndex(0);

			if (pass->IsValid() == false)
			{
				DL_ASSERT("Pass invalid");
			}
			HRESULT passResult = pass->Apply(NULL, myEngine->GetContext().Get());
			if (FAILED(passResult))
			{
				DL_ASSERT("Pass failed.");
			}
			myEngine->GetContext()->Draw(someLines.Size() * 2, 0);
		}
	}
Example #2
0
	void EffectFactory::CreateAllEffects()
	{
		CU::GrowingArray<std::string> files = WF::GetFilesWithExtension("Data\\Shaders\\", ".fso");

		for (unsigned short i = 0; i < files.Size(); i++)
		{
			std::string fileName = WF::GetFileNameWithoutExtension(files[i]);

			if (fileName != "Default" && fileName != "VertexPosNormUVBiTanInclude" && fileName != "ParticleShader")
			{
				CreateEffect(fileName, files[i], eVertexType::VERTEX_POS_NORM_UV_BI_NORMAL_TAN);
			}
			else if (fileName == "ParticleShader")
			{
				CreateEffect(fileName, files[i], eVertexType::VERTEX_POS_VELOCITY_SIZE_ALPHA_TIME);
			}
		}
	}
void MissionContainer::SortCopy(CU::GrowingArray<Mission*>& someOut, const CU::GrowingArray<Mission*>& someIn) const
{
	int currentIndex = 0;
	while (someOut.Size() != someIn.Size())
	{
		int prevIndex = currentIndex;
		for (int i = 0; i < someIn.Size(); ++i)
		{
			if (someIn[i]->GetIndex() == currentIndex)
			{
				++currentIndex;
				someOut.Add(someIn[i]);
				break;
			}
		}
		DL_ASSERT_EXP(prevIndex == currentIndex - 1, "Mission index " + std::to_string(currentIndex) + " not found.");
	}
}
Example #4
0
void Prism::Scene::Render(CU::GrowingArray<Instance*>& someBulletInstances)
{
	Render();

	for (int i = 0; i < someBulletInstances.Size(); ++i)
	{
		someBulletInstances[i]->UpdateDirectionalLights(myDirectionalLightData);
		someBulletInstances[i]->UpdatePointLights(myPointLightData);
		someBulletInstances[i]->UpdateSpotLights(mySpotLightData);
		someBulletInstances[i]->Render(*myCamera);
	}
}
void MissionContainer::Update(float aDeltaTime, CU::GrowingArray<Mission*>& someMissions, int aOffset, eMissionCategory aCategory)
{
	for (int i = someMissions.Size() - 1; i >= 0; --i)
	{
		if (someMissions[i]->Update(aDeltaTime, i + aOffset, aCategory) == true)
		{
			if (someMissions[i]->EventsEnd() == true)
			{
				myEndingMissions.Add(someMissions[i]);
			}
			else
			{
				someMissions[i]->End();
			}
			if (aCategory == eMissionCategory::NOT_REQUIRED)
			{
				PostMaster::GetInstance()->SendMessage<LevelScoreMessage>(LevelScoreMessage(eLevelScoreMessageType::OPTIONAL_MISSION_COMPLETED));
			}
			someMissions.RemoveCyclicAtIndex(i);
		}
	}
}
Example #6
0
	void Cube3D::CreateVertexBuffer(float aSideLength)
	{
		VertexPosNormColor temp;

		float offset = aSideLength * 0.5f;

		CU::GrowingArray<VertexPosNormColor> vertices;
		vertices.Init(16);

		temp.myPosition = { -offset, offset, -offset, 1.f };
		temp.myNormal = { 0.0f, 1.0f, 0.0f, 0.f };
		temp.myColor = myColor;
		vertices.Add(temp);

		temp.myPosition = { offset, offset, -offset, 1.f };
		temp.myNormal = { 0.0f, 1.0f, 0.0f, 0.f };
		vertices.Add(temp);

		temp.myPosition = { offset, offset, offset, 1.f };
		temp.myNormal = { 0.0f, 1.0f, 0.0f, 0.f };
		vertices.Add(temp);

		temp.myPosition = { -offset, offset, offset, 1.f };
		temp.myNormal = { 0.0f, 1.0f, 0.0f, 0.f };
		vertices.Add(temp);

		temp.myPosition = { -offset, -offset, -offset, 1.f };
		temp.myNormal = { 0.0f, -1.0f, 0.0f, 0.f };
		vertices.Add(temp);

		temp.myPosition = { offset, -offset, -offset, 1.f };
		temp.myNormal = { 0.0f, -1.0f, 0.0f, 0.f };
		vertices.Add(temp);

		temp.myPosition = { offset, -offset, offset, 1.f };
		temp.myNormal = { 0.0f, -1.0f, 0.0f, 0.f };
		vertices.Add(temp);

		temp.myPosition = { -offset, -offset, offset, 1.f };
		temp.myNormal = { 0.0f, -1.0f, 0.0f, 0.f };
		vertices.Add(temp);

		temp.myPosition = { -offset, -offset, offset, 1.f };
		temp.myNormal = { -1.0f, 0.0f, 0.0f, 0.f };
		vertices.Add(temp);

		temp.myPosition = { -offset, -offset, -offset, 1.f };
		temp.myNormal = { -1.0f, 0.0f, 0.0f, 0.f };
		vertices.Add(temp);

		temp.myPosition = { -offset, offset, -offset, 1.f };
		temp.myNormal = { -1.0f, 0.0f, 0.0f, 0.f };
		vertices.Add(temp);

		temp.myPosition = { -offset, offset, offset, 1.f };
		temp.myNormal = { -1.0f, 0.0f, 0.0f, 0.f };
		vertices.Add(temp);

		temp.myPosition = { offset, -offset, offset, 1.f };
		temp.myNormal = { 1.0f, 0.0f, 0.0f, 0.f };
		vertices.Add(temp);

		temp.myPosition = { offset, -offset, -offset, 1.f };
		temp.myNormal = { 1.0f, 0.0f, 0.0f, 0.f };
		vertices.Add(temp);

		temp.myPosition = { offset, offset, -offset, 1.f };
		temp.myNormal = { 1.0f, 0.0f, 0.0f, 0.f };
		vertices.Add(temp);

		temp.myPosition = { offset, offset, offset, 1.f };
		temp.myNormal = { 1.0f, 0.0f, 0.0f, 0.f };
		vertices.Add(temp);

		temp.myPosition = { -offset, -offset, -offset, 1.f };
		temp.myNormal = { 0.0f, 0.0f, -1.0f, 0.f };
		vertices.Add(temp);

		temp.myPosition = { offset, -offset, -offset, 1.f };
		temp.myNormal = { 0.0f, 0.0f, -1.0f, 0.f };
		vertices.Add(temp);

		temp.myPosition = { offset, offset, -offset, 1.f };
		temp.myNormal = { 0.0f, 0.0f, -1.0f, 0.f };
		vertices.Add(temp);

		temp.myPosition = { -offset, offset, -offset, 1.f };
		temp.myNormal = { 0.0f, 0.0f, -1.0f, 0.f };
		vertices.Add(temp);

		temp.myPosition = { -offset, -offset, offset, 1.f };
		temp.myNormal = { 0.0f, 0.0f, 1.0f, 0.f };
		vertices.Add(temp);

		temp.myPosition = { offset, -offset, offset, 1.f };
		temp.myNormal = { 0.0f, 0.0f, 1.0f, 0.f };
		vertices.Add(temp);

		temp.myPosition = { offset, offset, offset, 1.f };
		temp.myNormal = { 0.0f, 0.0f, 1.0f, 0.f };
		vertices.Add(temp);

		temp.myPosition = { -offset, offset, offset, 1.f };
		temp.myNormal = { 0.0f, 0.0f, 1.0f, 0.f };
		vertices.Add(temp);
		myVertexBaseData = new VertexDataWrapper();
		myVertexBaseData->myNumberOfVertices = vertices.Size();
		myVertexBaseData->myStride = sizeof(VertexPosNormColor);
		myVertexBaseData->mySize = myVertexBaseData->myNumberOfVertices * myVertexBaseData->myStride;
		myVertexBaseData->myType = VertexType::POS_NORM_COLOR;
		myVertexBaseData->myVertexData = new char[myVertexBaseData->mySize]();
		memcpy(myVertexBaseData->myVertexData, &vertices[0], myVertexBaseData->mySize);
	}
Example #7
0
	Cube3D::Cube3D()
		: myWireFrame(false)
		, mySize(1.f, 1.f, 1.f)
		, myColor(1.f, 1.f, 1.f, 1.f)
	{
		myEffect = EffectContainer::GetInstance()->GetEffect("Data/Resource/Shader/S_effect_cube3d.fx");
		CreateVertexBuffer(1.f);

		myIndexBaseData = new VertexIndexWrapper();
		myIndexBaseData->myFormat = DXGI_FORMAT_R32_UINT;
		myIndexBaseData->myNumberOfIndices = 6 * 6;
		myIndexBaseData->mySize = myIndexBaseData->myNumberOfIndices * sizeof(unsigned int);


		CU::GrowingArray<int> indices;
		indices.Init(32);

		indices.Add(3);
		indices.Add(1);
		indices.Add(0);

		indices.Add(2);
		indices.Add(1);
		indices.Add(3);

		indices.Add(6);
		indices.Add(4);
		indices.Add(5);

		indices.Add(6);
		indices.Add(7);
		indices.Add(4);

		indices.Add(11);
		indices.Add(9);
		indices.Add(8);

		indices.Add(10);
		indices.Add(9);
		indices.Add(11);

		indices.Add(14);
		indices.Add(12);
		indices.Add(13);

		indices.Add(15);
		indices.Add(12);
		indices.Add(14);

		indices.Add(19);
		indices.Add(17);
		indices.Add(16);

		indices.Add(18);
		indices.Add(17);
		indices.Add(19);

		indices.Add(22);
		indices.Add(20);
		indices.Add(21);

		indices.Add(23);
		indices.Add(20);
		indices.Add(22);

		myIndexBaseData->myIndexData = new char[myIndexBaseData->mySize]();
		memcpy(myIndexBaseData->myIndexData, &indices[0], indices.Size() * sizeof(unsigned int));

		myPrimitiveTopology = D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST;

		InitVertexBuffer();
		InitIndexBuffer();
	}
Example #8
0
	void GPUData::InitCube(EffectID aEffect, GPUContext& aGPUContext, AssetContainer& aAssetContainer)
	{
#pragma region Vertices
		CU::GrowingArray<VertexPosColor> vertices;
		vertices.Init(24);

		float size = 1.f;
		float halfWidth = size / 2.f;
		float halfHeight = size / 2.f;
		float halfDepth = size / 2.f;
		CU::Vector4<float> aColour(1.f, 1.f, 1.f, 1.f);

		//0 - 3 (Top)
		vertices.Add({ { -halfWidth, halfHeight, -halfDepth }, aColour });
		vertices.Add({ { halfWidth, halfHeight, -halfDepth }, aColour });
		vertices.Add({ { halfWidth, halfHeight, halfDepth }, aColour });
		vertices.Add({ { -halfWidth, halfHeight, halfDepth }, aColour });

		//4 - 7 (Bottom)
		vertices.Add({ { -halfWidth, -halfHeight, -halfDepth }, aColour });
		vertices.Add({ { halfWidth, -halfHeight, -halfDepth }, aColour });
		vertices.Add({ { halfWidth, -halfHeight, halfDepth }, aColour });
		vertices.Add({ { -halfWidth, -halfHeight, halfDepth }, aColour });

		//8 - 11 (Left)
		vertices.Add({ { -halfWidth, -halfHeight, halfDepth }, aColour });
		vertices.Add({ { -halfWidth, -halfHeight, -halfDepth }, aColour });
		vertices.Add({ { -halfWidth, halfHeight, -halfDepth }, aColour });
		vertices.Add({ { -halfWidth, halfHeight, halfDepth }, aColour });

		//12 - 15 (Right)
		vertices.Add({ { halfWidth, -halfHeight, halfDepth }, aColour });
		vertices.Add({ { halfWidth, -halfHeight, -halfDepth }, aColour });
		vertices.Add({ { halfWidth, halfHeight, -halfDepth }, aColour });
		vertices.Add({ { halfWidth, halfHeight, halfDepth }, aColour });

		//16 - 19 (Front)
		vertices.Add({ { -halfWidth, -halfHeight, -halfDepth }, aColour });
		vertices.Add({ { halfWidth, -halfHeight, -halfDepth }, aColour });
		vertices.Add({ { halfWidth, halfHeight, -halfDepth }, aColour });
		vertices.Add({ { -halfWidth, halfHeight, -halfDepth }, aColour });

		//20 - 23 (Back)
		vertices.Add({ { -halfWidth, -halfHeight, halfDepth }, aColour });
		vertices.Add({ { halfWidth, -halfHeight, halfDepth }, aColour });
		vertices.Add({ { halfWidth, halfHeight, halfDepth }, aColour });
		vertices.Add({ { -halfWidth, halfHeight, halfDepth }, aColour });
#pragma endregion

#pragma region Indices

		CU::GrowingArray<int> indices(24);
		//Top
		indices.Add(3);
		indices.Add(1);
		indices.Add(0);

		indices.Add(2);
		indices.Add(1);
		indices.Add(3);

		//Bottom
		indices.Add(6);
		indices.Add(4);
		indices.Add(5);

		indices.Add(7);
		indices.Add(4);
		indices.Add(6);

		//Left
		indices.Add(11);
		indices.Add(9);
		indices.Add(8);

		indices.Add(10);
		indices.Add(9);
		indices.Add(11);

		//Right
		indices.Add(14);
		indices.Add(12);
		indices.Add(13);

		indices.Add(15);
		indices.Add(12);
		indices.Add(14);

		//Front
		indices.Add(19);
		indices.Add(17);
		indices.Add(16);

		indices.Add(18);
		indices.Add(17);
		indices.Add(19);

		//Back
		indices.Add(22);
		indices.Add(20);
		indices.Add(21);

		indices.Add(23);
		indices.Add(20);
		indices.Add(22);

#pragma endregion

		SetTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
		AddInputElement(new D3D11_INPUT_ELEMENT_DESC({ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }));
		AddInputElement(new D3D11_INPUT_ELEMENT_DESC({ "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }));

		int indexCount = indices.Size();
		int vertexCount = vertices.Size();
		int vertexStride = sizeof(VertexPosColor);
		Init(aEffect, indexCount, reinterpret_cast<char*>(&indices[0]), vertexCount
			, vertexStride, reinterpret_cast<char*>(&vertices[0]), aGPUContext, aAssetContainer);

		myIndexData = new IndexData();
		myVertexData = new VertexData();

		myIndexData->myNumberOfIndices = indexCount;
		myVertexData->myNumberOfVertices = vertexCount;
		myVertexData->myStride = vertexStride;
	}
Example #9
0
bool NavGrid::FindPath(const CU::Vector2i& aStartPoint, const CU::Vector2i& aEndPoint, CU::GrowingArray<CU::Vector2f>& aOutPath)
{
	aOutPath.RemoveAll();
	ResetGrid();

	int startIndex = WorldIndexToGridIndex(aStartPoint);
	int goalIndex = WorldIndexToGridIndex(aEndPoint);

	if (!IsPositionOnGrid(aStartPoint) || !IsPositionOnGrid(aEndPoint))
		return false;

	Node& startNode = myGrid[startIndex];
	startNode.myG = 0;
	startNode.myH = CalculateHeuristic(startIndex, goalIndex);
	startNode.myF = startNode.myG + startNode.myH;
	startNode.myListState = IN_OPEN;

	Node* currentClosestNode = &myGrid[startIndex];

	CU::Heap<Node*, NavGrid_NodeComparer<Node*>> heap;
	heap.Enqueue(&startNode);

	while (!heap.IsEmpty())
	{
		Node* currNode = heap.Dequeue();
		currNode->myListState = IN_CLOSED;

		if (CalculateHeuristic(currNode->myGridIndex, goalIndex) < currentClosestNode->myH)
			currentClosestNode = currNode;

		if (currNode->myGridIndex == goalIndex)
		{
			while (currNode != nullptr)
			{
				CU::Vector2f worldPosition = ArrayIndexToWorldPosition(currNode->myGridIndex);
				aOutPath.Add(worldPosition);
				currNode = currNode->myParent;
			}

			return true;
		}

		int currIndex = currNode->myGridIndex;

		if (currIndex > myGridSize)
		{
			ExamineNeighbour(currNode, currIndex - myGridSize, goalIndex, heap);
		}

		if (currIndex < myGridSize * (myGridSize - 1))
		{
			ExamineNeighbour(currNode, currIndex + myGridSize, goalIndex, heap);
		}

		if (currIndex % myGridSize != 0)
		{
			ExamineNeighbour(currNode, currIndex - 1, goalIndex, heap);
		}

		if ((currIndex + 1) % myGridSize != 0)
		{
			ExamineNeighbour(currNode, currIndex + 1, goalIndex, heap);
		}

		currNode->myListState = IN_CLOSED;
	}

	return FindPath(aStartPoint, ArrayIndexToGridIndex(currentClosestNode->myGridIndex), aOutPath);
}