Sfoglia il codice sorgente

finished mariokart

vlod 1 anno fa
parent
commit
82bab4aaa9

+ 166 - 37
Pika/gameplay/containers/marioKart/marioKart.h

@@ -22,6 +22,18 @@ struct MarioKart: public Container
 	int currentMarker = 0;
 	int currentMarker = 0;
 	glm::vec2 markerDelta = {};
 	glm::vec2 markerDelta = {};
 
 
+	float acceleration = 0;
+
+	bool freeCamera = 0;
+	bool showGuides = 0;
+	
+	std::vector<float> coinTimers;
+	int score = 0;
+
+
+	gl2d::Font font;
+	gl2d::Renderer2D renderer2d;
+
 	//todo user can request imgui ids; shortcut manager context; allocators
 	//todo user can request imgui ids; shortcut manager context; allocators
 	static ContainerStaticInfo containerInfo()
 	static ContainerStaticInfo containerInfo()
 	{
 	{
@@ -45,18 +57,18 @@ struct MarioKart: public Container
 	gl3d::Entity marioEntity;
 	gl3d::Entity marioEntity;
 	gl3d::Model carModel;
 	gl3d::Model carModel;
 	gl3d::Entity carEntity;
 	gl3d::Entity carEntity;
-	bool first = 1;
-	float carPos = 0;
+	gl3d::Model coinModel;
 
 
+	float spinTimer = 0;
 
 
 	std::vector<gl3d::Entity> spheres;
 	std::vector<gl3d::Entity> spheres;
+	std::vector<gl3d::Entity> coins;
 
 
 	pika::gl3d::General3DEditor editor;
 	pika::gl3d::General3DEditor editor;
 
 
 	bool create(RequestedContainerInfo &requestedInfo, pika::StaticString<256> commandLineArgument)
 	bool create(RequestedContainerInfo &requestedInfo, pika::StaticString<256> commandLineArgument)
 	{
 	{
-
-		//todo add hbao
+		renderer2d.create(requestedInfo.requestedFBO.fbo);
 
 
 		renderer.setErrorCallback(&errorCallbackCustom, &requestedInfo);
 		renderer.setErrorCallback(&errorCallbackCustom, &requestedInfo);
 		renderer.fileOpener.userData = &requestedInfo;
 		renderer.fileOpener.userData = &requestedInfo;
@@ -64,10 +76,13 @@ struct MarioKart: public Container
 		renderer.fileOpener.readEntireFileCallback = readEntireFileCustom;
 		renderer.fileOpener.readEntireFileCallback = readEntireFileCustom;
 		renderer.fileOpener.fileExistsCallback = defaultFileExistsCustom;
 		renderer.fileOpener.fileExistsCallback = defaultFileExistsCustom;
 		renderer.frustumCulling = false;
 		renderer.frustumCulling = false;
+		renderer.tonemapper = 2;
 
 
 		renderer.init(1, 1, PIKA_RESOURCES_PATH "BRDFintegrationMap.png", requestedInfo.requestedFBO.fbo);
 		renderer.init(1, 1, PIKA_RESOURCES_PATH "BRDFintegrationMap.png", requestedInfo.requestedFBO.fbo);
 		
 		
 
 
+		font = pika::gl2d::loadFont(PIKA_RESOURCES_PATH "mcDungeons/CommodorePixeled.ttf", requestedInfo);
+
 		//const char *names[6] =
 		//const char *names[6] =
 		//{PIKA_RESOURCES_PATH "/skyBoxes/ocean/right.jpg",
 		//{PIKA_RESOURCES_PATH "/skyBoxes/ocean/right.jpg",
 		//	PIKA_RESOURCES_PATH "/skyBoxes/ocean/left.jpg",
 		//	PIKA_RESOURCES_PATH "/skyBoxes/ocean/left.jpg",
@@ -84,6 +99,8 @@ struct MarioKart: public Container
 		renderer.skyBox.color = glm::vec3(240.f / 255.f);
 		renderer.skyBox.color = glm::vec3(240.f / 255.f);
 
 
 		editor.loadFromFile(renderer, PIKA_RESOURCES_PATH "/marioKart/settings.gl3d", requestedInfo);
 		editor.loadFromFile(renderer, PIKA_RESOURCES_PATH "/marioKart/settings.gl3d", requestedInfo);
+		renderer.internal.lightShader.useTheHbaoImplementation = true;
+
 
 
 		renderer.createDirectionalLight({-0.155,-0.907,0.391}, glm::vec3{270.f/255.f});
 		renderer.createDirectionalLight({-0.155,-0.907,0.391}, glm::vec3{270.f/255.f});
 		renderer.getDirectionalShadowCascadesFrustumSplit(0) = 0.10;
 		renderer.getDirectionalShadowCascadesFrustumSplit(0) = 0.10;
@@ -103,6 +120,9 @@ struct MarioKart: public Container
 		marioModel = renderer.loadModel("C:/Users/meemk/Desktop/mario/mario2.obj",
 		marioModel = renderer.loadModel("C:/Users/meemk/Desktop/mario/mario2.obj",
 			gl3d::TextureLoadQuality::maxQuality, 1.f);
 			gl3d::TextureLoadQuality::maxQuality, 1.f);
 		
 		
+		coinModel = renderer.loadModel("C:/Users/meemk/Desktop/coin/coin.obj",
+			gl3d::TextureLoadQuality::maxQuality, 1.f);
+
 		//todo error by gl3d when creating an entity with no model loaded
 		//todo error by gl3d when creating an entity with no model loaded
 		sphereModel = renderer.loadModel(PIKA_RESOURCES_PATH "/marioKart/sphere.obj",
 		sphereModel = renderer.loadModel(PIKA_RESOURCES_PATH "/marioKart/sphere.obj",
 			gl3d::TextureLoadQuality::maxQuality, 1);
 			gl3d::TextureLoadQuality::maxQuality, 1);
@@ -110,8 +130,8 @@ struct MarioKart: public Container
 		worldEntity = renderer.createEntity(worldModel, {});
 		worldEntity = renderer.createEntity(worldModel, {});
 
 
 
 
-		carEntity = renderer.createEntity(carModel);
-		marioEntity = renderer.createEntity(marioModel);
+		carEntity = renderer.createEntity(carModel, {}, false);
+		marioEntity = renderer.createEntity(marioModel, {}, false);
 
 
 		size_t size = 0;
 		size_t size = 0;
 		if (requestedInfo.getFileSizeBinary(PIKA_RESOURCES_PATH "/marioKart/markers.bin", size))
 		if (requestedInfo.getFileSizeBinary(PIKA_RESOURCES_PATH "/marioKart/markers.bin", size))
@@ -131,11 +151,42 @@ struct MarioKart: public Container
 
 
 		}
 		}
 
 
+		size = 0;
+		if (requestedInfo.getFileSizeBinary(PIKA_RESOURCES_PATH "/marioKart/coins.bin", size))
+		{
+
+			if (size % sizeof(glm::vec3) == 0 && size)
+			{
+				std::vector<glm::vec3> positions;
+				positions.resize(size / sizeof(glm::vec3));
+
+				requestedInfo.readEntireFileBinary(PIKA_RESOURCES_PATH "/marioKart/coins.bin",
+					positions.data(), size);
+
+				for (auto &p : positions)
+				{
+					coins.push_back(renderer.createEntity(coinModel, gl3d::Transform{p}, false));
+					coinTimers.push_back(0);
+				}
+			}
+			else
+			{
+				requestedInfo.consoleWrite("Error, Mario kart coins file corrupted\n");
+			}
+
+		}
+
+
+
 		if (markers.size() >= 2)
 		if (markers.size() >= 2)
 		{
 		{
 			auto pos = markers[0].position;
 			auto pos = markers[0].position;
 			carPosition = pos;
 			carPosition = pos;
 		}
 		}
+		else
+		{
+			return false;
+		}
 		//
 		//
 
 
 		return true;
 		return true;
@@ -145,6 +196,8 @@ struct MarioKart: public Container
 		RequestedContainerInfo &requestedInfo)
 		RequestedContainerInfo &requestedInfo)
 	{
 	{
 	#pragma region init stuff
 	#pragma region init stuff
+		renderer2d.updateWindowMetrics(windowState.windowW, windowState.windowH);
+
 		renderer.setErrorCallback(&errorCallbackCustom, &requestedInfo);
 		renderer.setErrorCallback(&errorCallbackCustom, &requestedInfo);
 		renderer.fileOpener.userData = &requestedInfo;
 		renderer.fileOpener.userData = &requestedInfo;
 		renderer.fileOpener.readEntireFileBinaryCallback = readEntireFileBinaryCustom;
 		renderer.fileOpener.readEntireFileBinaryCallback = readEntireFileBinaryCustom;
@@ -195,7 +248,7 @@ struct MarioKart: public Container
 			spheres.push_back(renderer.createEntity(sphereModel, {}, false));
 			spheres.push_back(renderer.createEntity(sphereModel, {}, false));
 		}
 		}
 		
 		
