Jump to content

Recommended Posts

Posted

I have a helper class to help me make BakedQuad's but only the last quad created by that class get's rendered. I can still draw quads created by faceBakery.makeBakedQuad() after that(or before it just only the last quad created with 'faceBaker' will be shown)

 

the quad's I'm trying to draw(vertexData: x,y,z, shadecolor, u,v)

the first one is the quad created by faceBakery.makeBakedQuad(), the other 2 are created by  'faceBaker' and only the 1 and 3 quad get drawn (I can move the first quad to the back and it will still get drawn.)

[12:40:08] [Client thread/INFO] [sTDOUT]: [MinE.client.renderer.isbrh.ModelCrystal:getGeneralQuads:60]: {10.0, 10.0, 16.0, NaN, 0.06251953, 0.10547363, 0.0}
[12:40:08] [Client thread/INFO] [sTDOUT]: [MinE.client.renderer.isbrh.ModelCrystal:getGeneralQuads:60]: {10.0, 6.0, 16.0, NaN, 0.06251953, 0.11327637, 0.0}
[12:40:08] [Client thread/INFO] [sTDOUT]: [MinE.client.renderer.isbrh.ModelCrystal:getGeneralQuads:60]: {10.0, 6.0, 10.0, NaN, 0.07422363, 0.11327637, 0.0}
[12:40:08] [Client thread/INFO] [sTDOUT]: [MinE.client.renderer.isbrh.ModelCrystal:getGeneralQuads:60]: {10.0, 10.0, 10.0, NaN, 0.07422363, 0.10547363, 0.0}
[12:40:08] [Client thread/INFO] [sTDOUT]: [MinE.client.renderer.isbrh.ModelCrystal:getGeneralQuads:85]: {0.0, 6.0, 8.0, NaN, 0.06251953, 0.09376953, 0.0}
[12:40:08] [Client thread/INFO] [sTDOUT]: [MinE.client.renderer.isbrh.ModelCrystal:getGeneralQuads:85]: {0.0, 6.0, 8.0, NaN, 0.06251953, 0.12498047, 0.0}
[12:40:08] [Client thread/INFO] [sTDOUT]: [MinE.client.renderer.isbrh.ModelCrystal:getGeneralQuads:85]: {8.0, 6.0, 0.0, NaN, 0.09373047, 0.12498047, 0.0}
[12:40:08] [Client thread/INFO] [sTDOUT]: [MinE.client.renderer.isbrh.ModelCrystal:getGeneralQuads:85]: {8.0, 0.0, 8.0, NaN, 0.09373047, 0.09376953, 0.0}
[12:40:08] [Client thread/INFO] [sTDOUT]: [MinE.client.renderer.isbrh.ModelCrystal:getGeneralQuads:105]: {16.0, 6.0, 8.0, NaN, 0.06251953, 0.09376953, 0.0}
[12:40:08] [Client thread/INFO] [sTDOUT]: [MinE.client.renderer.isbrh.ModelCrystal:getGeneralQuads:105]: {16.0, 6.0, 8.0, NaN, 0.06251953, 0.12498047, 0.0}
[12:40:08] [Client thread/INFO] [sTDOUT]: [MinE.client.renderer.isbrh.ModelCrystal:getGeneralQuads:105]: {8.0, 6.0, 16.0, NaN, 0.09373047, 0.12498047, 0.0}
[12:40:08] [Client thread/INFO] [sTDOUT]: [MinE.client.renderer.isbrh.ModelCrystal:getGeneralQuads:105]: {8.0, 0.0, 8.0, NaN, 0.09373047, 0.09376953, 0.0}

 

package MinE.client.renderer.isbrh;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.BlockFaceUV;
import net.minecraft.client.renderer.block.model.BlockPartFace;
import net.minecraft.client.renderer.block.model.BlockPartRotation;
import net.minecraft.client.renderer.block.model.FaceBakery;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.resources.model.ModelRotation;
import net.minecraft.util.EnumFacing;

