我有一個從.obj文件加載的雪人模型。除了當我使用glRotatef()來旋轉模型時,一切正常,雪人的頭部總是會在身體前面呈現。雪人的鼻子也會始終在頭後。這產生了雪人在旋轉時改變方向的效果,但實際上這些部分不是以正確的z順序呈現。爲什麼會發生這種情況?Opengl ES - z軸上渲染不正確?
注意:雪人的所有部分來自使用攪拌器創建的相同.obj文件。
呈現這樣的模型(平局環)
glVertexPointer(3 ,GL_FLOAT, 0, model_verts);
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, 0, model_normals);
glDrawElements(GL_TRIANGLES, num_model_indices*3, GL_UNSIGNED_SHORT, &model_indices);
旋轉這樣的(在touchesMoved)
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
touchBeginPos = [touch locationInView:self];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
CGPoint touchEndPos = [[touches anyObject] locationInView:self];
glMatrixMode(GL_MODELVIEW_MATRIX);
glRotatef(10, (touchBeginPos.y - touchEndPos.y)/4, -(touchBeginPos.x - touchEndPos.x)/4, 0.0f);
touchBeginPos = touchEndPos;
}
發佈一些高層次的代碼可能有助於解釋怎麼回事。 – luke 2009-05-19 12:55:59
有沒有其他可能有用的信息? – 2009-05-19 13:20:50