-		if (0)
+		if (showGuides)
 		{
 		{
 			int currentSphere = 0;
 			int currentSphere = 0;
 			for (auto m : markers)
 			for (auto m : markers)
@@ -251,23 +304,69 @@ struct MarioKart: public Container
 
 
 	#pragma endregion
 	#pragma endregion
 
 
+	#pragma region coins
+
+		spinTimer += input.deltaTime * 3.f;
+
+		if (spinTimer > 2 * 3.141592)
+		{
+			spinTimer -= 2 * 3.141592;
+		}
+
+		int coinCount = 0;
+		for (auto &c : coins)
+		{
+			auto t = renderer.getEntityTransform(c);
+			t.rotation.y = spinTimer;
+			renderer.setEntityTransform(c, t);
+
+			if (coinTimers[coinCount] > 0)
+			{
+				coinTimers[coinCount] -= input.deltaTime;
+				if (coinTimers[coinCount] <= 0)
+				{
+					coinTimers[coinCount] = 0;
+					renderer.setEntityVisible(c, true);
+				}
+			}
+			else
+			{
+				if (glm::distance(carPosition, t.position) < 2.f)
+				{
+					coinTimers[coinCount] = 10;
+					renderer.setEntityVisible(c, false);
+					score++;
+				}
+			}
+
+
+			coinCount++;
+		}
+
+	#pragma endregion
+
+
 	#pragma region car
 	#pragma region car
 
 
 		float tilt = 0;
 		float tilt = 0;
 
 
 		if (markers.size() >= 2)
 		if (markers.size() >= 2)
 		{
 		{
-			
+
 			float moveForward = 0;
 			float moveForward = 0;
-			if (input.buttons[pika::Button::Up].held())
+			if (input.buttons[pika::Button::Up].held() || (input.buttons[pika::Button::W].held() && !freeCamera))
 			{
 			{
 				moveForward = 1;
 				moveForward = 1;
 			}
 			}
-			if (input.buttons[pika::Button::Down].held())
+			if (input.buttons[pika::Button::Down].held() || (input.buttons[pika::Button::S].held() && !freeCamera))
 			{
 			{
 				moveForward -= 1;
 				moveForward -= 1;
 			}
 			}
 
 
+			acceleration += moveForward * input.deltaTime * 3.f;
+
+			acceleration = glm::clamp(acceleration, -10.f, 20.f);
+
 			auto isLeft2 = [](glm::vec2 a, glm::vec2 b, glm::vec2 c)
 			auto isLeft2 = [](glm::vec2 a, glm::vec2 b, glm::vec2 c)
 			{
 			{
 				return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x) > 0;
 				return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x) > 0;
@@ -278,16 +377,30 @@ struct MarioKart: public Container
 				return isLeft2({a.x,a.z}, {b.x,b.z}, {c.x, c.z});
 				return isLeft2({a.x,a.z}, {b.x,b.z}, {c.x, c.z});
 			};
 			};
 
 
-			if (moveForward)
+			if (!moveForward)
+			{
+				if (acceleration > 0)
+				{
+					acceleration -= input.deltaTime;
+					if (acceleration < 0) { acceleration = 0; }
+				}
+				else if (acceleration < 0)
+				{
+					acceleration += input.deltaTime;
+					if (acceleration > 0) { acceleration = 0; }
+				}
+			}
+
+			if (acceleration)
 			{
 			{
 				carPosition.y = 0;
 				carPosition.y = 0;
 
 
 				float leftRight = 0;
 				float leftRight = 0;
-				if (input.buttons[pika::Button::Left].held())
+				if (input.buttons[pika::Button::Left].held() || (input.buttons[pika::Button::A].held() && !freeCamera))
 				{
 				{
 					leftRight = 1;
 					leftRight = 1;
 				}
 				}
-				if (input.buttons[pika::Button::Right].held())
+				if (input.buttons[pika::Button::Right].held() || (input.buttons[pika::Button::D].held() && !freeCamera))
 				{
 				{
 					leftRight -= 1;
 					leftRight -= 1;
 				}
 				}
@@ -301,41 +414,39 @@ struct MarioKart: public Container
 				}
 				}
 
 
 
 
-
 				//auto oldPos = carPosition;
 				//auto oldPos = carPosition;
 				//carPosition += 
 				//carPosition += 
-				auto move = moveDirection * input.deltaTime * moveForward * 8.f;
+				auto move = moveDirection * input.deltaTime * acceleration;
 				
 				
 				//glm::vec2 newDelta = markerDelta + glm::vec2(move.x, move.y);
 				//glm::vec2 newDelta = markerDelta + glm::vec2(move.x, move.y);
 
 
 				auto m1 = markers[carMarker];
 				auto m1 = markers[carMarker];
-				auto m2 = markers[(carMarker + 1)%markers.size()];
-
-				if (!isLeft(getLeft(m2), getRight(m2), carPosition + glm::vec3(move.x, 0, move.z)))
-				{
-					carMarker++;
-					carMarker = carMarker % markers.size();
-				}
-				else if (isLeft(getLeft(m1), getRight(m1), carPosition + glm::vec3(move.x, 0, move.z)))
-				{
-					carMarker--;
-					if (carMarker < 0) { carMarker = markers.size() - 1; }
-				}
+				auto m2 = markers[(carMarker + 1) % markers.size()];
 
 
 				if (!isLeft(getLeft(m1), getLeft(m2), carPosition + glm::vec3(move.x, 0, move.z)))
 				if (!isLeft(getLeft(m1), getLeft(m2), carPosition + glm::vec3(move.x, 0, move.z)))
 				{
 				{
-
+					acceleration = -acceleration*0.2;
 				}
 				}
 				else if (isLeft(getRight(m1), getRight(m2), carPosition + glm::vec3(move.x, 0, move.z)))
 				else if (isLeft(getRight(m1), getRight(m2), carPosition + glm::vec3(move.x, 0, move.z)))
 				{
 				{
-
+					acceleration = -acceleration * 0.2;
 				}
 				}
 				else
 				else
 				{
 				{
-					carPosition += glm::vec3(move.x, 0, move.z);
-				}
 
 
+					if (!isLeft(getLeft(m2), getRight(m2), carPosition + glm::vec3(move.x, 0, move.z)))
+					{
+						carMarker++;
+						carMarker = carMarker % markers.size();
+					}
+					else if (isLeft(getLeft(m1), getRight(m1), carPosition + glm::vec3(move.x, 0, move.z)))
+					{
+						carMarker--;
+						if (carMarker < 0) { carMarker = markers.size() - 1; }
+					}
 
 
+					carPosition += glm::vec3(move.x, 0, move.z);
+				}
 				
 				
 
 
 				//float dist1 = glm::distance(glm::vec2(m1.position.x, m1.position.z), 
 				//float dist1 = glm::distance(glm::vec2(m1.position.x, m1.position.z), 
@@ -404,23 +515,41 @@ struct MarioKart: public Container
 			renderer.setEntityTransform(marioEntity, t);
 			renderer.setEntityTransform(marioEntity, t);
 		}
 		}
 
 
