
该模型是一个不同楼层的建筑 – 我想放大到每个楼层的每个房间.但是,由于视锥体或者我无法非常“靠近”此对象,因此对象会消失.
我正在使用缩放触摸手势并获得“缩放”值 – 我现在该怎么做这个值?
到目前为止我尝试了什么:
更改近平面和远平面距离并更改Matrix.setLookAtM(….)中的eyeZ值,但我实现的只是缩小…稍微放大后它会消失…所以我我无法放大到一些特殊的部分(“那么远……”)
我怎么能做到这一点?
所以最大的问题是近平面与通过eyeZ-Value进行缩放相结合.它根本不起作用.如果我放大,对象会因为近平面而消失.但我没有看到任何背后的逻辑.
目前我正在使用:
/* * Set the camera position (VIEw matrix) */Matrix.setLookAtM(mVIEwMatrix,offset,eyeX,eyeY,eyeZ / mZoomLevel,centerX,centerY,centerZ,upX,upY,upZ);
其中mZoomLevel是我通过ontouch-Zooming获得的因素.
我的整个Matrix-Operations显示在这里:
@OverrIDepublic 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.frustumM(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); }
任何一些重要变量:
private float nearPlanedistance = 1f;private float farPlanedistance = 200f;private float eyeZ = -1;
I uploaded a dummy-project with only the OpenGL-part on Github – in case you want to have a better look into the sourcecode
是)我有的:
我需要的:
解决方法 我的解决方案之一(工作效果不佳):public voID setZoom(float zoom) { // this projection matrix is applIEd to object coordinates // in the onDrawFrame() method float ratio = (float) wIDth / height; Matrix.frustumM(mProjectionMatrix,-ratio / zoom,ratio / zoom,-1 / zoom,1 / zoom,farPlanedistance);} 但这不是最好的方法(请参阅此答案下面的内容)
总结以上是内存溢出为你收集整理的android – 放大OpenGL ES 2.0 – 对象消失全部内容,希望文章能够帮你解决android – 放大OpenGL ES 2.0 – 对象消失所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)