Hello JGO, today I’ve been messing around with cubes in a 3D application
Basically what I’m trying to accomplish is shown in the images below, but I’ll also explain it:
Here is what I am starting with:
I’m trying to accomplish something around the lines of:
Now I have been experimenting with this for the past few hours and I can’t seem to write a method that “Dynamically” adjusts.
Here is the method at the moment (Clean restart, was WAY too long):
/**
* Updating the blocks texture.
* @param parentChunk The chunk to iterate through.
*/
public void updateBlockTexture(Chunk parentChunk) {
// obtain a instance of this block (class)
final Block b1 = (Block) this;
// iterate through the parent chunk's blocks.
for (int i = 0; i < parentChunk.getBlockList().size(); i++) {
// obtaining a block from the list.
final Block b2 = parentChunk.getBlockList().get(i);
// are the blocks identical?
final boolean identical = Boolean.valueOf(b1 == b2 || b2 == b1);
if (!identical) {
// check if b1 is ontop of b2
if (b1.isOntopOf(b2)) {
// updateB2.texture -> solid block texture (Vice Verca)
}
// check if b2 is ontop of b1
if (b2.isOntopOf(b1)) {
// updateB1.texture -> solid block texture (Vice Verca)
}
// TODO: Check blocks on top of blocks.
}
}
}
When I wrote a somewhat decent version of this earlier I managed to get it to do what I want, but when I changed the chunks size It wouldn’t function properly xD.
If somebody whose done this before could help me out with a explanation / pseudo code or if anybody could link me to a tutorial I’d be very grateful thanks JGO
If you need anymore information, please ask