当前位置: 首页>>代码示例>>Java>>正文


Java GLU.gluUnProject方法代码示例

本文整理汇总了Java中android.opengl.GLU.gluUnProject方法的典型用法代码示例。如果您正苦于以下问题:Java GLU.gluUnProject方法的具体用法?Java GLU.gluUnProject怎么用?Java GLU.gluUnProject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.opengl.GLU的用法示例。


在下文中一共展示了GLU.gluUnProject方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Ray

import android.opengl.GLU; //导入方法依赖的package包/类
public Ray(MatrixGrabber matrixGrabber,int[] viewPort,float xTouch, float yTouch){
    float[] temp = new float[4];

    float winy =(float)viewPort[3] - yTouch;
    int result = GLU.gluUnProject(xTouch, winy, 1f, matrixGrabber.mModelView, 0, matrixGrabber.mProjection, 0, viewPort, 0, temp, 0);
    if(result == GL10.GL_TRUE){
        farCoords[0] = temp[0] / temp[3] * Cube3.one;
        farCoords[1] = temp[1] / temp[3] * Cube3.one;
        farCoords[2] = temp[2] / temp[3] * Cube3.one;
    }
    result = GLU.gluUnProject(xTouch, winy, 0, matrixGrabber.mModelView, 0, matrixGrabber.mProjection, 0, viewPort, 0, temp, 0);
    if(result == GL10.GL_TRUE){
        nearCoords[0] = temp[0] / temp[3] * Cube3.one;
        nearCoords[1] = temp[1] / temp[3] * Cube3.one;
        nearCoords[2] = temp[2] / temp[3] * Cube3.one;
    }
}
 
开发者ID:x6uderek,项目名称:rubik,代码行数:18,代码来源:Ray.java

示例2: projectTouchToWorld

import android.opengl.GLU; //导入方法依赖的package包/类
public static Vector3 projectTouchToWorld(int width, int height, float[] modelView, float[] projection, float x, float y) {
       int[] view = new int[] {0, 0, width, height};

       float[] touch_position = new float[4];
       int r = GLU.gluUnProject(x, view[3] - y, 1f,
               modelView, 0,
               projection, 0,
               view, 0,
               touch_position, 0);

       touch_position[0] /= touch_position[3];
       touch_position[1] /= touch_position[3];
       touch_position[2] /= touch_position[3];
       touch_position[3] /= touch_position[3];

       Vector3 rv = new Vector3(touch_position[0], touch_position[1], touch_position[2]);
       rv.normalize();
       return rv;
}
 
开发者ID:mdellavo,项目名称:plasma,代码行数:20,代码来源:GLHelper.java

示例3: getViewRay

import android.opengl.GLU; //导入方法依赖的package包/类
/**
 * Get a view {@link com.beyondar.android.util.math.geom.Ray Ray} for the
 * screen position (x,y). Use this to object to check if there are any
 * {@link com.beyondar.android.world.GeoObject GeoObject} that collide.
 * 
 * @param x
 * @param y
 * @param ray
 */
public void getViewRay(float x, float y, Ray ray) {

	// far eye point
	float[] eye = mFloat4ArrayPool.poll();
	if (eye == null) {
		eye = new float[4];
	} else {
		eye[0] = eye[1] = eye[2] = eye[3] = 0;
	}
	GLU.gluUnProject(x, mHeight - y, 0.9f, mMatrixGrabber.mModelView, 0, mMatrixGrabber.mProjection, 0,
			viewport, 0, eye, 0);

	// fix
	if (eye[3] != 0) {
		eye[0] = eye[0] / eye[3];
		eye[1] = eye[1] / eye[3];
		eye[2] = eye[2] / eye[3];
	}

	// ray vector
	ray.setVector((eye[0] - mCameraPosition.x), (eye[1] - mCameraPosition.y),
			(eye[2] - mCameraPosition.z));
	mFloat4ArrayPool.add(eye);
}
 
开发者ID:BeyondAR,项目名称:beyondar,代码行数:34,代码来源:ARRenderer.java

示例4: pointToModelSpace

