如何用等距透视渲染? [英] How to render with isometric perspective?
问题描述
可能重复:
使用opengl的真实等距投影
Blender3d使用相同的等距渲染,我如何做到这一点?是否可能只调用glMultMatrix()?我试图googling,但couldnt找到任何工作矩阵,将导致这种渲染模式。我试过这个 http://en.wikipedia.org/wiki/Isometric_projection ,但它只是表现得很奇怪。
I want to render using the same isometric rendering which Blender3d uses, how can i do this ? Is it possible with just a call to glMultMatrix() ? I tried googling but couldnt find any working matrixes that would result in that kind of rendering mode. i tried this http://en.wikipedia.org/wiki/Isometric_projection but it just rendered really weird.
这是现在使用正常透视呈现的矩阵:
This is the matrix i use now that renders with normal perspective:
GLdouble f = cotan(fovy/2.0);
GLdouble aspect = (GLdouble)width/(GLdouble)height;
IsoMatrix.x[0] = f/aspect;
IsoMatrix.y[0] = 0;
IsoMatrix.z[0] = 0;
IsoMatrix.w[0] = 0;
IsoMatrix.x[1] = 0;
IsoMatrix.y[1] = f;
IsoMatrix.z[1] = 0;
IsoMatrix.w[1] = 0;
IsoMatrix.x[2] = 0;
IsoMatrix.y[2] = 0;
IsoMatrix.z[2] = (zfar+znear)/(znear-zfar);
IsoMatrix.w[2] = (2.0*zfar*znear)/(znear-zfar);
IsoMatrix.x[3] = 0;
IsoMatrix.y[3] = 0;
IsoMatrix.z[3] = -1;
IsoMatrix.w[3] = 0;
glMultMatrixd((GLdouble *)&IsoMatrix);
如何更改它,因此会导致: http://rvzenteno.files.wordpress.com/2008/10/rvz_018.jpg ?
How do i change it so it will result to: http://rvzenteno.files.wordpress.com/2008/10/rvz_018.jpg ?
推荐答案
更容易使用 glOrtho 然后旋转轴:
It is easier to use glOrtho then rotate the axes:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-10.0f, 10.0f, -10.0f, 10.0f, -10.0f, 10.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRotatef(35.264f, 1.0f, 0.0f, 0.0f);
glRotatef(-45.0f, 0.0f, 1.0f, 0.0f);
这篇关于如何用等距透视渲染?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!