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


Java GLU.gluUnProject方法代碼示例

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


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

示例1: getModelCoordinates

import javax.media.opengl.glu.GLU; //導入方法依賴的package包/類
public static Vector3d getModelCoordinates(GL2 gl, ScreenCoordinates screenCoordinates) {
    double modelView[] = new double[16];
    double projection[] = new double[16];
    int viewport[] = new int[4];
    double wcoord[] = new double[4];

    gl.glGetDoublev(GL2.GL_MODELVIEW_MATRIX, modelView, 0);
    gl.glGetDoublev(GL2.GL_PROJECTION_MATRIX, projection, 0 );
    gl.glGetIntegerv(GL2.GL_VIEWPORT, viewport, 0 );

    GLU glu = new GLU();
    glu.gluUnProject(screenCoordinates.getPoint().getX(),  screenCoordinates.getPoint().getY(), screenCoordinates.getDepth(),
            modelView, 0,
            projection, 0,
            viewport, 0,
            wcoord, 0);

    return new Vector3d(wcoord[0], wcoord[1], wcoord[2]);
}
 
開發者ID:momega,項目名稱:spacesimulator,代碼行數:20,代碼來源:GLUtils.java

示例2: getWorldCoordinates

import javax.media.opengl.glu.GLU; //導入方法依賴的package包/類
public static Location getWorldCoordinates(GL gl, GLU glu, Location screen, Location store) {
    if (store == null) {
        store = new Location(0,0,0);
    }

    // Modelview matrix
    DoubleBuffer mvBuffer = DoubleBuffer.allocate(16);
    gl.glGetDoublev(GL.GL_MODELVIEW_MATRIX, mvBuffer);
    // Projection_matrix
    DoubleBuffer prBuffer = DoubleBuffer.allocate(16);
    gl.glGetDoublev(GL.GL_PROJECTION_MATRIX, prBuffer);
    // Viewport matrix
    IntBuffer vpBuffer = IntBuffer.allocate(16); // 4 is necessary
    gl.glGetIntegerv(GL.GL_VIEWPORT, vpBuffer);

    // 3d coordinates
    DoubleBuffer result = DoubleBuffer.allocate(3);
    glu.gluUnProject(screen.x,
            screen.y,
            screen.z,
            mvBuffer,
            prBuffer,
            vpBuffer,
            result);

    store = new Location(result.get(0), result.get(1), result.get(2));

    return store;
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:30,代碼來源:GLTools.java

示例3: screenToWorld

import javax.media.opengl.glu.GLU; //導入方法依賴的package包/類
public Point2D screenToWorld(Point2D mouse) {
	double[] wcoord = new double[4];
	double x = mouse.getX();
	double y = viewport.get(3) - mouse.getY();
	GLU glu = new GLU();

	glu.gluUnProject(x, y, 0, modelview.array(), 0, projection.array(), 0,
			viewport.array(), 0, wcoord, 0);

	Point2D p = new Point2D.Float();
	p.setLocation(wcoord[0], wcoord[1]);
	return p;
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:14,代碼來源:NetworkRenderer.java

示例4: getOGLPos

import javax.media.opengl.glu.GLU; //導入方法依賴的package包/類
public static double[] getOGLPos(GL2 gl, GLU glu, int x, int y) {
        int[] viewport = new int[4];
        double[] modelview  = {1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1};
        double[] projection = {1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1};
        double winX, winY;
        float[] winZ = new float[1];
        Buffer winZBuf = FloatBuffer.wrap(winZ);
     
        gl.glGetDoublev( GL2.GL_MODELVIEW_MATRIX, modelview, 0 ); // Kevin Watts stackoverflow said use identity.  Not likely.
        gl.glGetDoublev( GL2.GL_PROJECTION_MATRIX, projection, 0 );
        gl.glGetIntegerv( GL2.GL_VIEWPORT, viewport, 0 );
     
        winX = (double)x;
        winY = (double)viewport[3] - (double)y;
        gl.glReadPixels( x, (int)winY, 1, 1, GL2.GL_DEPTH_COMPONENT, GL2.GL_FLOAT, winZBuf );
     
        double[] objPos = new double[3];
        glu.gluUnProject(winX, winY, winZ[0], modelview, 0, projection, 0, viewport, 0, objPos, 0);
        
        // Draw sphere at objPos
//        gl.glPushMatrix();
//            gl.glTranslated(objPos[0], objPos[1], objPos[2]);
//            gl.glColor3f(1,0,0);
//            GLUquadric quadric = glu.gluNewQuadric();
//            glu.gluQuadricDrawStyle(quadric, GLU.GLU_LINE);
//            glu.gluQuadricNormals  (quadric, GLU.GLU_NONE);
//            glu.gluSphere(quadric, 1.0, 10, 10);
//        gl.glPopMatrix();
     
        return objPos;
    }
 
開發者ID:ProfAmesBC,項目名稱:Game2013,代碼行數:32,代碼來源:ReadZBuffer.java


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