import android.opengl.GLU; //导入方法依赖的package包/类
private void pointToModelSpace(float x, float y, float[] from, float[] direction) {
    float[] mtxMV = new float[16];
    Matrix.multiplyMM(mtxMV, 0, renderer.mtxView, 0, cube.mtxModel, 0);
    int[] view = {0, 0, getWidth(), getHeight()};
    float[] modelSpaceFrom = new float[4], modelSpaceTo = new float[4];
    GLU.gluUnProject(x, getHeight() - y, 1.0f, mtxMV, 0,
            renderer.mtxProj, 0, view, 0, modelSpaceFrom, 0);
    GLU.gluUnProject(x, getHeight() - y, 0.0f, mtxMV, 0,
            renderer.mtxProj, 0, view, 0, modelSpaceTo, 0);
    for (int i = 0; i < 3; ++i) {
        from[i] = modelSpaceFrom[i] / modelSpaceFrom[3];
        direction[i] = modelSpaceTo[i] / modelSpaceTo[3] - from[i];
    }

}
 
开发者ID:wwylele,项目名称:WwyleleCube,代码行数:16,代码来源:CubeView.java

示例5: Ray

import android.opengl.GLU; //导入方法依赖的package包/类
public Ray(GL10 gl, int width, int height, float xTouch, float yTouch) {
        MatrixGrabber matrixGrabber = new MatrixGrabber();
        matrixGrabber.getCurrentState(gl);

        int[] viewport = {0, 0, width, height};

        float[] nearCoOrds = new float[3];
        float[] farCoOrds = new float[3];
        float[] temp = new float[4];
        float[] temp2 = new float[4];
        // get the near and far ords for the click

        float winx = xTouch, winy = (float) viewport[3] - yTouch;
 
//        Log.d(TAG, "modelView is =" + Arrays.toString(matrixGrabber.mModelView));
//        Log.d(TAG, "projection view is =" + Arrays.toString( matrixGrabber.mProjection ));

        int result = GLU.gluUnProject(winx, winy, 1.0f, matrixGrabber.mModelView, 0, matrixGrabber.mProjection, 0, viewport, 0, temp, 0);

        Matrix.multiplyMV(temp2, 0, matrixGrabber.mModelView, 0, temp, 0);
        if (result == GL10.GL_TRUE) {
            nearCoOrds[0] = temp2[0] / temp2[3];
            nearCoOrds[1] = temp2[1] / temp2[3];
            nearCoOrds[2] = temp2[2] / temp2[3];

        }

        result = GLU.gluUnProject(winx, winy, 0, matrixGrabber.mModelView, 0, matrixGrabber.mProjection, 0, viewport, 0, temp, 0);
        Matrix.multiplyMV(temp2, 0, matrixGrabber.mModelView, 0, temp, 0);
        if (result == GL10.GL_TRUE) {
            farCoOrds[0] = temp2[0] / temp2[3];
            farCoOrds[1] = temp2[1] / temp2[3];
            farCoOrds[2] = temp2[2] / temp2[3];
        }
        this.P0 = farCoOrds;
        this.P1 = nearCoOrds;
    }
 
开发者ID:ykrapiva,项目名称:android-eventmap-library,代码行数:38,代码来源:Ray.java

示例6: onTouchEvent

import android.opengl.GLU; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent e) {
	switch (e.getAction()) {
	case MotionEvent.ACTION_MOVE:
		final float screenX = e.getX();
		final float screenY = mScreenHeight - e.getY();

		final int[] viewport = {
				0, 0, mScreenWidth, mScreenHeight
		};

		float[] resultWorldPos = {
				0.0f, 0.0f, 0.0f, 0.0f
		};

		GLU.gluUnProject(screenX, screenY, 0, mUnprojectViewMatrix, 0, mUnprojectProjMatrix, 0,
				viewport, 0, resultWorldPos, 0);
		resultWorldPos[0] /= resultWorldPos[3];
		resultWorldPos[1] /= resultWorldPos[3];
		resultWorldPos[2] /= resultWorldPos[3];
		resultWorldPos[3] = 1.0f;

		mRenderer.updatePaddlePosition(resultWorldPos[0], resultWorldPos[1]);
		break;
	
	case MotionEvent.ACTION_DOWN:
		// Only start the game when the user clicks on the screen
		State.setGamePaused(false);
		break;
	}
	return true;
}
 
开发者ID:m45t3r,项目名称:retrobreaker,代码行数:33,代码来源:TouchSurfaceView.java

示例7: setScreenCoordinates

import android.opengl.GLU; //导入方法依赖的package包/类
/**
 * Maps screen coordinates to object coordinates
 *
 * @param x
 * @param y
 * @param viewportWidth
 * @param viewportHeight
 * @param eyeZ
 */
