I’m having trouble trying to render a diagonal quad in my block world. I’m trying to implement minecraft like flowers but the sky keeps getting shown through the texture. I’m not sure if this is face culling going on or what. I think my texture coordinates are in the right order because I can see the flower. Also, it is being rendered in the transparent bucket.
See the screenshot below for what it looks like. I am just trying to get one face working right now and I have included the important part of the code.
Thanks!
package com.chappelle.jcraft.shapes;
import java.util.List;
import com.chappelle.jcraft.Block;
import com.chappelle.jcraft.BlockShape;
import com.chappelle.jcraft.BlockSkin_TextureLocation;
import com.chappelle.jcraft.Chunk;
import com.chappelle.jcraft.Vector3Int;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
public class BlockShape_Flower extends BlockShape
{
@Override
public void addTo(Chunk chunk, Block block, Vector3Int blockLocation)
{
Vector3f blockLocation3f = new Vector3f(blockLocation.getX(), blockLocation.getY(), blockLocation.getZ());
addFaceIndices(indices, positions.size());
positions.add(blockLocation3f.add(new Vector3f(1, 0, 0)));
positions.add(blockLocation3f.add(new Vector3f(0, 0, 1)));
positions.add(blockLocation3f.add(new Vector3f(1, 1, 0)));
positions.add(blockLocation3f.add(new Vector3f(0, 1, 1)));
addSquareNormals(normals, -1, 0, -1);
addTextureCoordinates(chunk, textureCoordinates, block.getSkin(chunk, blockLocation, Block.Face.Back).getTextureLocation());
addLighting(chunk, blockLocation, Block.Face.Back);
}
private void addFaceIndices(List<Short> indices, int offset){
indices.add((short) (offset + 2));
indices.add((short) (offset + 0));
indices.add((short) (offset + 1));
indices.add((short) (offset + 1));
indices.add((short) (offset + 3));
indices.add((short) (offset + 2));
}
private void addSquareNormals(List<Float> normals, float normalX, float normalY, float normalZ){
for(int i=0;i<4;i++){
normals.add(normalX);
normals.add(normalY);
normals.add(normalZ);
}
}
private void addTextureCoordinates(Chunk chunk, List<Vector2f> textureCoordinates, BlockSkin_TextureLocation textureLocation){
textureCoordinates.add(getTextureCoordinates(chunk, textureLocation, 0, 0));
textureCoordinates.add(getTextureCoordinates(chunk, textureLocation, 1, 0));
textureCoordinates.add(getTextureCoordinates(chunk, textureLocation, 0, 1));
textureCoordinates.add(getTextureCoordinates(chunk, textureLocation, 1, 1));
}
@Override
protected boolean canBeMerged(Block.Face face){
return false;
}
}