use of net.minecraft.client.renderer.VertexBuffer in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class EntityCannonBasicRender method renderHead.
private void renderHead(EntityCannonBasic entity, double x, double y, double z, float entityYaw, float partialTicks) {
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer vertexbuffer = tessellator.getBuffer();
vertexbuffer.begin(7, DefaultVertexFormats.BLOCK);
BlockPos blockpos = new BlockPos(entity.posX, entity.posY, entity.posZ);
// GlStateManager.translate((float)(x - (double)blockpos.getX() - 0.5D), (float)(y - (double)blockpos.getY()), (float)(z - (double)blockpos.getZ() - 0.5D));
BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
blockrendererdispatcher.getBlockModelRenderer().renderModel(entity.worldObj, blockrendererdispatcher.getModelForState(headState), headState, blockpos, vertexbuffer, false, 0);
tessellator.draw();
}
use of net.minecraft.client.renderer.VertexBuffer in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class HovercraftControllerGUI method drawBackground.
@Override
public void drawBackground(int tint) {
GlStateManager.disableLighting();
GlStateManager.disableFog();
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer worldrenderer = tessellator.getBuffer();
this.mc.getTextureManager().bindTexture(background);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
float f = 32.0F;
worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
worldrenderer.pos(0.0D, (double) this.height, 0.0D).tex(0.0D, (double) ((float) this.height / 32.0F + (float) tint)).color(64, 64, 64, 255).endVertex();
worldrenderer.pos((double) this.width, (double) this.height, 0.0D).tex((double) ((float) this.width / 32.0F), (double) ((float) this.height / 32.0F + (float) tint)).color(64, 64, 64, 255).endVertex();
worldrenderer.pos((double) this.width, 0.0D, 0.0D).tex((double) ((float) this.width / 32.0F), (double) tint).color(64, 64, 64, 255).endVertex();
worldrenderer.pos(0.0D, 0.0D, 0.0D).tex(0.0D, (double) tint).color(64, 64, 64, 255).endVertex();
tessellator.draw();
}
use of net.minecraft.client.renderer.VertexBuffer in project Railcraft by Railcraft.
the class LocomotiveRendererDefault method renderLocomotive.
// @Override
// public IIcon[] getItemIcons() {
// return itemIcons;
// }
//
// @Override
// public void registerItemIcons(IIconRegister iconRegister) {
// String tag = "railcraft:locomotives/" + MiscTools.cleanTag(modelTag);
// itemIcons[0] = iconRegister.registerIcon(tag + ".primary");
// itemIcons[1] = iconRegister.registerIcon(tag + ".secondary");
// itemIcons[2] = iconRegister.registerIcon(tag + ".nocolor");
// }
@Override
public void renderLocomotive(ICartRenderer renderer, EntityMinecart cart, int primaryColor, int secondaryColor, @Nullable ResourceLocation emblemTexture, float light, float time) {
OpenGL.glPushMatrix();
OpenGL.glPushAttrib(GL11.GL_ENABLE_BIT);
// OpenGL.glEnable(GL11.GL_BLEND);
// OpenGL.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
OpenGL.glScalef(-1F, -1F, 1.0F);
color[0] = primaryColor;
color[1] = secondaryColor;
for (int pass = 0; pass < textures.length; pass++) {
renderer.bindTex(textures[pass]);
int c = color[pass];
float dim = 1.0F;
float c1 = (float) (c >> 16 & 255) / 255.0F;
float c2 = (float) (c >> 8 & 255) / 255.0F;
float c3 = (float) (c & 255) / 255.0F;
OpenGL.glColor4f(c1 * dim, c2 * dim, c3 * dim, SeasonPlugin.isGhostTrain(cart) ? 0.5F : 1);
model.render(cart, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
}
OpenGL.glPopAttrib();
if (emblemTexture != null) {
renderer.bindTex(emblemTexture);
Tessellator tess = Tessellator.getInstance();
VertexBuffer vertexBuffer = tess.getBuffer();
// float size = 0.22F;
// float offsetX = -0.25F;
// float offsetY = -0.25F;
// float offsetZ = -0.46F;
// TODO: Test this!
vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
vertexBuffer.pos(emblemOffsetX - emblemSize, emblemOffsetY - emblemSize, emblemOffsetZ).tex(0, 0).endVertex();
vertexBuffer.pos(emblemOffsetX - emblemSize, emblemOffsetY + emblemSize, emblemOffsetZ).tex(0, 1).endVertex();
vertexBuffer.pos(emblemOffsetX + emblemSize, emblemOffsetY + emblemSize, emblemOffsetZ).tex(1, 1).endVertex();
vertexBuffer.pos(emblemOffsetX + emblemSize, emblemOffsetY + -emblemSize, emblemOffsetZ).tex(1, 0).endVertex();
vertexBuffer.pos(emblemOffsetX + emblemSize, emblemOffsetY + -emblemSize, -emblemOffsetZ).tex(0, 0).endVertex();
vertexBuffer.pos(emblemOffsetX + emblemSize, emblemOffsetY + emblemSize, -emblemOffsetZ).tex(0, 1).endVertex();
vertexBuffer.pos(emblemOffsetX - emblemSize, emblemOffsetY + emblemSize, -emblemOffsetZ).tex(1, 1).endVertex();
vertexBuffer.pos(emblemOffsetX - emblemSize, emblemOffsetY - emblemSize, -emblemOffsetZ).tex(1, 0).endVertex();
tess.draw();
}
// OpenGL.glDisable(GL11.GL_BLEND);
OpenGL.glPopMatrix();
}
use of net.minecraft.client.renderer.VertexBuffer in project Railcraft by Railcraft.
the class TESRSignals method doRenderAspect.
protected void doRenderAspect(double x, double y, double z) {
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer vertexBuffer = tessellator.getBuffer();
final float depth = 1.95F * RenderTools.PIXEL;
OpenGL.glPushMatrix();
// no idea why this is necessary, but without it the texture brightness varies depending on what is on screen
GL11.glNormal3f(0.0F, 0.0F, 1.0F);
OpenGL.glEnable(GL11.GL_LIGHTING);
OpenGL.glColor3f(1, 1, 1);
OpenGL.glTranslated(x, y, z);
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
if (lampInfo.glow)
RenderTools.setBrightness(0.875F);
vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
if (lampInfo.sides[2].render) {
TextureAtlasSprite texture = lampInfo.sides[2].texture;
vertexBuffer.pos(0, 0, depth).tex(texture.getInterpolatedU(16), texture.getInterpolatedV(16)).endVertex();
vertexBuffer.pos(0, 1, depth).tex(texture.getInterpolatedU(16), texture.getInterpolatedV(0)).endVertex();
vertexBuffer.pos(1, 1, depth).tex(texture.getInterpolatedU(0), texture.getInterpolatedV(0)).endVertex();
vertexBuffer.pos(1, 0, depth).tex(texture.getInterpolatedU(0), texture.getInterpolatedV(16)).endVertex();
}
if (lampInfo.sides[3].render) {
TextureAtlasSprite texture = lampInfo.sides[3].texture;
vertexBuffer.pos(0, 0, 1 - depth).tex(texture.getInterpolatedU(0), texture.getInterpolatedV(16)).endVertex();
vertexBuffer.pos(1, 0, 1 - depth).tex(texture.getInterpolatedU(16), texture.getInterpolatedV(16)).endVertex();
vertexBuffer.pos(1, 1, 1 - depth).tex(texture.getInterpolatedU(16), texture.getInterpolatedV(0)).endVertex();
vertexBuffer.pos(0, 1, 1 - depth).tex(texture.getInterpolatedU(0), texture.getInterpolatedV(0)).endVertex();
}
if (lampInfo.sides[4].render) {
TextureAtlasSprite texture = lampInfo.sides[4].texture;
vertexBuffer.pos(depth, 0, 0).tex(texture.getInterpolatedU(0), texture.getInterpolatedV(16)).endVertex();
vertexBuffer.pos(depth, 0, 1).tex(texture.getInterpolatedU(16), texture.getInterpolatedV(16)).endVertex();
vertexBuffer.pos(depth, 1, 1).tex(texture.getInterpolatedU(16), texture.getInterpolatedV(0)).endVertex();
vertexBuffer.pos(depth, 1, 0).tex(texture.getInterpolatedU(0), texture.getInterpolatedV(0)).endVertex();
}
if (lampInfo.sides[5].render) {
TextureAtlasSprite texture = lampInfo.sides[5].texture;
vertexBuffer.pos(1 - depth, 0, 0).tex(texture.getInterpolatedU(16), texture.getInterpolatedV(16)).endVertex();
vertexBuffer.pos(1 - depth, 1, 0).tex(texture.getInterpolatedU(16), texture.getInterpolatedV(0)).endVertex();
vertexBuffer.pos(1 - depth, 1, 1).tex(texture.getInterpolatedU(0), texture.getInterpolatedV(0)).endVertex();
vertexBuffer.pos(1 - depth, 0, 1).tex(texture.getInterpolatedU(0), texture.getInterpolatedV(16)).endVertex();
}
tessellator.draw();
if (lampInfo.glow)
RenderTools.resetBrightness();
lampInfo.resetSidesAndLight();
OpenGL.glPopMatrix();
}
use of net.minecraft.client.renderer.VertexBuffer in project Railcraft by Railcraft.
the class TESRTurbineGauge method renderTileEntityAt.
@Override
public void renderTileEntityAt(TileSteamTurbine turbine, double x, double y, double z, float partialTicks, int destroyStage) {
if (!turbine.isStructureValid() || turbine.getPatternMarker() != 'W')
// not a gauge block
return;
// half width of the needle
double halfWidth = 0.5 / 16;
// length of the needle (along the center)
double len = 0.26;
// offset to prevent z-fighting
double zOffset = 0.001;
// average the value over time to smooth the needle
double value = turbine.mainGauge = (turbine.mainGauge * 14.0 + turbine.getMainGauge()) / 15.0;
// set the needle angle between 45° (= 0%) and 135° (= 100%)
double angle = Math.toRadians(90 * value + 45);
// vector towards the front of the gauge
int fx = 0, fz = 0;
// vector to the right when looking at the gauge
int rx = 0, rz = 0;
BlockPos patternPos = turbine.getPatternPosition();
if (turbine.getPatternIndex() == 0) {
if (patternPos.getX() == 1) {
fx = -1;
rz = 1;
} else if (patternPos.getX() == 2) {
x++;
z++;
fx = 1;
rz = -1;
}
} else if (turbine.getPatternIndex() == 1)
if (patternPos.getZ() == 1) {
x++;
fz = -1;
rx = -1;
} else if (patternPos.getZ() == 2) {
z++;
fz = 1;
rx = 1;
}
if (fx == 0 && fz == 0 || rx == 0 && rz == 0)
throw new IllegalStateException("can't detect gauge orientation");
// fix lightmap coords to use the brightness value in front of the block, not inside it (which would be just 0)
int lmCoords = turbine.getWorld().getCombinedLight(turbine.getPos().add(fx, 0, fz), 0);
int lmX = lmCoords % 65536;
int lmY = lmCoords / 65536;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lmX / 1.0F, lmY / 1.0F);
OpenGL.glDisable(GL11.GL_TEXTURE_2D);
OpenGL.glDisable(GL11.GL_LIGHTING);
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer vertexBuffer = tessellator.getBuffer();
vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
// move the origin to the center of the gauge
vertexBuffer.setTranslation(x + rx * 0.5 + fx * zOffset, y + 0.5, z + rz * 0.5 + fz * zOffset);
double cosA = Math.cos(angle);
double sinA = Math.sin(angle);
// displacement along the length of the needle
double glx = cosA * len;
double gly = sinA * len;
// displacement along the width of the needle
double gwx = sinA * halfWidth;
double gwy = cosA * halfWidth;
// half width of the horizontal needle part where it connects to the "case"
double baseOffset = 1. / Math.sin(angle) * halfWidth;
// set the needle color to dark-ish red
int red = 100;
int green = 0;
int blue = 0;
int alpha = 255;
vertexBuffer.pos(-rx * baseOffset, 0, -rz * baseOffset).color(red, green, blue, alpha).endVertex();
vertexBuffer.pos(rx * baseOffset, 0, rz * baseOffset).color(red, green, blue, alpha).endVertex();
vertexBuffer.pos(-rx * glx + rx * gwx, gly + gwy, -rz * glx + rz * gwx).color(red, green, blue, alpha).endVertex();
vertexBuffer.pos(-rx * glx - rx * gwx, gly - gwy, -rz * glx - rz * gwx).color(red, green, blue, alpha).endVertex();
tessellator.draw();
// resetting
vertexBuffer.setTranslation(0, 0, 0);
OpenGL.glEnable(GL11.GL_LIGHTING);
OpenGL.glEnable(GL11.GL_TEXTURE_2D);
}
Aggregations