我是openGL的新手,我的问题是当我执行旋转到Y轴时,函数glRotatef会产生错误的转换。我无法理解旋转功能是如何工作的,所以有人可以解释一下这个plis吗?
我的代码:
将每个弧放置到位:
void CreaStone(void)
{
stone = glGenLists(1);
if (stone != 0)
{ int i = 0;
int rotation = 15;
float translationX = 2;
float translationZ = 0;
float fact = 0.2;
glNewList(stone, GL_COMPILE);
for(i = 0; i<5; ++i){
/*Crear cada stone*/
glPushMatrix();
glScalef(0.15,0.15,0.15);
glRotatef(rotation, 0,1,0);
glTranslatef(translationX,0,0);
arco();
glPopMatrix();
translationX = translationX + 2;
//translationZ = translationZ + 1.8;
fact += 0.2;
rotation = rotation + 15;
}
glEndList();
}
}
显示巨石阵元素组件
void arco(void)
{
glPushMatrix();
glScalef(0.25,0.6,0.25);
glPushMatrix();
glRotatef(45, 0, 2, 0);
igWireCubo(4, 4);
glPopMatrix();
glPushMatrix();
glRotatef(45, 0, 2, 0);
glTranslatef(4,0,4);
igWireCubo(4, 4);
glPopMatrix();
glPopMatrix();
glPushMatrix();
glScalef(1.250,0.20,0.25);
glTranslatef(0,2,0);
glTranslatef(0.566,0,0);
glRotatef(45, 0, 2, 0);
//glRotatef(90, 1, 0, 0);
igWireCubo(4, 4);
glPopMatrix();
}
绘制一个多维数据集
void igWireCubo(int pu, int pv)
{
igCreateQuadricObject(pu, pv, 1.0f, 0.5f, 1.0f, 0.0f, 2.0f);
}
生成原始对象
void igCreateQuadricObject (int pu, int pv, float uMax, float vMax, float R, float s1, float s2)
{
float u, v, inc_u, inc_v;
float x, y, z;
int i,j;
v= 0.0f;
u = 0.0f;
inc_u = uMax / pu;
inc_v = vMax/ pv;
for (i = 0; i <= pu; ++i) {
glBegin(GL_LINE_LOOP);
for (j = 0; j<= pu; ++j)
{
x = xSuperQuadric(u, v, R, s1, s2);
y = ySuperQuadric(u, v, R, s1, s2);
z = zSuperQuadric(u, v, R, s1, s2);
glVertex3f(x, y, z);
u = u + inc_u;}
u = 0.0f;
glEnd();
v = v + inc_v;
}
v = 0.0f;
u = 0.0f;
for (i = 0; i <= pu; ++i) {
glBegin(GL_LINE_STRIP);
for (j = 0; j <= pv; ++j)
{
x = xSuperQuadric(u, v, R, s1, s2);
y = ySuperQuadric(u, v, R, s1, s2);
z = zSuperQuadric(u, v, R, s1, s2);
glVertex3f(x, y, z);
v = v + inc_v;
}
v = 0.0f;
glEnd();
u = u + inc_u;
}
}