本文整理匯總了Java中org.lwjgl.util.glu.GLU.gluUnProject方法的典型用法代碼示例。如果您正苦於以下問題:Java GLU.gluUnProject方法的具體用法?Java GLU.gluUnProject怎麽用?Java GLU.gluUnProject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.lwjgl.util.glu.GLU
的用法示例。
在下文中一共展示了GLU.gluUnProject方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateRenderInfo
import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
/**
* Updates the current render info and camera location based on entity look angles and 1st/3rd person view mode
*/
public static void updateRenderInfo(EntityPlayer entityplayerIn, boolean p_74583_1_)
{
GlStateManager.getFloat(2982, MODELVIEW);
GlStateManager.getFloat(2983, PROJECTION);
GL11.glGetInteger(GL11.GL_VIEWPORT, VIEWPORT);
float f = (float)((VIEWPORT.get(0) + VIEWPORT.get(2)) / 2);
float f1 = (float)((VIEWPORT.get(1) + VIEWPORT.get(3)) / 2);
GLU.gluUnProject(f, f1, 0.0F, MODELVIEW, PROJECTION, VIEWPORT, OBJECTCOORDS);
position = new Vec3((double)OBJECTCOORDS.get(0), (double)OBJECTCOORDS.get(1), (double)OBJECTCOORDS.get(2));
int i = p_74583_1_ ? 1 : 0;
float f2 = entityplayerIn.rotationPitch;
float f3 = entityplayerIn.rotationYaw;
rotationX = MathHelper.cos(f3 * (float)Math.PI / 180.0F) * (float)(1 - i * 2);
rotationZ = MathHelper.sin(f3 * (float)Math.PI / 180.0F) * (float)(1 - i * 2);
rotationYZ = -rotationZ * MathHelper.sin(f2 * (float)Math.PI / 180.0F) * (float)(1 - i * 2);
rotationXY = rotationX * MathHelper.sin(f2 * (float)Math.PI / 180.0F) * (float)(1 - i * 2);
rotationXZ = MathHelper.cos(f2 * (float)Math.PI / 180.0F);
}
示例2: updateRenderInfo
import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
/**
* Updates the current render info and camera location based on entity look angles and 1st/3rd person view mode
*/
public static void updateRenderInfo(EntityPlayer entityplayerIn, boolean p_74583_1_)
{
GlStateManager.getFloat(2982, MODELVIEW);
GlStateManager.getFloat(2983, PROJECTION);
GlStateManager.glGetInteger(2978, VIEWPORT);
float f = (float)((VIEWPORT.get(0) + VIEWPORT.get(2)) / 2);
float f1 = (float)((VIEWPORT.get(1) + VIEWPORT.get(3)) / 2);
GLU.gluUnProject(f, f1, 0.0F, MODELVIEW, PROJECTION, VIEWPORT, OBJECTCOORDS);
position = new Vec3d((double)OBJECTCOORDS.get(0), (double)OBJECTCOORDS.get(1), (double)OBJECTCOORDS.get(2));
int i = p_74583_1_ ? 1 : 0;
float f2 = entityplayerIn.rotationPitch;
float f3 = entityplayerIn.rotationYaw;
rotationX = MathHelper.cos(f3 * 0.017453292F) * (float)(1 - i * 2);
rotationZ = MathHelper.sin(f3 * 0.017453292F) * (float)(1 - i * 2);
rotationYZ = -rotationZ * MathHelper.sin(f2 * 0.017453292F) * (float)(1 - i * 2);
rotationXY = rotationX * MathHelper.sin(f2 * 0.017453292F) * (float)(1 - i * 2);
rotationXZ = MathHelper.cos(f2 * 0.017453292F);
}
示例3: updateRenderInfo
import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
/**
* Updates the current render info and camera location based on entity look angles and 1st/3rd person view mode
*/
public static void updateRenderInfo(EntityPlayer par0EntityPlayer, boolean par1)
{
GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelview);
GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projection);
GL11.glGetInteger(GL11.GL_VIEWPORT, viewport);
float var2 = (float)((viewport.get(0) + viewport.get(2)) / 2);
float var3 = (float)((viewport.get(1) + viewport.get(3)) / 2);
GLU.gluUnProject(var2, var3, 0.0F, modelview, projection, viewport, objectCoords);
objectX = objectCoords.get(0);
objectY = objectCoords.get(1);
objectZ = objectCoords.get(2);
int var4 = par1 ? 1 : 0;
float var5 = par0EntityPlayer.rotationPitch;
float var6 = par0EntityPlayer.rotationYaw;
rotationX = MathHelper.cos(var6 * (float)Math.PI / 180.0F) * (float)(1 - var4 * 2);
rotationZ = MathHelper.sin(var6 * (float)Math.PI / 180.0F) * (float)(1 - var4 * 2);
rotationYZ = -rotationZ * MathHelper.sin(var5 * (float)Math.PI / 180.0F) * (float)(1 - var4 * 2);
rotationXY = rotationX * MathHelper.sin(var5 * (float)Math.PI / 180.0F) * (float)(1 - var4 * 2);
rotationXZ = MathHelper.cos(var5 * (float)Math.PI / 180.0F);
}
示例4: doEye
import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
private void doEye()
{
int mouseX = Mouse.getX();
int mouseY = Mouse.getY();
FloatBuffer modelview = BufferUtils.createFloatBuffer(16);
GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelview);
FloatBuffer projection = BufferUtils.createFloatBuffer(16);
GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projection);
IntBuffer viewport = BufferUtils.createIntBuffer(16);
GL11.glGetInteger(GL11.GL_VIEWPORT, viewport);
float winX = mouseX;
float winY = viewport.get(3) - mouseY;
FloatBuffer winZBuffer = BufferUtils.createFloatBuffer(1);
GL11.glReadPixels(mouseX, mouseY, 1, 1, GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, winZBuffer);
float winZ = winZBuffer.get(0);
FloatBuffer pos = BufferUtils.createFloatBuffer(3);
GLU.gluUnProject(winX, winY, winZ, modelview, projection, viewport, pos);
mEyeRay = new Point3f(pos.get(0), pos.get(1), pos.get(2));
}
示例5: updateRenderInfo
import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
public static void updateRenderInfo(EntityPlayer p_74583_0_, boolean p_74583_1_)
{
GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelview);
GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projection);
GL11.glGetInteger(GL11.GL_VIEWPORT, viewport);
float f = (float)((viewport.get(0) + viewport.get(2)) / 2);
float f1 = (float)((viewport.get(1) + viewport.get(3)) / 2);
GLU.gluUnProject(f, f1, 0.0F, modelview, projection, viewport, objectCoords);
objectX = objectCoords.get(0);
objectY = objectCoords.get(1);
objectZ = objectCoords.get(2);
int i = p_74583_1_ ? 1 : 0;
float f2 = p_74583_0_.rotationPitch;
float f3 = p_74583_0_.rotationYaw;
rotationX = MathHelper.cos(f3 * (float)Math.PI / 180.0F) * (float)(1 - i * 2);
rotationZ = MathHelper.sin(f3 * (float)Math.PI / 180.0F) * (float)(1 - i * 2);
rotationYZ = -rotationZ * MathHelper.sin(f2 * (float)Math.PI / 180.0F) * (float)(1 - i * 2);
rotationXY = rotationX * MathHelper.sin(f2 * (float)Math.PI / 180.0F) * (float)(1 - i * 2);
rotationXZ = MathHelper.cos(f2 * (float)Math.PI / 180.0F);
}
示例6: func_74583_a
import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
public static void func_74583_a(EntityPlayer p_74583_0_, boolean p_74583_1_) {
GL11.glGetFloat(2982, field_74594_j);
GL11.glGetFloat(2983, field_74595_k);
GL11.glGetInteger(2978, field_74597_i);
float var2 = (float)((field_74597_i.get(0) + field_74597_i.get(2)) / 2);
float var3 = (float)((field_74597_i.get(1) + field_74597_i.get(3)) / 2);
GLU.gluUnProject(var2, var3, 0.0F, field_74594_j, field_74595_k, field_74597_i, field_74593_l);
field_74592_a = field_74593_l.get(0);
field_74590_b = field_74593_l.get(1);
field_74591_c = field_74593_l.get(2);
int var4 = p_74583_1_?1:0;
float var5 = p_74583_0_.field_70125_A;
float var6 = p_74583_0_.field_70177_z;
field_74588_d = MathHelper.func_76134_b(var6 * 3.1415927F / 180.0F) * (float)(1 - var4 * 2);
field_74586_f = MathHelper.func_76126_a(var6 * 3.1415927F / 180.0F) * (float)(1 - var4 * 2);
field_74587_g = -field_74586_f * MathHelper.func_76126_a(var5 * 3.1415927F / 180.0F) * (float)(1 - var4 * 2);
field_74596_h = field_74588_d * MathHelper.func_76126_a(var5 * 3.1415927F / 180.0F) * (float)(1 - var4 * 2);
field_74589_e = MathHelper.func_76134_b(var5 * 3.1415927F / 180.0F);
}
示例7: updateRenderInfo
import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
/**
* Updates the current render info and camera location based on entity look angles and 1st/3rd person view mode
*/
public static void updateRenderInfo(EntityPlayer par0EntityPlayer, boolean par1)
{
GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelview);
GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projection);
GL11.glGetInteger(GL11.GL_VIEWPORT, viewport);
float f = (float)((viewport.get(0) + viewport.get(2)) / 2);
float f1 = (float)((viewport.get(1) + viewport.get(3)) / 2);
GLU.gluUnProject(f, f1, 0.0F, modelview, projection, viewport, objectCoords);
objectX = objectCoords.get(0);
objectY = objectCoords.get(1);
objectZ = objectCoords.get(2);
int i = par1 ? 1 : 0;
float f2 = par0EntityPlayer.rotationPitch;
float f3 = par0EntityPlayer.rotationYaw;
rotationX = MathHelper.cos(f3 * (float)Math.PI / 180.0F) * (float)(1 - i * 2);
rotationZ = MathHelper.sin(f3 * (float)Math.PI / 180.0F) * (float)(1 - i * 2);
rotationYZ = -rotationZ * MathHelper.sin(f2 * (float)Math.PI / 180.0F) * (float)(1 - i * 2);
rotationXY = rotationX * MathHelper.sin(f2 * (float)Math.PI / 180.0F) * (float)(1 - i * 2);
rotationXZ = MathHelper.cos(f2 * (float)Math.PI / 180.0F);
}
示例8: doEye
import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
private void doEye() {
int mouseX = Mouse.getX();
int mouseY = Mouse.getY();
FloatBuffer modelview = BufferUtils.createFloatBuffer(16);
GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelview);
FloatBuffer projection = BufferUtils.createFloatBuffer(16);
GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projection);
IntBuffer viewport = BufferUtils.createIntBuffer(16);
GL11.glGetInteger(GL11.GL_VIEWPORT, viewport);
float winX = mouseX;
float winY = viewport.get(3) - mouseY;
FloatBuffer winZBuffer = BufferUtils.createFloatBuffer(1);
GL11.glReadPixels(mouseX, mouseY, 1, 1, GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, winZBuffer);
float winZ = winZBuffer.get(0);
FloatBuffer pos = BufferUtils.createFloatBuffer(3);
GLU.gluUnProject(winX, winY, winZ, modelview, projection, viewport, pos);
mEyeRay = new Point3f(pos.get(0), pos.get(1), pos.get(2));
}
示例9: toWorld
import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
/**
* Converts the specified X, Y, and Z screen positions
* to a position in the world, that through some fancy
* maths (raytracing) can be used get the actual block
* position of the conversion
*
* @return World projected coordinates
*/
public static Vec3 toWorld(double x, double y, double z) {
FloatBuffer screenCoords = BufferUtils.createFloatBuffer(3);
boolean result = GLU.gluUnProject((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;
}
示例10: getRayTrace
import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
public static RayTrace getRayTrace()
{
FloatBuffer model = BufferUtils.createFloatBuffer(16);
FloatBuffer projection = BufferUtils.createFloatBuffer(16);
IntBuffer viewport = BufferUtils.createIntBuffer(16);
GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, model);
GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projection);
GL11.glGetInteger(GL11.GL_VIEWPORT, viewport);
FloatBuffer posNearBuffer = BufferUtils.createFloatBuffer(3);
FloatBuffer posFarBuffer = BufferUtils.createFloatBuffer(3);
GLU.gluUnProject(Mouse.getX(), Mouse.getY(), 0.0F, model, projection, viewport, posNearBuffer);
GLU.gluUnProject(Mouse.getX(), Mouse.getY(), 1.0F, model, projection, viewport, posFarBuffer);
float[] posNear = new float[3];
float[] posFar = new float[3];
for(int i = 0; i < 3; i++)
{
posNear[i] = posNearBuffer.get(i);
posFar[i] = posFarBuffer.get(i);
}
Vec3d v = new Vec3d(posNear[0], posNear[1], posNear[2]);
Vec3d w = new Vec3d(posFar[0], posFar[1], posFar[2]);
return new RayTrace(v,w);
// entityModel.clearHighlights();
// PartObj p = entityModel.testRay(new RayTrace(v,w));
// if(p != null)
// hoveredPart = p.getName();
// else
// hoveredPart = null;
}
示例11: unproject
import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
public Vec3 unproject(float winX, float winY, float winZ) {
GLU.gluUnProject(winX, winY, winZ, modelview, projection, viewport, objectCoords);
float objectX = objectCoords.get(0);
float objectY = objectCoords.get(1);
float objectZ = objectCoords.get(2);
return Vec3.createVectorHelper(objectX, objectY, objectZ);
}
示例12: 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);
}
}
示例13: renderLast
import org.lwjgl.util.glu.GLU; //導入方法依賴的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
}
示例14: 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);
}
}
示例15: getRayFromMouse
import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
public Ray getRayFromMouse() {
int mousex = 0, mousey = 0;
mousex = Mouse.getX();
mousey = Mouse.getY();
final FloatBuffer projection = BufferUtils.createFloatBuffer(16);
final FloatBuffer modelview = BufferUtils.createFloatBuffer(16);
final IntBuffer viewport = BufferUtils.createIntBuffer(16);
final FloatBuffer position = BufferUtils.createFloatBuffer(3);
GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelview);
GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projection);
GL11.glGetInteger(GL11.GL_VIEWPORT, viewport);
GLU.gluUnProject(mousex, mousey, 1, modelview, projection, viewport, position);
final Vector3f near = new Vector3f(position.get(0), position.get(1), position.get(2));
// reuse buffers
// near = eyeOut;
projection.rewind();
modelview.rewind();
viewport.rewind();
position.rewind();
GLU.gluUnProject(mousex, mousey, 0, modelview, projection, viewport, position);
final Vector3f far = new Vector3f(position.get(0), position.get(1), position.get(2));
Vector3f.sub(near, far, this.vView);
this.vView.normalise();
return new Ray(this.m_vPosition, this.vView);
}