-		renderer.camera.position = carPosition + glm::vec3(0, 4.5, 0) - moveDirection * 5.5f;
+			
+		if (input.buttons[pika::Button::P].pressed())
+		{
+			freeCamera = !freeCamera;
+		}
+		if (input.buttons[pika::Button::O].pressed())
+		{
+			showGuides = !showGuides;
+		}
 
 
-		renderer.camera.up = glm::vec3(glm::rotate(-tilt*2.f, glm::vec3(0, 0, 1)) * glm::vec4(0, 1, 0, 1));
 
 
-		renderer.camera.viewDirection = glm::normalize(moveDirection + glm::vec3(0, -0.5, 0));
+		if (freeCamera)
+		{
+			editor.update(requestedInfo.requestedImguiIds, renderer, input, cameraSpeed, requestedInfo, {windowState.windowW,windowState.windowH});
+		}
+		else
+		{
+			renderer.camera.position = carPosition + glm::vec3(0, 4.5, 0) - moveDirection * 5.5f;
+			renderer.camera.up = glm::vec3(glm::rotate(-tilt * 2.f, glm::vec3(0, 0, 1)) * glm::vec4(0, 1, 0, 1));
+			renderer.camera.viewDirection = glm::normalize(moveDirection + glm::vec3(0, -0.5, 0));
+		}
+	
 
 
 
 
 	#pragma endregion
 	#pragma endregion
 			
 			
