GLKitでユーザーの指に続くテクスチャがあります。2点間のアークタンを使用して角度を描くためにラジアンを計算します。
ここでの秘訣の一部は、オブジェクトを指の中心に置いておくということです。そこで、原点や中心を基準にして物を描くことができるように、アンカーポイントのアイデアを紹介しました。私の目標は、スプライトを所定の位置に移動してから回転させることです。レンダラーに次のコードがあります。
// lets adjust for our location based on our anchor point.
GLKVector2 adjustment = GLKVector2Make(self.spriteSize.width * self.anchorPoint.x,
self.spriteSize.height * self.anchorPoint.y);
GLKVector2 adjustedPosition = GLKVector2Subtract(self.position, adjustment);
GLKMatrix4 modelMatrix = GLKMatrix4Multiply(GLKMatrix4MakeTranslation(adjustedPosition.x, adjustedPosition.y, 1.0), GLKMatrix4MakeScale(adjustedScale.x, adjustedScale.y, 1));
modelMatrix = GLKMatrix4Rotate(modelMatrix, self.rotation, 0, 0, 1);
effect.transform.modelviewMatrix = modelMatrix;
effect.transform.projectionMatrix = scene.projection;
もう1つの注意点は、私のスプライトがテクスチャエイリアス上にあることです。回転を外すと、スプライトは指の下の中央に正しく描画されます。私のプロジェクトマトリックスはGLKMatrix4MakeOrtho(0、CGRectGetWidth(self.frame)、CGRectGetHeight(self.frame)、0、1、-1);です。そのため、UIkitとそれに埋め込まれているビューと一致します。