mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 10:25:06 -04:00
added support for rotated textures
This commit is contained in:
parent
ac8e57c3d4
commit
cbf73f02d1
@ -63,8 +63,6 @@ public class MainWindow {
|
|||||||
float mouseY = (float) openGLWindow.getMouseY();
|
float mouseY = (float) openGLWindow.getMouseY();
|
||||||
switch (renderMode) {
|
switch (renderMode) {
|
||||||
case MAIN_MENU:
|
case MAIN_MENU:
|
||||||
if (glfwGetKey(openGLWindow.getWindow(), GLFW_KEY_ESCAPE) == GLFW_PRESS)
|
|
||||||
close();
|
|
||||||
glOrtho(0.f, openGLWindow.getWidth(), openGLWindow.getHeight(), 0.f, 0.f, 1.f);
|
glOrtho(0.f, openGLWindow.getWidth(), openGLWindow.getHeight(), 0.f, 0.f, 1.f);
|
||||||
mainMenu.draw(mouseX, mouseY);
|
mainMenu.draw(mouseX, mouseY);
|
||||||
break;
|
break;
|
||||||
@ -109,10 +107,6 @@ public class MainWindow {
|
|||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void close() {
|
|
||||||
//System.exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PlayerController getPlayerController() {
|
public static PlayerController getPlayerController() {
|
||||||
return playerController;
|
return playerController;
|
||||||
}
|
}
|
||||||
|
@ -19,13 +19,15 @@ import de.bixilon.minosoft.render.texture.InFaceUV;
|
|||||||
import javafx.util.Pair;
|
import javafx.util.Pair;
|
||||||
|
|
||||||
public class Face {
|
public class Face {
|
||||||
|
int textureRotation;
|
||||||
SubBlockPosition[] positions;
|
SubBlockPosition[] positions;
|
||||||
InFaceUV uv;
|
InFaceUV uv;
|
||||||
|
|
||||||
public Face(Pair<Float, Float> texture, InFaceUV uv, SubBlockPosition[] facePositions) {
|
public Face(Pair<Float, Float> texture, InFaceUV uv, SubBlockPosition[] facePositions, int textureRotation) {
|
||||||
positions = facePositions;
|
positions = facePositions;
|
||||||
this.uv = uv;
|
this.uv = uv;
|
||||||
this.uv.prepare(texture);
|
this.uv.prepare(texture);
|
||||||
|
this.textureRotation = textureRotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Face() {
|
public Face() {
|
||||||
@ -34,7 +36,7 @@ public class Face {
|
|||||||
|
|
||||||
public void draw(BlockPosition pos) {
|
public void draw(BlockPosition pos) {
|
||||||
for (int i = 0; i < positions.length; i++) {
|
for (int i = 0; i < positions.length; i++) {
|
||||||
uv.draw(i);
|
uv.draw(i + textureRotation);
|
||||||
positions[i].draw(pos);
|
positions[i].draw(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ package de.bixilon.minosoft.render.blockModels.subBlocks;
|
|||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
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.BlockProperties;
|
||||||
import de.bixilon.minosoft.game.datatypes.objectLoader.blocks.BlockRotation;
|
import de.bixilon.minosoft.game.datatypes.objectLoader.blocks.BlockRotation;
|
||||||
import de.bixilon.minosoft.render.blockModels.Face.Face;
|
import de.bixilon.minosoft.render.blockModels.Face.Face;
|
||||||
import de.bixilon.minosoft.render.blockModels.Face.FaceOrientation;
|
import de.bixilon.minosoft.render.blockModels.Face.FaceOrientation;
|
||||||
@ -112,17 +113,78 @@ public class SubBlock {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (block.getRotation().equals(BlockRotation.DOWN)) {
|
if (block.getRotation().equals(BlockRotation.DOWN)) {
|
||||||
|
if (orientation.equals(FaceOrientation.UP)) {
|
||||||
|
result.add(prepareFace(FaceOrientation.DOWN, orientation,
|
||||||
|
adjacentBlocks));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (orientation.equals(FaceOrientation.DOWN)) {
|
if (orientation.equals(FaceOrientation.DOWN)) {
|
||||||
result.add(prepareFace(FaceOrientation.DOWN, FaceOrientation.UP,
|
result.add(prepareFace(FaceOrientation.UP, orientation,
|
||||||
|
adjacentBlocks));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else if (block.getProperties().contains(BlockProperties.AXIS_X)) {
|
||||||
|
if (orientation.equals(FaceOrientation.EAST)) {
|
||||||
|
result.add(prepareFace(FaceOrientation.UP, orientation,
|
||||||
|
adjacentBlocks));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (orientation.equals(FaceOrientation.WEST)) {
|
||||||
|
result.add(prepareFace(FaceOrientation.DOWN, orientation,
|
||||||
adjacentBlocks));
|
adjacentBlocks));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (orientation.equals(FaceOrientation.UP)) {
|
if (orientation.equals(FaceOrientation.UP)) {
|
||||||
result.add(prepareFace(FaceOrientation.UP, FaceOrientation.DOWN,
|
result.add(prepareFace(FaceOrientation.EAST, orientation,
|
||||||
|
adjacentBlocks, 1));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (orientation.equals(FaceOrientation.DOWN)) {
|
||||||
|
result.add(prepareFace(FaceOrientation.WEST, orientation,
|
||||||
|
adjacentBlocks, 1));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (orientation.equals(FaceOrientation.NORTH)) {
|
||||||
|
result.add(prepareFace(orientation, orientation,
|
||||||
|
adjacentBlocks, 1));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (orientation.equals(FaceOrientation.SOUTH)) {
|
||||||
|
result.add(prepareFace(orientation, orientation,
|
||||||
|
adjacentBlocks, 1));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else if (block.getProperties().contains(BlockProperties.AXIS_Z)) {
|
||||||
|
if (orientation.equals(FaceOrientation.EAST)) {
|
||||||
|
result.add(prepareFace(orientation, orientation,
|
||||||
|
adjacentBlocks, 1));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (orientation.equals(FaceOrientation.WEST)) {
|
||||||
|
result.add(prepareFace(orientation, orientation,
|
||||||
|
adjacentBlocks, 1));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (orientation.equals(FaceOrientation.UP)) {
|
||||||
|
result.add(prepareFace(FaceOrientation.EAST, orientation,
|
||||||
|
adjacentBlocks));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (orientation.equals(FaceOrientation.DOWN)) {
|
||||||
|
result.add(prepareFace(FaceOrientation.WEST, orientation,
|
||||||
|
adjacentBlocks));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (orientation.equals(FaceOrientation.NORTH)) {
|
||||||
|
result.add(prepareFace(FaceOrientation.UP, orientation,
|
||||||
|
adjacentBlocks));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (orientation.equals(FaceOrientation.SOUTH)) {
|
||||||
|
result.add(prepareFace(FaceOrientation.DOWN, orientation,
|
||||||
adjacentBlocks));
|
adjacentBlocks));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
result.add(prepareFace(orientation, orientation, adjacentBlocks));
|
result.add(prepareFace(orientation, orientation, adjacentBlocks));
|
||||||
}
|
}
|
||||||
@ -130,12 +192,18 @@ public class SubBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Face prepareFace(FaceOrientation textureDirection, FaceOrientation faceDirection,
|
private Face prepareFace(FaceOrientation textureDirection, FaceOrientation faceDirection,
|
||||||
HashMap<FaceOrientation, Boolean> adjacentBlocks) {
|
HashMap<FaceOrientation, Boolean> adjacentBlocks, int textureRotation) {
|
||||||
if (adjacentBlocks.get(faceDirection) && !cullFaceTextures.get(faceDirection)) {
|
if (adjacentBlocks.get(faceDirection) && !cullFaceTextures.get(faceDirection)) {
|
||||||
return new Face();
|
return new Face();
|
||||||
}
|
}
|
||||||
return new Face(textureCoordinates.get(textureDirection), uv.get(textureDirection),
|
return new Face(textureCoordinates.get(textureDirection), uv.get(textureDirection),
|
||||||
cuboid.getFacePositions(faceDirection));
|
cuboid.getFacePositions(faceDirection), textureRotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Face prepareFace(FaceOrientation textureDirection, FaceOrientation faceDirection,
|
||||||
|
HashMap<FaceOrientation, Boolean> adjacentBlocks) {
|
||||||
|
return prepareFace(textureDirection, faceDirection,
|
||||||
|
adjacentBlocks, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFull() {
|
public boolean isFull() {
|
||||||
|
@ -47,6 +47,9 @@ public class InFaceUV {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void draw(int i) {
|
public void draw(int i) {
|
||||||
|
if (i > 3) {
|
||||||
|
i -= 4;
|
||||||
|
}
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0:
|
case 0:
|
||||||
glTexCoord2f(realU1, realV1);
|
glTexCoord2f(realU1, realV1);
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
"gold_ore": "regular",
|
"gold_ore": "regular",
|
||||||
"iron_ore": "regular",
|
"iron_ore": "regular",
|
||||||
"coal_ore": "regular",
|
"coal_ore": "regular",
|
||||||
|
"oak_log": "regular",
|
||||||
"spruce_log": "regular",
|
"spruce_log": "regular",
|
||||||
"birch_log": "regular",
|
"birch_log": "regular",
|
||||||
"jungle_log": "regular",
|
"jungle_log": "regular",
|
||||||
@ -109,7 +110,96 @@
|
|||||||
"poppy": "regular",
|
"poppy": "regular",
|
||||||
"blue_orchid": "regular",
|
"blue_orchid": "regular",
|
||||||
"allium": "regular",
|
"allium": "regular",
|
||||||
"azure_bluet": "regular"
|
"azure_bluet": "regular",
|
||||||
|
"red_tulip": "regular",
|
||||||
|
"orange_tulip": "regular",
|
||||||
|
"white_tulip": "regular",
|
||||||
|
"pink_tulip": "regular",
|
||||||
|
"oxeye_daisy": "regular",
|
||||||
|
"brown_mushroom": "regular",
|
||||||
|
"red_mushroom": "regular",
|
||||||
|
"gold_block": "regular",
|
||||||
|
"iron_block": "regular",
|
||||||
|
"stone_slab": {
|
||||||
|
"else": "stone_slab",
|
||||||
|
"top": "stone_slab_top",
|
||||||
|
"bottom": "stone_slab",
|
||||||
|
"double": "stone"
|
||||||
|
},
|
||||||
|
"sandstone_slab": {
|
||||||
|
"else": "sandstone_slab",
|
||||||
|
"top": "sandstone_slab_top",
|
||||||
|
"bottom": "sandstone_slab",
|
||||||
|
"double": "sandstone"
|
||||||
|
},
|
||||||
|
"oak_slab": {
|
||||||
|
"else": "oak_slab",
|
||||||
|
"top": "oak_slab_top",
|
||||||
|
"bottom": "oak_slab",
|
||||||
|
"double": "oak_planks"
|
||||||
|
},
|
||||||
|
"spruce_slab": {
|
||||||
|
"else": "spruce_slab",
|
||||||
|
"top": "spruce_slab_top",
|
||||||
|
"bottom": "spruce_slab",
|
||||||
|
"double": "spruce_planks"
|
||||||
|
},
|
||||||
|
"birch_slab": {
|
||||||
|
"else": "birch_slab",
|
||||||
|
"top": "birch_slab_top",
|
||||||
|
"bottom": "birch_slab",
|
||||||
|
"double": "birch_planks"
|
||||||
|
},
|
||||||
|
"acacia_slab": {
|
||||||
|
"else": "acacia_slab",
|
||||||
|
"top": "acacia_slab_top",
|
||||||
|
"bottom": "acacia_slab",
|
||||||
|
"double": "acacia_planks"
|
||||||
|
},
|
||||||
|
"dark_oak_slab": {
|
||||||
|
"else": "dark_oak_slab",
|
||||||
|
"top": "dark_oak_slab_top",
|
||||||
|
"bottom": "dark_oak_slab",
|
||||||
|
"double": "dark_oak_planks"
|
||||||
|
},
|
||||||
|
"cobblestone_slab": {
|
||||||
|
"else": "cobblestone_slab",
|
||||||
|
"top": "cobblestone_slab_top",
|
||||||
|
"bottom": "cobblestone_slab",
|
||||||
|
"double": "cobblestone"
|
||||||
|
},
|
||||||
|
"brick_slab": {
|
||||||
|
"else": "brick_slab",
|
||||||
|
"top": "brick_slab_top",
|
||||||
|
"bottom": "brick_slab",
|
||||||
|
"double": "bricks"
|
||||||
|
},
|
||||||
|
"stone_brick_slab": {
|
||||||
|
"else": "stone_brick_slab",
|
||||||
|
"top": "stone_brick_slab_top",
|
||||||
|
"bottom": "stone_brick_slab",
|
||||||
|
"double": "stone_bricks"
|
||||||
|
},
|
||||||
|
"nether_brick_slab": {
|
||||||
|
"else": "nether_brick_slab",
|
||||||
|
"top": "nether_brick_slab_top",
|
||||||
|
"bottom": "nether_brick_slab",
|
||||||
|
"double": "nether_bricks"
|
||||||
|
},
|
||||||
|
"quartz_slab": {
|
||||||
|
"else": "quartz_slab",
|
||||||
|
"top": "quartz_slab_top",
|
||||||
|
"bottom": "quartz_slab",
|
||||||
|
"double": "quartz_block"
|
||||||
|
},
|
||||||
|
"bricks": "regular",
|
||||||
|
"tnt": "regular",
|
||||||
|
"bookshelf": "regular",
|
||||||
|
"mossy_cobblestone": "regular",
|
||||||
|
"obsidian": "regular",
|
||||||
|
"torch": "regular",
|
||||||
|
"wall_torch": "regular",
|
||||||
|
"spawner": "regular"
|
||||||
},
|
},
|
||||||
"tinted_textures": {
|
"tinted_textures": {
|
||||||
"block/grass_block_top": [0,1,0],
|
"block/grass_block_top": [0,1,0],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user