2D等距立方体图

时间:2018-06-22 07:48:19

标签: c opengl drawing

我想绘制一个如下所示的等距立方体,以便获得3D图形的直线。第三个图片是我想要的示例-外部立方体上的直线。从实验来看,这不适用于使用透视变换的3D。

在信息图表中,我尝试绘制底部正方形(剪切30,旋转-30),但仍然有些偏离。

enter image description here

void draw_outer()
{
int ii; 
int w, h;
float equiv = 0.0f;
Matrix transform = IDENTITY_MATRIX;

w = glutGet(GLUT_WINDOW_WIDTH);
h = glutGet(GLUT_WINDOW_HEIGHT);

equiv = h/(float)w;

//vert scale
ScaleMatrix(&projection, 1.0f, .861f, 1.0f);
//shear x adjusted for aspect ratio
ConstructShearMatrixX(&projection, .5236f * equiv);
//rotation
//fix aspect ratio
RotateAboutZ(&projection, -.5236f);
ScaleMatrix(&projection, equiv, 1.0f, 1.0f);

glUniformMatrix4fv(uniform_ids[0], 1, GL_FALSE, model.m);
glUniformMatrix4fv(uniform_ids[1], 1, GL_FALSE, view.m);                                     
glUniformMatrix4fv(uniform_ids[2], 1, GL_FALSE, projection.m);
} 

我的顶点着色器只是glPosition =(投影*视图*模型* position.xyz)。

enter image description here enter image description here

0 个答案:

没有答案