當前位置: 首頁>>代碼示例>>Java>>正文


Java GLU.gluProject方法代碼示例

本文整理匯總了Java中org.lwjgl.util.glu.GLU.gluProject方法的典型用法代碼示例。如果您正苦於以下問題:Java GLU.gluProject方法的具體用法?Java GLU.gluProject怎麽用?Java GLU.gluProject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.lwjgl.util.glu.GLU的用法示例。


在下文中一共展示了GLU.gluProject方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: project

import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
public Vec3 project(float objX, float objY, float objZ) {
    GLU.gluProject(objX, objY, objZ, modelview, projection, viewport, winCoords);

    float winX = winCoords.get(0);
    float winY = winCoords.get(1);
    float winZ = winCoords.get(2);

    return Vec3.createVectorHelper(winX, winY, winZ);
}
 
開發者ID:awesommist,項目名稱:DynamicLib,代碼行數:10,代碼來源:ProjectionHelper.java

示例2: projectToScreen

import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
private void projectToScreen(JGLNode obj) 
    {
        if ((obj.getLowBounds() == null) && (obj.getHighBounds() == null) && (obj.getData("pointMap") == null))
            return;
        FloatBuffer modelView = BufferUtils.createFloatBuffer(16);
        FloatBuffer projection = BufferUtils.createFloatBuffer(16);
        FloatBuffer dviewport = BufferUtils.createFloatBuffer(16);

        GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelView);
        GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projection);
        GL11.glGetFloat(GL11.GL_VIEWPORT, dviewport);

        IntBuffer viewport = BufferLogic.create((int)dviewport.get(0), (int)dviewport.get(1), (int)dviewport.get(2), (int)dviewport.get(3));
        if ((obj.getLowBounds() != null) && (obj.getHighBounds() != null))
        {
            FloatBuffer low = BufferLogic.createFloatBuffer(3);
            GLU.gluProject(obj.getLowBounds().x, obj.getLowBounds().y, obj.getLowBounds().z, modelView, projection, viewport, low);
            FloatBuffer high = BufferLogic.createFloatBuffer(3);
            GLU.gluProject(obj.getHighBounds().x, obj.getHighBounds().y, obj.getHighBounds().z, modelView, projection, viewport, high);
            FloatBuffer mid = BufferLogic.createFloatBuffer(3);
            GLU.gluProject(0, 0, 0, modelView, projection, viewport, mid);
            obj.setScreen(new Point3f(mid.get(0), mid.get(1), mid.get(2)));
            obj.setScreenLowBounds(new Point3f((float)Math.min(low.get(0), high.get(0)), (float)Math.min(low.get(1), high.get(1)), (float)Math.min(low.get(2), high.get(2))));
            obj.setScreenHighBounds(new Point3f((float)Math.max(low.get(0), high.get(0)), (float)Math.max(low.get(1), high.get(1)), (float)Math.max(low.get(2), high.get(2))));
//        System.out.println("modelView="+DoubleUtils.toString(modelView));
//        System.out.println("projection="+DoubleUtils.toString(projection));
//        System.out.println("dviewport="+DoubleUtils.toString(dviewport));
//        System.out.println("Screen="+DoubleUtils.toString(mid));
        }
        Point3f pointMap = (Point3f)obj.getData("pointMap");
        if (pointMap != null)
        {
            FloatBuffer pointMapped = BufferLogic.createFloatBuffer(3);
            GLU.gluUnProject(pointMap.x, pointMap.y, pointMap.z, modelView, projection, viewport, pointMapped);
            Point3f pMapped = new Point3f(pointMapped.get(0), pointMapped.get(1), pointMapped.get(2));
            obj.setData("pointMap", null);
            obj.setData("pointMapped", pMapped);
        }
    }
 
開發者ID:StarMade,項目名稱:SMEditClassic,代碼行數:40,代碼來源:NodeDrawHandler.java

示例3: projectToScreen

