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


Java GLU.gluProject方法代碼示例

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


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

示例1: getProjectionCoordinates

import javax.media.opengl.glu.GLU; //導入方法依賴的package包/類
/**
 * Gets the projection coordinates of the position in model-view based on the camera
 * @param gl open gl context
 * @param position any position in 3D
 * @param camera the camera
 * @return array of the coordinates, 0th coordinate is x, 1st coordinate is y, Result can be null if the point is behind
 * the camera
 */
public static ScreenCoordinates getProjectionCoordinates(GL2 gl, Vector3d position, Camera camera) {
    Vector3d viewVector = camera.getOppositeOrientation().getN();
    Vector3d diffVector = position.subtract(camera.getPosition());

    if (viewVector.dot(diffVector) < 0) {  // object is in front of the camera
        double modelView[] = new double[16];
        double projection[] = new double[16];
        int viewport[] = new int[4];
        gl.glGetDoublev(GL2.GL_MODELVIEW_MATRIX, modelView, 0);
        gl.glGetDoublev(GL2.GL_PROJECTION_MATRIX, projection, 0 );
        gl.glGetIntegerv(GL2.GL_VIEWPORT, viewport, 0 );

        double[] my2DPoint = new double[4];
        GLU glu = new GLU();
        glu.gluProject(position.getX(), position.getY(), position.getZ(),
                modelView, 0, projection, 0, viewport, 0, my2DPoint, 0);

        return new ScreenCoordinates(my2DPoint);
    }

    return null;
}
 
開發者ID:momega,項目名稱:spacesimulator,代碼行數:31,代碼來源:GLUtils.java

示例2: getScreenCoordinates

import javax.media.opengl.glu.GLU; //導入方法依賴的package包/類
public static Location getScreenCoordinates(GL gl, GLU glu, Location worldPosition, 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);
    gl.glGetIntegerv(GL.GL_VIEWPORT, vpBuffer);

    DoubleBuffer result = DoubleBuffer.allocate(3);

    glu.gluProject(worldPosition.x,
            worldPosition.y,
            worldPosition.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: get2DPoint

import javax.media.opengl.glu.GLU; //導入方法依賴的package包/類
private Point get2DPoint(Vector3f coords, int[] viewport,double[] modelViewMatrix, double[] projectionMatrix, GLU glu) {
    double coordsTransformed[] = new double[3];
    glu.gluProject(
            coords.getX(),
            coords.getY(),
            coords.getZ(),
            modelViewMatrix, 0,
            projectionMatrix, 0,
            viewport, 0,
            coordsTransformed, 0);
    coordsTransformed[1] = viewport[3] - coordsTransformed[1] - 1;
    return new Point((int) coordsTransformed[0], (int) coordsTransformed[1]);
}
 
開發者ID:Fidentis,項目名稱:Analyst,代碼行數:14,代碼來源:Manipulator.java


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