public class FaceBaker {

static FaceBakery faceBakery = new FaceBakery();
int[] vert =new int[28];
int vertexPossition=0;
BlockFaceUV faceUV;

/**
 * add vertex
 * 
 * @param x
 * @param y
 * @param z
 */
public void addVertex(float x, float y, float z, float u, float v){
	if(vertexPossition>3){vertexPossition=0; for(int i=0; i<28; i++){vert[i]=0;}}
	int l = vertexPossition*7;
	vert[l]=Float.floatToIntBits(x/16);
	vert[l+1]=Float.floatToIntBits(y/16);
	vert[l+2]=Float.floatToIntBits(z/16);
	vert[l+3]=-1;
	vert[l+4]=Float.floatToIntBits(u);
	vert[l+5]=Float.floatToIntBits(v);
	vert[l+6]=Float.floatToIntBits(0);
	vertexPossition++;
}

/**
 * requires 3*4 ints(floats(floatToRawIntBits))
 * 
 * @param vertex
 * @return BakedQuad
 */
public BakedQuad makeBaked(int[] vertex){
	BakedQuad bakedQuad = new BakedQuad(vertex, 0, EnumFacing.UP);

	return bakedQuad;
}

/**
 * makes the vertexes into a quad
 * 
 * @return BakedQuad
 */
public BakedQuad getbaked(EnumFacing f){
	BakedQuad bakedQuad = new BakedQuad(vert, 0, f);
	return bakedQuad;
}

}

@Override
public List getGeneralQuads() {

	List<BakedQuad> list = new ArrayList();
	ModelRotation modelRot = ModelRotation.X0_Y0;
	BlockFaceUV uv = new BlockFaceUV(new float[] { 0.0F, 0.0F, 16.0F, 16.0F }, 0);
	BlockPartFace face = new BlockPartFace(null, 0, "", uv);


	list.add(faceBaker.faceBakery.makeBakedQuad(new Vector3f(10.0F, 6.0F, 10.0F), new Vector3f(10.0F, 10.0F, 16.0F), face, redstoneTexture, EnumFacing.EAST, modelRot, null, true, true));

	int[] vert = list.get(list.size()-1).getVertexData();

	for(int m=0; m<4; m++){
		int n = m*7;
		System.out.println("{"+
			Float.intBitsToFloat(vert[n])*16f+", "+
			Float.intBitsToFloat(vert[n+1])*16f+", "+
			Float.intBitsToFloat(vert[n+2])*16f+", "+
			Float.intBitsToFloat(vert[n+3])+", "+
			Float.intBitsToFloat(vert[n+4])+", "+
			Float.intBitsToFloat(vert[n+5])+", "+
			Float.intBitsToFloat(vert[n+6])+"}");
	}

	float i = redstoneTexture.getMinU();
	float j = redstoneTexture.getMinV();
	float k = redstoneTexture.getMaxU();
	float l = redstoneTexture.getMaxV();

	faceBaker.addVertex(0, 6, 8, i, j);
	faceBaker.addVertex(0, 6, 8, i, l);
	faceBaker.addVertex(8, 6, 0, k, l);
	faceBaker.addVertex(8, 0, 8, k, j);
	list.add(faceBaker.getbaked(EnumFacing.DOWN));

	vert = list.get(list.size()-1).getVertexData();

	for(int m=0; m<4; m++){
		int n = m*7;
		System.out.println("{"+
			Float.intBitsToFloat(vert[n])*16f+", "+
			Float.intBitsToFloat(vert[n+1])*16f+", "+
			Float.intBitsToFloat(vert[n+2])*16f+", "+
			Float.intBitsToFloat(vert[n+3])+", "+
			Float.intBitsToFloat(vert[n+4])+", "+
			Float.intBitsToFloat(vert[n+5])+", "+
			Float.intBitsToFloat(vert[n+6])+"}");
	}

	faceBaker.addVertex(16, 6, 8, i, j);
	faceBaker.addVertex(16, 6, 8, i, l);
	faceBaker.addVertex(8, 6, 16, k, l);
	faceBaker.addVertex(8, 0, 8, k, j);
	list.add(faceBaker.getbaked(EnumFacing.EAST));

	vert = list.get(list.size()-1).getVertexData();

	for(int m=0; m<4; m++){
		int n = m*7;
		System.out.println("{"+
			Float.intBitsToFloat(vert[n])*16f+", "+
			Float.intBitsToFloat(vert[n+1])*16f+", "+
			Float.intBitsToFloat(vert[n+2])*16f+", "+
			Float.intBitsToFloat(vert[n+3])+", "+
			Float.intBitsToFloat(vert[n+4])+", "+
			Float.intBitsToFloat(vert[n+5])+", "+
			Float.intBitsToFloat(vert[n+6])+"}");
	}

	return list;
}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.