當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。