当前位置: 首页>>代码示例>>Java>>正文


Java Tessellator.startDrawing方法代码示例

本文整理汇总了Java中net.minecraft.client.renderer.Tessellator.startDrawing方法的典型用法代码示例。如果您正苦于以下问题:Java Tessellator.startDrawing方法的具体用法?Java Tessellator.startDrawing怎么用?Java Tessellator.startDrawing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.client.renderer.Tessellator的用法示例。


在下文中一共展示了Tessellator.startDrawing方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doRender_NeutralBeam

import net.minecraft.client.renderer.Tessellator; //导入方法依赖的package包/类
public void doRender_NeutralBeam(_ProjectileBase entity, double x, double y, double z, float yaw, float tick, float beamWidth) 
  {
  	//GL11.glPushMatrix();
  	
//float f2 = par9;// (float) player.innerRotation + par9;
float f3 = MathHelper.sin(tick * 0.2F) / 2.0F + 0.5F;
f3 = (f3 * f3 + f3) * 0.2F;

float xPosEnd = (float) (entity.ownerX - entity.posX - (entity.prevPosX - entity.posX) * (double) (1.0F - tick));
float yPosEnd = (float) ((double) f3 + entity.ownerY - entity.posY - (entity.prevPosY - entity.posY) * (double) (1.0F - tick));
float zPosEnd = (float) (entity.ownerZ - entity.posZ - (entity.prevPosZ - entity.posZ) * (double) (1.0F - tick));

//for rotation/distance
float f7 = MathHelper.sqrt_float(xPosEnd * xPosEnd + zPosEnd * zPosEnd);
float f8 = MathHelper.sqrt_float(xPosEnd * xPosEnd + yPosEnd * yPosEnd + zPosEnd * zPosEnd);

// Changing the starting point here slightly, so it doesn't come out of the center
//int distance = 6;	// Increasing this will likely increase the distance
//double adjustmentZ = -MathHelper.cos((entity.shootingEntity.rotationYaw) * (float)Math.PI / 180.0F) * (distance * 0.08);
//double adjustmentX = MathHelper.sin((entity.shootingEntity.rotationYaw) * (float)Math.PI / 180.0F) * (distance * 0.08);

// Start drawing (i think)
GL11.glTranslated((float) x, (float) y, (float) z);	// Adjusted with distance to shooter
GL11.glRotatef((float) (-Math.atan2((double) zPosEnd, (double) xPosEnd)) * 180.0F / (float) Math.PI - 90.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef((float) (-Math.atan2((double) f7, (double) yPosEnd)) * 180.0F / (float) Math.PI - 90.0F, 1.0F, 0.0F, 0.0F);
Tessellator tessellator = Tessellator.instance;

//Makes the beam look nice
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL11.GL_CULL_FACE);

//Shading?
GL11.glShadeModel(GL11.GL_SMOOTH);

//from what i can tell f9 and f10 make the beam change (looks like its rotating or whatnot)
float f9 = 0.0F - ((float) entity.ticksExisted + tick) * 0.01F;
float f10 = MathHelper.sqrt_float(xPosEnd * xPosEnd + yPosEnd * yPosEnd + zPosEnd * zPosEnd) / 32.0F - ((float) entity.ticksExisted + tick) * 0.01F;

// change draw mode
tessellator.startDrawing(5);
byte b0 = 8;	// how many sides the circle has?

//float beamWidth = 0.15f;

for (int i = 0; i <= b0; ++i) 	// makes one side circular(fancy math stuff)
{
       float f11 = MathHelper.sin((float) (i % b0) * (float) Math.PI * 2.0F / (float) b0) * beamWidth;		// "changing the 2 or .75 should change size of circle"
       float f12 = MathHelper.cos((float) (i % b0) * (float) Math.PI * 2.0F / (float) b0) * beamWidth;		// The 2 seems to be there to describe a full circle
       float f13 = (float) (i % b0) * 1.0F / (float) b0;												// 1 makes it a half circle
       tessellator.setColorOpaque_I(0);
       tessellator.addVertexWithUV((double) (f11 * 0.2F), (double) (f12 * 0.2F), 0.0D, (double) f13, (double) f10);	// Now how do I shorten the beam slightly
       tessellator.setColorOpaque_I(16777215);																			// so it doesn't appear from the center of the shooter
       tessellator.addVertexWithUV((double) f11, (double) f12, (double) f8, (double) f13, (double) f9);				
}

tessellator.draw();	// draw added vertices
  
// reset openGl stuff?
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glShadeModel(GL11.GL_FLAT);
RenderHelper.enableStandardItemLighting();
  	
  	GL11.glPopMatrix();
  }
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:65,代码来源:Render_Projectile.java


注:本文中的net.minecraft.client.renderer.Tessellator.startDrawing方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。