public void setScreenCoordinates(float x, float y, int viewportWidth, int viewportHeight, float eyeZ) {
    float[] r1 = new float[16];
    int[] viewport = new int[]{0, 0, viewportWidth, viewportHeight};
    float[] modelMatrix = new float[16];
    Matrix.setIdentityM(modelMatrix, 0);

    GLU.gluUnProject(x, viewportHeight - y, 0.0f, modelMatrix, 0, mProjMatrix, 0, viewport, 0, r1, 0);
    setPosition(r1[0] * eyeZ, r1[1] * -eyeZ, 0);
}
 
开发者ID:BitMastro,项目名称:PortalLW,代码行数:19,代码来源:BaseObject3D.java

示例8: GetWorldCoords

import android.opengl.GLU; //导入方法依赖的package包/类
/**
 * Calculates the transform from screen coordinate
 * system to world coordinate system coordinates
 * for a specific point, given a camera position.
 *
 * @param touch Coord point of screen touch, the
 *              actual position on physical screen (ej: 160, 240)
 * @return position in WCS.
 */
public Coord GetWorldCoords(GL10 gl, Coord touch, float z) {

    GL11 gl11 = (GL11) gl;
    GL11ExtensionPack gl11ext = (GL11ExtensionPack) gl;
    int[] viewport = new int[4];
    float[] modelview = new float[16];
    float[] projection = new float[16];
    float winX, winY;
    FloatBuffer winZ = FloatBuffer.allocate(4);

    gl11.glGetFloatv(gl11.GL_MODELVIEW_MATRIX, modelview, 0);       // Retrieve The Modelview Matrix
    gl11.glGetFloatv(gl11.GL_PROJECTION_MATRIX, projection, 0);
    gl11.glGetIntegerv(gl11.GL_VIEWPORT, viewport, 0);

    winX = touch.X;
    winY = (float) viewport[3] - touch.Y;
    gl11.glReadPixels((int) touch.X, (int) winY, 1, 1, gl11ext.GL_DEPTH_COMPONENT, gl11.GL_FLOAT, winZ);


    float[] output = new float[4];
    GLU.gluUnProject(winX, winY, winZ.get(), modelview, 0, projection, 0, viewport, 0, output, 0);
    //Log.w("WorldCoord", output[0] + " , " + output[1]);
    return new Coord(output[0] * Math.abs(transZ), output[1] * Math.abs(transZ));


}
 
开发者ID:PhilipRead,项目名称:Codename-Slate,代码行数:36,代码来源:MyGLRenderer.java

示例9: unproject

import android.opengl.GLU; //导入方法依赖的package包/类
/**
 * Get the corresponding near and far vertex for the specified window coordinates
 *
 * @param mRenderer
 * @param rx
 * @param ry
 * @param rz
 * @return the corresponding near and far vertex for the specified window coordinates
 */
public static float[] unproject(ModelRenderer mRenderer, float rx, float ry, float rz) {
    float[] xyzw = {0, 0, 0, 0};
    ry = (float) mRenderer.getHeight() - ry;
    int[] viewport = {0, 0, mRenderer.getWidth(), mRenderer.getHeight()};
    GLU.gluUnProject(rx, ry, rz, mRenderer.getModelViewMatrix(), 0, mRenderer.getModelProjectionMatrix(), 0,
            viewport, 0, xyzw, 0);
    xyzw[0] /= xyzw[3];
    xyzw[1] /= xyzw[3];
    xyzw[2] /= xyzw[3];
    xyzw[3] = 1;
    return xyzw;
}
 
开发者ID:andresoviedo,项目名称:android-3D-model-viewer,代码行数:22,代码来源:CollisionDetection.java

示例10: setScreenCoordinates

import android.opengl.GLU; //导入方法依赖的package包/类
/**
 * Maps screen coordinates to object coordinates
 * 
 * @param x
 * @param y
 * @param viewportWidth
 * @param viewportHeight
 * @param eyeZ
 */
public void setScreenCoordinates(float x, float y, int viewportWidth, int viewportHeight, float eyeZ) {
	float[] r1 = new float[16];
	int[] viewport = new int[] { 0, 0, viewportWidth, viewportHeight };
	float[] modelMatrix = new float[16];
	Matrix.setIdentityM(modelMatrix, 0);

	GLU.gluUnProject(x, viewportHeight - y, 0.0f, modelMatrix, 0, mProjMatrix, 0, viewport, 0, r1, 0);
	setPosition(r1[0] * eyeZ, r1[1] * -eyeZ, 0);
}
 
开发者ID:OpsLabJPL,项目名称:MarsImagesAndroid,代码行数:19,代码来源:BaseObject3D.java


注:本文中的android.opengl.GLU.gluUnProject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。