import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
private void projectToScreen(JGLNode obj) {
        if ((obj.getLowBounds() == null) && (obj.getHighBounds() == null) && (obj.getData("pointMap") == null)) {
            return;
        }
        FloatBuffer modelView = BufferUtils.createFloatBuffer(16);
        FloatBuffer projection = BufferUtils.createFloatBuffer(16);
        FloatBuffer dviewport = BufferUtils.createFloatBuffer(16);

        GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelView);
        GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projection);
        GL11.glGetFloat(GL11.GL_VIEWPORT, dviewport);

        IntBuffer viewport = BufferLogic.create((int) dviewport.get(0), (int) dviewport.get(1), (int) dviewport.get(2), (int) dviewport.get(3));
        if ((obj.getLowBounds() != null) && (obj.getHighBounds() != null)) {
            FloatBuffer low = BufferLogic.createFloatBuffer(3);
            GLU.gluProject(obj.getLowBounds().x, obj.getLowBounds().y, obj.getLowBounds().z, modelView, projection, viewport, low);
            FloatBuffer high = BufferLogic.createFloatBuffer(3);
            GLU.gluProject(obj.getHighBounds().x, obj.getHighBounds().y, obj.getHighBounds().z, modelView, projection, viewport, high);
            FloatBuffer mid = BufferLogic.createFloatBuffer(3);
            GLU.gluProject(0, 0, 0, modelView, projection, viewport, mid);
            obj.setScreen(new Point3f(mid.get(0), mid.get(1), mid.get(2)));
            obj.setScreenLowBounds(new Point3f(Math.min(low.get(0), high.get(0)), Math.min(low.get(1), high.get(1)), Math.min(low.get(2), high.get(2))));
            obj.setScreenHighBounds(new Point3f(Math.max(low.get(0), high.get(0)), Math.max(low.get(1), high.get(1)), Math.max(low.get(2), high.get(2))));
//        System.out.println("modelView="+DoubleUtils.toString(modelView));
//        System.out.println("projection="+DoubleUtils.toString(projection));
//        System.out.println("dviewport="+DoubleUtils.toString(dviewport));
//        System.out.println("Screen="+DoubleUtils.toString(mid));
        }
        Point3f pointMap = (Point3f) obj.getData("pointMap");
        if (pointMap != null) {
            FloatBuffer pointMapped = BufferLogic.createFloatBuffer(3);
            GLU.gluUnProject(pointMap.x, pointMap.y, pointMap.z, modelView, projection, viewport, pointMapped);
            Point3f pMapped = new Point3f(pointMapped.get(0), pointMapped.get(1), pointMapped.get(2));
            obj.setData("pointMap", null);
            obj.setData("pointMapped", pMapped);
        }
    }
 
開發者ID:StarMade,項目名稱:SMEdit,代碼行數:38,代碼來源:NodeDrawHandler.java

示例4: project

import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
public Vec3d project(float objX, float objY, float objZ) {
	GLU.gluProject(objX, objY, objZ, modelview, projection, viewport, winCoords);

	float winX = winCoords.get(0);
	float winY = winCoords.get(1);
	float winZ = winCoords.get(2);

	return new Vec3d(winX, winY, winZ);
}
 
開發者ID:OpenMods,項目名稱:OpenModsLib,代碼行數:10,代碼來源:ProjectionHelper.java

示例5: project2D

import org.lwjgl.util.glu.GLU; //導入方法依賴的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

示例6: project2D

import org.lwjgl.util.glu.GLU; //導入方法依賴的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

示例7: toScreen

import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
/**
 * Converts the specified X, Y, and Z position to
 * the 2D projected position. The returned result
 * is a Vec3 containing the X and Y position, to
 * represent the position on-screen, and a Z position
 * that can be used to indicate whether or not the
 * projected position
 *
 * @return Screen projected coordinates
 */
public static Vec3 toScreen(double x, double y, double z) {
    FloatBuffer screenCoords = BufferUtils.createFloatBuffer(3);
    boolean result = GLU.gluProject((float) x, (float) y, (float) z, MODELVIEW, PROJECTION, VIEWPORT, screenCoords);
    if (result) {
        return new Vec3(screenCoords.get(0), Display.getHeight() - screenCoords.get(1), screenCoords.get(2));
    }
    return null;
}
 
開發者ID:ImpactDevelopment,項目名稱:ClientAPI,代碼行數:19,代碼來源:GLUtils.java


注:本文中的org.lwjgl.util.glu.GLU.gluProject方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。