-		//editor.update(requestedInfo.requestedImguiIds, renderer, input, cameraSpeed, requestedInfo, {windowState.windowW,windowState.windowH});
-
-
 
 
 
 
 		renderer.render(input.deltaTime);
 		renderer.render(input.deltaTime);
 		glDisable(GL_DEPTH_TEST);
 		glDisable(GL_DEPTH_TEST);
 
 
+		renderer2d.renderText({100, 50}, std::to_string(score).c_str(), font, Colors_White);
+
+		renderer2d.flush();
+
 
 
 		return true;
 		return true;
 	}
 	}

+ 96 - 6
Pika/gameplay/containers/marioKart/marioKartEditor.h

@@ -34,6 +34,9 @@ struct MarioKartEditor: public Container
 	int currentMarker = 0;
 	int currentMarker = 0;
 	glm::vec2 markerDelta = {};
 	glm::vec2 markerDelta = {};
 
 
+	int currentCoin = 0;
+
+
 	//todo user can request imgui ids; shortcut manager context; allocators
 	//todo user can request imgui ids; shortcut manager context; allocators
 	static ContainerStaticInfo containerInfo()
 	static ContainerStaticInfo containerInfo()
 	{
 	{
@@ -55,12 +58,14 @@ struct MarioKartEditor: public Container
 	gl3d::Entity worldEntity;
 	gl3d::Entity worldEntity;
 	gl3d::Model carModel;
 	gl3d::Model carModel;
 	gl3d::Entity carEntity;
 	gl3d::Entity carEntity;
-	bool first = 1;
-	float carPos = 0;
+	gl3d::Model coinModel;
 
 
 
 
 	std::vector<gl3d::Entity> spheres;
 	std::vector<gl3d::Entity> spheres;
 
 
+	std::vector<gl3d::Entity> coins;
+
+	
 	pika::gl3d::General3DEditor editor;
 	pika::gl3d::General3DEditor editor;
 
 
 	bool create(RequestedContainerInfo &requestedInfo, pika::StaticString<256> commandLineArgument)
 	bool create(RequestedContainerInfo &requestedInfo, pika::StaticString<256> commandLineArgument)
@@ -110,6 +115,10 @@ struct MarioKartEditor: public Container
 		carModel = renderer.loadModel("C:/Users/meemk/Desktop/car/Standard Kart.obj",
 		carModel = renderer.loadModel("C:/Users/meemk/Desktop/car/Standard Kart.obj",
 			gl3d::TextureLoadQuality::maxQuality, 1.f);
 			gl3d::TextureLoadQuality::maxQuality, 1.f);
 
 
+		coinModel = renderer.loadModel("C:/Users/meemk/Desktop/coin/coin.obj",
+			gl3d::TextureLoadQuality::maxQuality, 1.f);
+		
+
 		//todo error by gl3d when creating an entity with no model loaded
 		//todo error by gl3d when creating an entity with no model loaded
 		sphereModel = renderer.loadModel(PIKA_RESOURCES_PATH "/marioKart/sphere.obj",
 		sphereModel = renderer.loadModel(PIKA_RESOURCES_PATH "/marioKart/sphere.obj",
 			gl3d::TextureLoadQuality::maxQuality, 1);
 			gl3d::TextureLoadQuality::maxQuality, 1);
@@ -117,7 +126,7 @@ struct MarioKartEditor: public Container
 		worldEntity = renderer.createEntity(worldModel, {});
 		worldEntity = renderer.createEntity(worldModel, {});
 
 
 
 
-		carEntity = renderer.createEntity(carModel);
+		carEntity = renderer.createEntity(carModel, {}, false);
 
 
 		size_t size = 0;
 		size_t size = 0;
 		if (requestedInfo.getFileSizeBinary(PIKA_RESOURCES_PATH "/marioKart/markers.bin", size))
 		if (requestedInfo.getFileSizeBinary(PIKA_RESOURCES_PATH "/marioKart/markers.bin", size))
@@ -144,6 +153,32 @@ struct MarioKartEditor: public Container
 		}
 		}
 		//
 		//
 
 
