浏览代码

working at map'

meemknight 2 年之前
父节点
当前提交
c6f9510694

二进制
Pika/engineResources/engineSaves/options1.bin


二进制
Pika/engineResources/engineSaves/options2.bin


二进制
Pika/engineResources/engineSaves/window1.bin


二进制
Pika/engineResources/engineSaves/window2.bin


二进制
Pika/engineResources/engineSaves/windowPos1.bin


二进制
Pika/engineResources/engineSaves/windowPos2.bin


+ 12 - 0
Pika/gameplay/containers/minecraftDungeons/blocks.cpp

@@ -35,6 +35,8 @@ int atlasData[] =
 	11, 12,//crafting table
 	13, 12,//furnace on
 	12, 13,//furnace off
+	5, 4,  //glass
+	0, 7, //hay
 
 	//back
 	0, 0,
@@ -67,6 +69,8 @@ int atlasData[] =
 	11, 12,//crafting table
 	13, 13,//furnace on
 	13, 13,//furnace off
+	5, 4,  //glass
+	0, 7, //hay
 
 	//top
 	0, 0,
@@ -99,6 +103,8 @@ int atlasData[] =
 	11, 13,//crafting table
 	14, 12,//furnace on
 	14, 12,//furnace off
+	5, 4,  //glass
+	0, 8, //hay
 
 	//bottom
 	0, 0,
@@ -131,6 +137,8 @@ int atlasData[] =
 	4, 15,//crafting table
 	14, 12,//furnace on
 	14, 12,//furnace off
+	5, 4,  //glass
+	0, 8, //hay
 
 	//left
 	0, 0,
@@ -163,6 +171,8 @@ int atlasData[] =
 	12, 12,//crafting table
 	13, 13,//furnace on
 	13, 13,//furnace off
+	5, 4,  //glass
+	0, 7, //hay
 
 	//right
 	0, 0,
@@ -195,6 +205,8 @@ int atlasData[] =
 	12, 12,//crafting table
 	13, 13,//furnace on
 	13, 13,//furnace off
+	5, 4,  //glass
+	0, 7, //hay
 
 };
 

+ 2 - 0
Pika/gameplay/containers/minecraftDungeons/blocks.h

@@ -33,6 +33,8 @@ enum BlockTypes
 	crafting_table,
 	furnace_on,
 	furnace_off,
+	glass,
+	hay,
 	BlocksCount
 };
 

+ 75 - 21
Pika/gameplay/containers/minecraftDungeons/mcDungeonsEditor.h

@@ -41,8 +41,8 @@ struct McDungeonsEditor: public Container
 	pika::gl3d::General3DEditor editor;
 	pika::pikaImgui::FileSelector loadedLevel;
 
-	glm::vec3 worldSize = {150,30,150};
-	unsigned char worldData[150][30][150] = {};
+	glm::vec3 worldSize = {150,40,150};
+	unsigned char worldData[150][40][150] = {};
 
 	unsigned char &getBlockUnsafe(int x, int y, int z)
 	{
@@ -97,7 +97,17 @@ struct McDungeonsEditor: public Container
 		for (int x = 0; x < worldSize.x; x++)
 			for (int z = 0; z < worldSize.z; z++)
 			{
-				getBlockUnsafe(x, 0, z) = BlockTypes::grassBlock;
+				for(int y=0; y<10; y++)
+				{
+					getBlockUnsafe(x, y, z) = BlockTypes::stone;
+				}
+				for (int y = 10; y < 12; y++)
+				{
+					getBlockUnsafe(x, y, z) = BlockTypes::dirt;
+				}
+
+				getBlockUnsafe(x, 12, z) = BlockTypes::grassBlock;
+
 			}
 
 		for (int x = 2; x < 8; x++)
@@ -106,13 +116,13 @@ struct McDungeonsEditor: public Container
 				getBlockUnsafe(x, 4, z) = BlockTypes::stone;
 			}
 
-		getBlockUnsafe(4, 5, 4) = BlockTypes::glowStone;
-		getBlockUnsafe(5, 5, 4) = BlockTypes::redstone_ore;
-
-		getBlockUnsafe(7, 6, 4) = BlockTypes::crafting_table;
-		getBlockUnsafe(9, 6, 4) = BlockTypes::furnace_on;
-		getBlockUnsafe(3, 6, 7) = BlockTypes::furnace_off;
-		getBlockUnsafe(2, 5, 9) = BlockTypes::iron_block;
+		//getBlockUnsafe(4, 5, 4) = BlockTypes::glowStone;
+		//getBlockUnsafe(5, 5, 4) = BlockTypes::redstone_ore;
+		//
+		//getBlockUnsafe(7, 6, 4) = BlockTypes::crafting_table;
+		//getBlockUnsafe(9, 6, 4) = BlockTypes::furnace_on;
+		//getBlockUnsafe(3, 6, 7) = BlockTypes::furnace_off;
+		//getBlockUnsafe(2, 5, 9) = BlockTypes::iron_block;
 
 		getBlockUnsafe(0, 0, 0) = BlockTypes::gold_block;
 
