added support for SubBlockRotation reading wip1

This commit is contained in:
Lukas 2020-08-16 16:05:45 +02:00
parent 1fc93f067c
commit 1ad4e19e02
13 changed files with 89 additions and 29 deletions

View File

@ -0,0 +1,18 @@
/*
* Codename Minosoft
* Copyright (C) 2020 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.render.Face;
public enum Axis {
X, Y, Z
}

View File

@ -11,7 +11,7 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft. * This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/ */
package de.bixilon.minosoft.render.fullFace; package de.bixilon.minosoft.render.Face;
public enum FaceOrientation { public enum FaceOrientation {
EAST(0), WEST(1), UP(2), DOWN(3), SOUTH(4), NORTH(5); EAST(0), WEST(1), UP(2), DOWN(3), SOUTH(4), NORTH(5);

View File

@ -11,13 +11,13 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft. * This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/ */
package de.bixilon.minosoft.render.fullFace; package de.bixilon.minosoft.render.Face;
import de.bixilon.minosoft.game.datatypes.world.BlockPosition; import de.bixilon.minosoft.game.datatypes.world.BlockPosition;
import javafx.util.Pair; import javafx.util.Pair;
import org.apache.commons.collections.primitives.ArrayFloatList; import org.apache.commons.collections.primitives.ArrayFloatList;
import static de.bixilon.minosoft.render.fullFace.RenderConstants.UV; import static de.bixilon.minosoft.render.Face.RenderConstants.UV;
public class FullFacePosition { public class FullFacePosition {
private final BlockPosition blockPosition; private final BlockPosition blockPosition;

View File

@ -11,7 +11,7 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft. * This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/ */
package de.bixilon.minosoft.render.fullFace; package de.bixilon.minosoft.render.Face;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;

View File

@ -11,7 +11,7 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft. * This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/ */
package de.bixilon.minosoft.render.fullFace; package de.bixilon.minosoft.render.Face;
public class RenderConstants { public class RenderConstants {
public static final int texturePackRes = 16; public static final int texturePackRes = 16;

View File

@ -17,15 +17,15 @@ import de.bixilon.minosoft.game.datatypes.objectLoader.blocks.Block;
import de.bixilon.minosoft.game.datatypes.objectLoader.blocks.Blocks; import de.bixilon.minosoft.game.datatypes.objectLoader.blocks.Blocks;
import de.bixilon.minosoft.game.datatypes.world.*; import de.bixilon.minosoft.game.datatypes.world.*;
import de.bixilon.minosoft.logging.Log; import de.bixilon.minosoft.logging.Log;
import de.bixilon.minosoft.render.Face.FaceOrientation;
import de.bixilon.minosoft.render.blockModels.BlockModelLoader; import de.bixilon.minosoft.render.blockModels.BlockModelLoader;
import de.bixilon.minosoft.render.blockModels.Face; import de.bixilon.minosoft.render.blockModels.Face;
import de.bixilon.minosoft.render.fullFace.FaceOrientation;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import static de.bixilon.minosoft.render.fullFace.RenderConstants.faceDir; import static de.bixilon.minosoft.render.Face.RenderConstants.faceDir;
import static org.lwjgl.opengl.GL11.*; import static org.lwjgl.opengl.GL11.*;
public class WorldRenderer { public class WorldRenderer {

View File

@ -17,7 +17,8 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import de.bixilon.minosoft.Config; import de.bixilon.minosoft.Config;
import de.bixilon.minosoft.game.datatypes.objectLoader.blocks.Block; import de.bixilon.minosoft.game.datatypes.objectLoader.blocks.Block;
import de.bixilon.minosoft.render.fullFace.FaceOrientation; import de.bixilon.minosoft.render.Face.FaceOrientation;
import de.bixilon.minosoft.render.blockModels.subBlocks.SubBlock;
import de.bixilon.minosoft.render.texture.TextureLoader; import de.bixilon.minosoft.render.texture.TextureLoader;
import java.io.IOException; import java.io.IOException;

View File

@ -19,7 +19,7 @@ import de.bixilon.minosoft.Config;
import de.bixilon.minosoft.game.datatypes.objectLoader.blocks.Block; import de.bixilon.minosoft.game.datatypes.objectLoader.blocks.Block;
import de.bixilon.minosoft.game.datatypes.objectLoader.blocks.Blocks; import de.bixilon.minosoft.game.datatypes.objectLoader.blocks.Blocks;
import de.bixilon.minosoft.logging.Log; import de.bixilon.minosoft.logging.Log;
import de.bixilon.minosoft.render.fullFace.FaceOrientation; import de.bixilon.minosoft.render.Face.FaceOrientation;
import de.bixilon.minosoft.render.texture.TextureLoader; import de.bixilon.minosoft.render.texture.TextureLoader;
import org.apache.commons.collections.primitives.ArrayFloatList; import org.apache.commons.collections.primitives.ArrayFloatList;

View File

@ -14,13 +14,14 @@
package de.bixilon.minosoft.render.blockModels; package de.bixilon.minosoft.render.blockModels;
import de.bixilon.minosoft.game.datatypes.world.BlockPosition; import de.bixilon.minosoft.game.datatypes.world.BlockPosition;
import de.bixilon.minosoft.render.Face.FaceOrientation;
import de.bixilon.minosoft.render.Face.InFaceUV;
import de.bixilon.minosoft.render.MainWindow; import de.bixilon.minosoft.render.MainWindow;
import de.bixilon.minosoft.render.fullFace.FaceOrientation; import de.bixilon.minosoft.render.blockModels.subBlocks.SubBlock;
import de.bixilon.minosoft.render.fullFace.InFaceUV;
import javafx.util.Pair; import javafx.util.Pair;
import static de.bixilon.minosoft.render.fullFace.RenderConstants.blockRes; import static de.bixilon.minosoft.render.Face.RenderConstants.blockRes;
import static de.bixilon.minosoft.render.fullFace.RenderConstants.texturePackRes; import static de.bixilon.minosoft.render.Face.RenderConstants.texturePackRes;
import static org.lwjgl.opengl.GL11.glTexCoord2f; import static org.lwjgl.opengl.GL11.glTexCoord2f;
import static org.lwjgl.opengl.GL11.glVertex3f; import static org.lwjgl.opengl.GL11.glVertex3f;

View File

@ -11,11 +11,12 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft. * This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/ */
package de.bixilon.minosoft.render.blockModels; package de.bixilon.minosoft.render.blockModels.subBlocks;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import de.bixilon.minosoft.render.fullFace.FaceOrientation; import de.bixilon.minosoft.render.Face.FaceOrientation;
import de.bixilon.minosoft.render.fullFace.InFaceUV; import de.bixilon.minosoft.render.Face.InFaceUV;
import de.bixilon.minosoft.render.blockModels.Face;
import de.bixilon.minosoft.render.texture.TextureLoader; import de.bixilon.minosoft.render.texture.TextureLoader;
import javafx.util.Pair; import javafx.util.Pair;
@ -24,6 +25,7 @@ import java.util.HashSet;
import java.util.Map; import java.util.Map;
public class SubBlock { public class SubBlock {
SubBlockRotation rotation;
SubBlockPosition pos1; // the most negative Point of the SubBlock SubBlockPosition pos1; // the most negative Point of the SubBlock
SubBlockPosition pos2; // the most positive Point of the SubBlock SubBlockPosition pos2; // the most positive Point of the SubBlock
@ -49,6 +51,9 @@ public class SubBlock {
orientation, variables); orientation, variables);
} }
} }
if (json.has("rotation")) {
rotation = new SubBlockRotation(json.get("rotation").getAsJsonObject());
}
isFull = (pos1.x == 0 && pos1.y == 0 && pos1.z == 0) && (pos2.x == 16 && pos2.y == 16 && pos2.z == 16); isFull = (pos1.x == 0 && pos1.y == 0 && pos1.z == 0) && (pos2.x == 16 && pos2.y == 16 && pos2.z == 16);
} }

View File

@ -1,6 +1,6 @@
/* /*
* Codename Minosoft * Codename Minosoft
* Copyright (C) 2020 Moritz Zwerger * Copyright (C) 2020 Lukas Eisenhauer
* *
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* *
@ -11,22 +11,16 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft. * This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/ */
package de.bixilon.minosoft.render.blockModels; package de.bixilon.minosoft.render.blockModels.subBlocks;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
public class SubBlockPosition { public class SubBlockPosition {
int x, y, z; float x, y, z;
public SubBlockPosition(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
public SubBlockPosition(JsonArray json) { public SubBlockPosition(JsonArray json) {
x = json.get(0).getAsInt(); x = json.get(0).getAsFloat();
y = json.get(1).getAsInt(); y = json.get(1).getAsFloat();
z = json.get(2).getAsInt(); z = json.get(2).getAsFloat();
} }
} }

View File

@ -0,0 +1,41 @@
/*
* Codename Minosoft
* Copyright (C) 2020 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.render.blockModels.subBlocks;
import com.google.gson.JsonObject;
import de.bixilon.minosoft.render.Face.Axis;
public class SubBlockRotation {
SubBlockPosition origin;
Axis direction;
float angle;
public SubBlockRotation(JsonObject rotation) {
origin = new SubBlockPosition(rotation.get("origin").getAsJsonArray());
String axis = rotation.get("axis").getAsString();
switch (axis) {
case "x":
direction = Axis.X;
break;
case "y":
direction = Axis.Y;
break;
case "z":
direction = Axis.Z;
}
angle = rotation.get("angle").getAsFloat();
}
}

View File

@ -26,7 +26,7 @@ public class PlayerController {
private final float playerWidth = 0.5f; private final float playerWidth = 0.5f;
CameraMovement cameraMovement; CameraMovement cameraMovement;
PlayerMovement playerMovement; PlayerMovement playerMovement;
Vec3 playerPos = new Vec3(0, 1, 0); // the feet position of the player Vec3 playerPos = new Vec3(); // the feet position of the player
Vec3 playerVelocity = new Vec3(); Vec3 playerVelocity = new Vec3();
float gravity = 9.81f; float gravity = 9.81f;
boolean onGround; boolean onGround;