+		size = 0;
+		if (requestedInfo.getFileSizeBinary(PIKA_RESOURCES_PATH "/marioKart/coins.bin", size))
+		{
+
+			if (size % sizeof(glm::vec3) == 0 && size)
+			{
+				std::vector<glm::vec3> positions;
+				positions.resize(size / sizeof(glm::vec3));
+
+				requestedInfo.readEntireFileBinary(PIKA_RESOURCES_PATH "/marioKart/coins.bin",
+					positions.data(), size);
+
+				for (auto &p : positions)
+				{
+					coins.push_back(renderer.createEntity(coinModel, gl3d::Transform{p}, false));
+				}
+			}
+			else
+			{
+				requestedInfo.consoleWrite("Error, Mario kart coins file corrupted\n");
+			}
+
+		}
+
+
+
 		return true;
 		return true;
 	}
 	}
 
 
@@ -399,7 +434,6 @@ struct MarioKartEditor: public Container
 	#pragma endregion
 	#pragma endregion
 			
 			
 
 
-
 		ImGui::PushID(requestedInfo.requestedImguiIds);
 		ImGui::PushID(requestedInfo.requestedImguiIds);
 		if (ImGui::Begin("General3DEditor"))
 		if (ImGui::Begin("General3DEditor"))
 		{
 		{
@@ -444,6 +478,14 @@ struct MarioKartEditor: public Container
 					m.isAir = isAir;
 					m.isAir = isAir;
 
 
 					ImGui::Separator();
 					ImGui::Separator();
+
+					if (ImGui::Button("Remove Current Marker"))
+					{
+						markers.erase(markers.begin() + currentMarker);
+					}
+
+					ImGui::Separator();
+
 				}
 				}
 
 
 				if (ImGui::Button("Add Marker"))
 				if (ImGui::Button("Add Marker"))
