2012-01-23 16 views
0

数時間の苦労の末、私は最終的にオブジェクトを描くことができましたが、回転するときには固まってしまいました。私はy軸を中心に回転させようとしていますが、回転を滑らかにすることはできません。その周りを飛び回っている。私はテンプレートを使用したので、いくつかのビットとその間にuneccessaryの部分があるかもしれません。回転するOpenGL-ESオブジェクト

- (void)update 
{ 
    float aspect = fabsf(self.view.bounds.size.width/self.view.bounds.size.height); 
    GLKMatrix4 projectionMatrix = GLKMatrix4MakePerspective(GLKMathDegreesToRadians(65.0f), aspect, 0.1f, 100.0f); 

    self.effect.transform.projectionMatrix = projectionMatrix; 

    GLKMatrix4 baseModelViewMatrix = GLKMatrix4MakeTranslation(0.0f, 0.0f, -4.0f); 

    // Compute the model view matrix for the object rendered with ES2 
    GLKMatrix4 modelViewMatrix = GLKMatrix4MakeTranslation(0.0f, 0.0f, 0.0f); 
    modelViewMatrix = GLKMatrix4Rotate(modelViewMatrix, startPoint.y, 0.0f, 1.0f, 0.0f); 

    dx = dy = 0; 
    modelViewMatrix = GLKMatrix4Multiply(baseModelViewMatrix, modelViewMatrix); 

    _normalMatrix = GLKMatrix3InvertAndTranspose(GLKMatrix4GetMatrix3(modelViewMatrix), NULL); 

    _modelViewProjectionMatrix = GLKMatrix4Multiply(projectionMatrix, modelViewMatrix); 

    _rotation += self.timeSinceLastUpdate * 0.5f; 
} 

そして、私のタッチ行動:事前に

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    UITouch *touch = [touches anyObject]; 
    startPoint = [touch locationInView:self.view]; 
} 

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    UITouch *touch = [touches anyObject]; 
    CGPoint point = [touch locationInView:self.view]; 
    dx = point.y - startPoint.y; 
    dy = point.x - startPoint.x; 
    startPoint = point; 
} 

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
{ 

} 

感謝。

答えて

-1

あなたの問題を解決することができますリンゴライブラリの下のリンクを経由して [http://developer.apple.com/library/ios/#samplecode/GLSprite/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007325

+0

返信いただきありがとうございますが、残念なことにサンプルにはタッチの手段でユーザーのやりとりがありません。 – JavaCake

+0

他のコメントは単なるリンクです – michaelsnowden

関連する問題