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


Java GLAllocation.createDirectFloatBuffer方法代码示例

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


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

示例1: project2D

import net.minecraft.client.renderer.GLAllocation; //导入方法依赖的package包/类
/**
* Converts a Minecraft world coordinate to a screen coordinate
*
* The world coordinate is the absolute location of a 3d vector
* in the Minecraft world relative to the world origin.
* <p>
* Note that the return value will be scaled to match the current
* GUI resolution of Minecraft.
*
* @param  x  X coordinate in the Minecraft world
* @param  y  Y coordinate in the Minecraft world
* @param  z  Z coordinate in the Minecraft world
* @return Returns a {@link Vector2f} representing a 2D location on the screen,
* or null if the vector fails to be converted.
*/
  public static Vector2f project2D(final float x, final float y, final float z)
  {
  	/**
  	 * Buffer that will hold the screen coordinates
  	 */
      FloatBuffer screen_coords = GLAllocation.createDirectFloatBuffer(3);
      
      /**
       * Buffer that holds the transformation matrix of the view port
       */
      IntBuffer viewport = GLAllocation.createDirectIntBuffer(16);
      
      /**
       * Buffer that holds the transformation matrix of the model view
       */
      FloatBuffer modelview = GLAllocation.createDirectFloatBuffer(16);
      
      /**
       * Buffer that holds the transformation matrix of the projection
       */
      FloatBuffer projection = GLAllocation.createDirectFloatBuffer(16);
      
      /**
       * the return value of the gluProject call
       */
      boolean ret;
      
      
      screen_coords.clear();
      modelview.clear();
      projection.clear();
      
      viewport.clear();

      GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelview);
      GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projection);
      GL11.glGetInteger(GL11.GL_VIEWPORT, viewport);

      ret = GLU.gluProject(x, y, z, modelview, projection, viewport, screen_coords);
      
      if (ret)
      {
          return new Vector2f(screen_coords.get(0), screen_coords.get(1));
      }

      return null;
  }
 
开发者ID:sabarjp,项目名称:ShoulderSurfing,代码行数:63,代码来源:VectorConverter.java

示例2: renderLast

import net.minecraft.client.renderer.GLAllocation; //导入方法依赖的package包/类
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void renderLast(RenderWorldLastEvent evt) {
	if (EntityCamera.isActive()) {
		GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelviewF);
		GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projectionF);
		GL11.glGetInteger(GL11.GL_VIEWPORT, viewport);

		float x = Mouse.getX();
		float y = Mouse.getY();

		FloatBuffer winZ = GLAllocation.createDirectFloatBuffer(1);

		GL11.glReadPixels((int) x, (int) y, 1, 1, GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, winZ);
		GLU.gluUnProject(x, y, 0F, modelviewF, projectionF, viewport, posClose);
		GLU.gluUnProject(x, y, 1F, modelviewF, projectionF, viewport, posFar);

		close = Vec3.createVectorHelper(posClose.get(0), posClose.get(1), posClose.get(2));
		far = Vec3.createVectorHelper(posFar.get(0), posFar.get(1), posFar.get(2));

		// Draw selection box
		if (EntityCamera.mouseover != null) {
			drawBlockBounds(EntityCamera.activeCamera, EntityCamera.mouseover);
		}
	}

	//TODO Render selected minion movement target
}
 
开发者ID:dmillerw,项目名称:RoboticMinions,代码行数:29,代码来源:RenderHelper.java

示例3: project2D