@@ -455,19 +497,67 @@ struct MarioKartEditor: public Container
 					currentMarker = markers.size() - 1;
 					currentMarker = markers.size() - 1;
 				}
 				}
 
 
-				if (ImGui::Button("Remove Current Marker"))
+
+				ImGui::Separator();
+
+				ImGui::Text("Coins: %d", int(coins.size()));
+
+				if (!coins.empty())
 				{
 				{
-					markers.erase(markers.begin() + currentMarker);
+					ImGui::InputInt("CurrentCoin: ", &currentCoin);
+
+					currentCoin = std::clamp(currentCoin, 0, int(coins.size() - 1));
+
+					glm::vec3 p = renderer.getEntityTransform(coins[currentCoin]).position;
+
+					ImGui::Separator();
+
+					ImGui::DragFloat3("Coin position: ", &p[0], 0.02);
+
+					renderer.setEntityTransform(coins[currentCoin], gl3d::Transform{p});
+
+					ImGui::Separator();
+
+					if (ImGui::Button("Remove Current Coin"))
+					{
+						coins.erase(coins.begin() + currentCoin);
+					}
+					ImGui::Separator();
+
 				}
 				}
 
 
+				if (ImGui::Button("Add Coin"))
+				{
+					coins.push_back(renderer.createEntity(coinModel, gl3d::Transform{renderer.camera.position},
+						false));
+					currentCoin = coins.size() - 1;
+				}
+				
 
 
 				ImGui::Separator();
 				ImGui::Separator();
 
 
 
 
+
 				if (ImGui::Button("Save"))
 				if (ImGui::Button("Save"))
 				{
 				{
 					requestedInfo.writeEntireFileBinary(PIKA_RESOURCES_PATH "/marioKart/markers.bin",
 					requestedInfo.writeEntireFileBinary(PIKA_RESOURCES_PATH "/marioKart/markers.bin",
 						markers.data(), markers.size() * sizeof(RoadMarker));
 						markers.data(), markers.size() * sizeof(RoadMarker));
+
+
+					std::vector<glm::vec3> coinsPositions;
+
+					for (auto &c : coins)
+					{
+						auto t = renderer.getEntityTransform(c);
+
+						coinsPositions.push_back(t.position);
+
+						requestedInfo.writeEntireFileBinary(PIKA_RESOURCES_PATH "/marioKart/coins.bin",
+							coinsPositions.data(), coinsPositions.size() * sizeof(glm::vec3));
+					}
+
+
+
 				}
 				}
 
 
 
 

