本文整理汇总了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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}