私は、本体とそれに別の場所で「添付」する部分を含めて約7+の部分を持つオブジェクトを作成しました。私の目標はオブジェクト全体を回転させることです。私はオブジェクト全体を構築する前にglRotatef(angle, 0, 1, 0)
を呼び出すことを試みましたが、翻訳にかかわらず、これが原点の周りに「すべて」回転するように思えます。次のコードは、本体自体を回転させ、付属部品を回転させる試みでした。マルチパートオブジェクトを回転させる
// glRotatef(angle, 0, 1, 0); //old way of rotating the object
// body
glPushMatrix();
// movement
glTranslatef(subx, suby + y, subz);
//rotating the body itself
glRotatef(angle, 0, 1, 0);
// starting position of the body
glScalef(9.0, 1.75, 1.75);
glTranslatef(-subx, -suby, -subz);
glTranslatef(subx, suby, subz);
glutSolidSphere(1.0, 50, 50);
glPopMatrix();
// attached part
glPushMatrix();
// movement
glTranslatef(rot1x, rot1y + y, rot1z);
// attempting to rotate the part while 'attached to' the body
glRotatef(angle, 0, 1, 0);
//placing the part on the object in starting position
glRotatef(rot1angle, rot1xrot, rot1yrot, rot1zrot);
glTranslatef(-rot1x, -rot1y, -rot1z);
glTranslatef(rot1x, rot1y, rot1z);
gluPartialDisk(gluNewQuadric(), 0, 1, 50, 1, 0, 100.0);
glPopMatrix();
私は、オブジェクトの身体に適切に回転させるように、オブジェクトの小さな部品のために発生する必要があるもののまわりで私の頭を包むように見えることはできません(固定点?)。