+ 3 - 13
Pika/resources/logs.txt

@@ -1,13 +1,3 @@
-#2024-01-20 03:02:36: Reloaded dll
-#2024-01-20 03:02:40: Created container: MarioKart
-#2024-01-20 03:03:01: Destroyed continer: MarioKart #1
-#2024-01-20 03:07:09: Created container: MarioKart
-#2024-01-20 03:07:25: Destroyed continer: MarioKart #2
-#2024-01-20 03:17:26[warning]: Couldn't reloaded dll
-#2024-01-20 03:17:27: Reloaded dll
-#2024-01-20 03:17:31: Created container: MarioKart
-#2024-01-20 03:19:11[warning]: Couldn't reloaded dll
-#2024-01-20 03:19:14: Reloaded dll
-#2024-01-20 03:20:25: Destroyed continer: MarioKart #3
-#2024-01-20 03:36:44: Created container: MarioKart
-#2024-01-20 03:37:09: Destroyed continer: MarioKart #4
+#2024-01-20 04:45:54: Created container: MarioKart
+#2024-01-20 04:46:53: Reloaded dll
+#2024-01-20 04:47:30: Destroyed continer: MarioKart #1

BIN
Pika/resources/marioKart/coins.bin


File diff suppressed because it is too large
+ 595 - 191
Pika/thirdparty/gl3d/gl3d.cpp


+ 31 - 9
Pika/thirdparty/gl3d/gl3d.h

@@ -1,6 +1,6 @@
 ////////////////////////////////////////////////
 ////////////////////////////////////////////////
 //gl3D --Vlad Luta -- 
 //gl3D --Vlad Luta -- 
-//built on 2023-03-07
+//built on 2024-01-20
 ////////////////////////////////////////////////
 ////////////////////////////////////////////////
 
 
 
 
@@ -19,8 +19,11 @@
 
 
 #define GL3D_REMOVE_IOSTREAM 1 //you can remove this if neded to. It is just used for the default errorcallback
 #define GL3D_REMOVE_IOSTREAM 1 //you can remove this if neded to. It is just used for the default errorcallback
 #define GL3D_REMOVE_FSTREAM 1 //you can remove this if neded to. It is used for the default file callback, supply your own function for file oppening so the library still works :))
 #define GL3D_REMOVE_FSTREAM 1 //you can remove this if neded to. It is used for the default file callback, supply your own function for file oppening so the library still works :))
+#define GL3D_REMOVE_ASSERTS 0 //you can remove asserts in production
 
 
 
 
+#define GL3D_OPTIMIZE_CACHED_SEARCH 1 //this was used by the dev to test some things, if you are using the library just keep it to 1.
+
 #if GL3D_REMOVE_IOSTREAM == 0
 #if GL3D_REMOVE_IOSTREAM == 0
 #include <iostream> 
 #include <iostream> 
 #endif
 #endif
@@ -53,11 +56,13 @@
 namespace gl3d
 namespace gl3d
 {
 {
 	//todo optimization also hold the last found position
 	//todo optimization also hold the last found position
+	//todo why id isn't unsigned?
 
 
 #define CREATE_RENDERER_OBJECT_HANDLE(x)	\
 #define CREATE_RENDERER_OBJECT_HANDLE(x)	\
 	struct x								\
 	struct x								\
 	{										\
 	{										\
 		int id_ = {};						\
 		int id_ = {};						\
+		int lastFoundPos_ = {};				\
 		x (int id=0):id_(id){};				\
 		x (int id=0):id_(id){};				\
 	}
 	}
 
 
@@ -218,6 +223,9 @@ namespace gl3d
 
 
 };
 };
 
 
