大佬教程收集整理的这篇文章主要介绍了android – 放大OpenGL ES 2.0 – 对象消失,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
该模型是一个不同楼层的建筑 – 我想放大到每个楼层的每个房间.但是,由于视锥体或者我无法非常“靠近”此对象,因此对象会消失.
我正在使用缩放触摸手势并获得“缩放”值 – 我现在该怎么做这个值?
到目前为止我尝试了什么:
更改近平面和远平面距离并更改Matrix.setLookAtM(….)中的eyeZ值,但我实现的只是缩小…稍微放大后它会消失…所以我我无法放大到一些特殊的部分(“那么远……”)
我怎么能做到这一点?
所以最大的问题是近平面与通过eyeZ-Value进行缩放相结合.它根本不起作用.如果我放大,对象会因为近平面而消失.但我没有看到任何背后的逻辑.
目前我正在使用:
@H_301_25@/* * Set the camera position (View matriX) */ Matrix.setLookAtM(mViewMatrix,offset,eyeX,eyeY,eyeZ / mZoomLevel,centerX,centerY,centerZ,upX,upY,upz);
其中mZoomLevel是我通过onTouch-Zooming获得的因素.
@H_301_25@@Override public void onDrawFrame(GL10 unused) { LoggerHelper.calculateFPS(); /* * Draw BACkground color */ GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); /* * scale model down to smaller values */ Matrix.setIdentitym(mModelMatrix,0); Matrix.scaleM(mModelMatrix,model3d.getRatio() * scaleFactor,model3d.getRatio() * scaleFactor); /* * rotate and translate model in dependence to the user input */ Matrix.translateM(mModelMatrix,translateX,translateY,translatez); Helper.rotateModel(mModelMatrix,rotationX,rotationY,rotationZ,true,model3d.getWidth(),model3d.getLength(),model3d.getHeight()); /* * Set the camera position (View matriX) */ Matrix.setLookAtM(mViewMatrix,upz); /* * combine the model with the view matrix */ Matrix.multiplymM(mMVMatrix,mViewMatrix,mModelMatrix,0); /* * this projection matrix is applied to object coordinates in the * onDrawFrame() method */ Matrix.frustuR_860_11845@M(mProjectionMatrix,-ratio,ratio,1,-1,nearPlaneDistance,farPlaneDistancE); /* * Calculate the projection and view transformation */ float[] mMVPMatrix = new float[16]; Matrix.multiplymM(mMVPMatrix,mProjectionMatrix,mMVMatrix,0); /* * all the drawing stuff inside the model-object (otherwise * translation/rotation wouldn't affect every object) */ model3d.draw(mMVPMatriX);
}
任何一些重要变量:
@H_301_25@private float nearPlaneDistance = 1f; private float farPlaneDistance = 200f; private float eyeZ = -1;
是)我有的:
我需要的:
@H_301_25@public void setZoom(float zoom) { // this projection matrix is applied to object coordinates // in the onDrawFrame() method float ratio = (float) width / height; Matrix.frustuR_860_11845@M(mProjectionMatrix,-ratio / zoom,ratio / zoom,-1 / zoom,1 / zoom,farPlaneDistancE); }
以上是大佬教程为你收集整理的android – 放大OpenGL ES 2.0 – 对象消失全部内容,希望文章能够帮你解决android – 放大OpenGL ES 2.0 – 对象消失所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。