@@ -121,6 +131,23 @@ struct McDungeonsEditor: public Container
 	gl3d::Model createWorld(gl3d::Renderer3D &renderer, gl3d::Material material)
 	{
 
+		auto &pointLights = renderer.internal.pointLightIndexes;
+		while(!pointLights.empty())
+		{
+			::gl3d::PointLight light;
+			light.id_ = pointLights.back();
+			renderer.detletePointLight(light);
+		}
+
+		auto &spoLights = renderer.internal.spotLightIndexes;
+		while (!spoLights.empty())
+		{
+			::gl3d::SpotLight light;
+			light.id_ = spoLights.back();
+			renderer.deleteSpotLight(light);
+		}
+
+
 	#pragma region data
 
 		float uv = 1;
@@ -241,7 +268,6 @@ struct McDungeonsEditor: public Container
 
 		auto addFace = [&](glm::vec3 pos, std::vector<float> &ver, glm::vec2 atlas)
 		{
-			pos.z += 4;
 
 			unsigned int currentIndexPadding = vertexes.size() / 8;
 			for (auto i : ind) { indices.push_back(i + currentIndexPadding); }
@@ -316,7 +342,7 @@ struct McDungeonsEditor: public Container
 			addBack(pos, blockType);
 		};
 
-		auto isSolid = [](unsigned char b) { return b != 0; };
+		auto isSolid = [](unsigned char b) { return b != 0 && b != BlockTypes::glass; };
 
 		for (int x = 0; x < worldSize.x; x++)
 			for (int y = 0; y < worldSize.y; y++)
@@ -357,6 +383,11 @@ struct McDungeonsEditor: public Container
 							addBack({x,y,z}, b);
 						}
 
+						if (b == BlockTypes::glowStone)
+						{
+							renderer.createPointLight({x,y,z}, glm::vec3(0.845f, 0.812f, 0.381f)*1.5f, 16.f, 1.5f);
+						}
+
 					}
 				}
 
@@ -431,12 +462,8 @@ struct McDungeonsEditor: public Container
 		}
 
 
-
 		model = createWorld(renderer, defaultMat[0]);
-		gl3d::Transform t;
-		t.position = {0, -1, -4};
-		//t.rotation = {1.5, 0 , 0};
-		entity = renderer.createEntity(model, t);
+		entity = renderer.createEntity(model);
 
 		renderer.camera.farPlane = 200;
 		renderer.directionalShadows.frustumSplits[0] = 0.06;
@@ -479,10 +506,24 @@ struct McDungeonsEditor: public Container
 			glm::vec3 block = {};
 			glm::vec3 prev = {};
 
-			if (input.lMouse.pressed() && input.hasFocus && input.lastFrameHasFocus) //todo and this by the engine
+			if (input.buttons[pika::Button::LeftCtrl].held())
+			{
+				if (input.rMouse.pressed() || input.lMouse.pressed())
+				{
+					auto cameraRayPos = renderer.camera.position;
+					cameraRayPos.y += 0.5;
+					cameraRayPos.x += 0.5;
+					cameraRayPos.z += 0.5;
+					if (rayMarch(cameraRayPos, renderer.camera.viewDirection, 10, &block, nullptr))
+					{
+						currentBlock = getBlockSafe(block.x, block.y, block.z);
+					}
+				}
+			}else
+			if (input.lMouse.pressed())
 			{
 				auto cameraRayPos = renderer.camera.position;
-				cameraRayPos.y += 1.5;
+				cameraRayPos.y += 0.5;
 				cameraRayPos.x += 0.5;
 				cameraRayPos.z += 0.5;
 				if (rayMarch(cameraRayPos, renderer.camera.viewDirection, 10, &block, nullptr))
@@ -491,10 +532,10 @@ struct McDungeonsEditor: public Container
 					shouldRecreate = 1;
 				}
 			}else 
-			if (input.rMouse.pressed() && input.hasFocus && input.lastFrameHasFocus && currentBlock != 0)
+			if (input.rMouse.pressed() && currentBlock != 0)
 			{
 				auto cameraRayPos = renderer.camera.position;
-				cameraRayPos.y += 1.5;
+				cameraRayPos.y += 0.5;
 				cameraRayPos.x += 0.5;
 				cameraRayPos.z += 0.5;
 				if (rayMarch(cameraRayPos, renderer.camera.viewDirection, 10, nullptr, &block))
@@ -510,6 +551,19 @@ struct McDungeonsEditor: public Container
 
 		ImGui::PushID(requestedInfo.requestedImguiIds);
 
+		if (input.buttons[pika::Button::Z].released())
+		{
+			currentBlock--;
+		}
+
+		if (input.buttons[pika::Button::X].released())
+		{
+			currentBlock++;
+		}
+
+		currentBlock = std::max(0, currentBlock);
+		currentBlock = std::min(BlocksCount-1, currentBlock);
+
 		if (ImGui::Begin("General3DEditor"))
 		{
 			if (ImGui::Button("recreate world"))

+ 8 - 4
Pika/resources/logs.txt

@@ -1,4 +1,8 @@
-#2023-02-26 13:20:48: Created container: Gameplay
-#2023-02-26 13:21:44: Created container: McDungeonsEditor
-#2023-02-26 13:23:54: Destroyed continer: Gameplay #1
-#2023-02-26 13:23:54: Destroyed continer: McDungeonsEditor #2
+#2023-02-27 13:11:25: Created container: Gameplay
+#2023-02-27 13:11:30: Created container: McDungeonsEditor
+#2023-02-27 13:11:32: Destroyed continer: Gameplay #1
+#2023-02-27 13:16:07: Reloaded dll
+#2023-02-27 13:23:25: Reloaded dll
+#2023-02-27 13:27:28: Created container: McDungeonsEditor
+#2023-02-27 13:27:33: Destroyed continer: McDungeonsEditor #3
+#2023-02-27 13:27:42: Destroyed continer: McDungeonsEditor #2

二进制
Pika/resources/materials/mcSprites/albedo.png


二进制
Pika/resources/materials/mcSprites/albedo.psd


二进制
Pika/resources/materials/mcSprites/normal.png


二进制
Pika/resources/materials/mcSprites/normal.psd


二进制
Pika/resources/materials/mcSprites/rma.png


二进制
Pika/resources/materials/mcSprites/rma.psd


二进制
Pika/resources/mcDungeons/map1.mcDungeons