import net.minecraft.client.renderer.GLAllocation; //导入方法依赖的package包/类
/**
* Converts a Minecraft world coordinate to a screen coordinate
*
* The world coordinate is the absolute location of a 3d vector
* in the Minecraft world relative to the world origin.
* <p>
* Note that the return value will be scaled to match the current
* GUI resolution of Minecraft.
*
* @param  x  X coordinate in the Minecraft world
* @param  y  Y coordinate in the Minecraft world
* @param  z  Z coordinate in the Minecraft world
* @return Returns a {@link Vector2f} representing a 2D location on the screen,
* or null if the vector fails to be converted.
*/
  public static Vector2f project2D(float x, float y, float z)
  {
  	/**
  	 * Buffer that will hold the screen coordinates
  	 */
      FloatBuffer screen_coords = GLAllocation.createDirectFloatBuffer(3);
      
      /**
       * Buffer that holds the transformation matrix of the view port
       */
      IntBuffer viewport = GLAllocation.createDirectIntBuffer(16);
      
      /**
       * Buffer that holds the transformation matrix of the model view
       */
      FloatBuffer modelview = GLAllocation.createDirectFloatBuffer(16);
      
      /**
       * Buffer that holds the transformation matrix of the projection
       */
      FloatBuffer projection = GLAllocation.createDirectFloatBuffer(16);
      
      /**
       * the return value of the gluProject call
       */
      boolean ret;
      
      
      screen_coords.clear();
      modelview.clear();
      projection.clear();
      
      viewport.clear();

      GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelview);
      GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projection);
      GL11.glGetInteger(GL11.GL_VIEWPORT, viewport);

      ret = GLU.gluProject(x, y, z, modelview, projection, viewport, screen_coords);
      
      if (ret)
      {
          return new Vector2f(screen_coords.get(0), screen_coords.get(1));
      }

      return null;
  }
 
开发者ID:sabarjp,项目名称:ShoulderSurfing,代码行数:63,代码来源:VectorConverter.java

示例4: onKeypress

import net.minecraft.client.renderer.GLAllocation; //导入方法依赖的package包/类
@Override
public void onKeypress() {
    Minecraft minecraft = FMLClientHandler.instance().getClient();
    if(minecraft.thePlayer != null) {
        ItemStack current = minecraft.thePlayer.getCurrentEquippedItem();
        if(current != null && current.getItem() != null) {

            fbo.begin();

            GlStateManager.matrixMode(GL11.GL_PROJECTION);
            GlStateManager.pushMatrix();
            GlStateManager.loadIdentity();
            GlStateManager.ortho(0, 16, 16, 0, -100000.0, 100000.0);

            GlStateManager.matrixMode(GL11.GL_MODELVIEW);
            FloatBuffer matrix = GLAllocation.createDirectFloatBuffer(16);

            matrix.clear();

            matrix.put(new float[] {
                    1f, 0f, 0f, 0f,
                    0f, 1f, 0f, 0f,
                    0f, 0f, -1f, 0f,
                    0f, 0f, 0f, 1f});

            matrix.rewind();

            //GlStateManager.multMatrix(matrix);

            RenderHelper.enableGUIStandardItemLighting();
            GlStateManager.enableRescaleNormal();
            GlStateManager.enableColorMaterial();
            GlStateManager.enableLighting();

            itemRenderer.func_175042_a(current, 0, 0);

            GlStateManager.disableLighting();
            RenderHelper.disableStandardItemLighting();

            GlStateManager.matrixMode(GL11.GL_PROJECTION);
            GlStateManager.popMatrix();

            fbo.end();

            fbo.saveToFile(new File(minecraft.mcDataDir,
                    String.format("rendered/item_%s_%d%s.png", GameData.getItemRegistry().getNameForObject(current.getItem()).toString().replace(':', '_'), current.getItemDamage(),
                            filenameSuffix)));

            fbo.restoreTexture();
        }
    }
}
 
开发者ID:Kobata,项目名称:item-render,代码行数:53,代码来源:KeybindRenderInventoryBlock.java

示例5: directFloatBuffer

import net.minecraft.client.renderer.GLAllocation; //导入方法依赖的package包/类
/**
 * Asks for a new directly backed FloatBuffer
 *
 * @param size
 *            the number of buffer elements (floats)
 * @return a new direct float buffer
 */
public static FloatBuffer directFloatBuffer(int size) {
	return GLAllocation.createDirectFloatBuffer(size);
}
 
开发者ID:WorldSEnder,项目名称:MCAnm,代码行数:11,代码来源:Utils.java


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