+
+#if GL3D_REMOVE_ASSERTS == 0
+
 #define gl3dAssert(expression) (void)(											\
 #define gl3dAssert(expression) (void)(											\
 			(!!(expression)) ||													\
 			(!!(expression)) ||													\
 			(gl3d::assertFunc(#expression, __FILE__, (unsigned)(__LINE__)), 0)	\
 			(gl3d::assertFunc(#expression, __FILE__, (unsigned)(__LINE__)), 0)	\
@@ -228,6 +236,16 @@ namespace gl3d
 			(gl3d::assertFunc(#expression, __FILE__, (unsigned)(__LINE__), comment), 0)\
 			(gl3d::assertFunc(#expression, __FILE__, (unsigned)(__LINE__), comment), 0)\
 		)
 		)
 
 
+#else 
+
+#define gl3dAssert(expression) 
+
+#define gl3dAssertComment(expression, comment) 
+
+#endif
+
+
+
 #pragma endregion
 #pragma endregion
 
 
 
 
@@ -34087,6 +34105,7 @@ namespace gl3d
 
 
 		bool normalMap = 1; 
 		bool normalMap = 1; 
 		bool useSSAO = 1;
 		bool useSSAO = 1;
+		bool useTheHbaoImplementation = 1;
 		
 		
 		//todo split stuff into separate things
 		//todo split stuff into separate things
 		bool bloom = 1;
 		bool bloom = 1;
@@ -34908,6 +34927,8 @@ namespace gl3d
 		Camera camera;
 		Camera camera;
 		SkyBox skyBox;
 		SkyBox skyBox;
 
 
+		int tonemapper = 1; //todo add enum, todo save data
+
 		//debug stuff todo
 		//debug stuff todo
 		void renderModelNormals(Model o, glm::vec3 position, glm::vec3 rotation = {},
 		void renderModelNormals(Model o, glm::vec3 position, glm::vec3 rotation = {},
 			glm::vec3 scale = { 1,1,1 }, float normalSize = 0.5, glm::vec3 normalColor = {0.7, 0.7, 0.1});
 			glm::vec3 scale = { 1,1,1 }, float normalSize = 0.5, glm::vec3 normalColor = {0.7, 0.7, 0.1});
@@ -34970,13 +34991,13 @@ namespace gl3d
 			void renderSkyBox(Camera &c, SkyBox &s); //todo remove this later
 			void renderSkyBox(Camera &c, SkyBox &s); //todo remove this later
 			void renderSkyBoxBefore(Camera& c, SkyBox& s);
 			void renderSkyBoxBefore(Camera& c, SkyBox& s);
 
 
-			int getMaterialIndex(Material m);
-			int getModelIndex(Model o);
-			int getTextureIndex(Texture t);
-			int getEntityIndex(Entity t);
-			int getSpotLightIndex(SpotLight l);
-			int getPointLightIndex(PointLight l);
-			int getDirectionalLightIndex(DirectionalLight l);
+			int getMaterialIndex(Material &m);
+			int getModelIndex(Model &o);
+			int getTextureIndex(Texture &t);
+			int getEntityIndex(Entity &e);
+			int getSpotLightIndex(SpotLight &l);
+			int getPointLightIndex(PointLight &l);
+			int getDirectionalLightIndex(DirectionalLight &l);
 
 
 			//material
 			//material
 			std::vector<MaterialValues> materials;
 			std::vector<MaterialValues> materials;
@@ -35145,6 +35166,7 @@ namespace gl3d
 				GLint u_texture;
 				GLint u_texture;
 				GLint u_exposure;
 				GLint u_exposure;
 				GLint u_tresshold;
 				GLint u_tresshold;
+				GLint u_tonemapper;
 			}filterShader;
 			}filterShader;
 
 
 			struct
 			struct
@@ -35191,7 +35213,7 @@ namespace gl3d
 			GLint u_useSSAO;	//post process shader
 			GLint u_useSSAO;	//post process shader
 			GLint u_ssaoExponent;	//post process shader
 			GLint u_ssaoExponent;	//post process shader
 			GLint u_ssao;	//post process shader
 			GLint u_ssao;	//post process shader
-
+			GLint u_tonemapper; //post process shader
 
 
 			GLint u_toBlurcolorInput;
 			GLint u_toBlurcolorInput;
 			GLint u_horizontal;
 			GLint u_horizontal;

Some files were not shown because too many files changed in this diff