我想圍繞OpenGL中的對象繞軌道運行相機。沒有發生。這裏是我的代碼:OpenGL ES圍繞對象的軌道相機
該對象是標準的多維數據集。
- (void)update {
float aspect = fabsf(self.view.bounds.size.width/self.view.bounds.size.height);
float radius = 10.0f;
float startAngle = -3 * M_PI/4.0;
float newX = 0.0f + radius *cos(phi)*sin(theta);
float newY = 0.0f + radius *sin(phi)*sin(theta);
float newZ = 0.0f + radius *cos(theta);
GLKMatrix4 projectionMatrix = GLKMatrix4MakeLookAt(newX, 0.0, newZ
0.0, 0.0, 0.0,
0.0, 1.0, 0.0);
self.effect.transform.projectionMatrix = projectionMatrix;
GLKMatrix4 modelViewMatrix = GLKMatrix4MakeTranslation(0.0f, 0.0f, 0.0f);
self.effect.transform.modelviewMatrix = modelViewMatrix;
}
-(void) viewPanned:(UIPanGestureRecognizer *) sender
{
CGPoint curTouch = [sender locationInView:self.view];
if ([sender state] == UIGestureRecognizerStateBegan){
oldX = curTouch.x;
oldY = curTouch.y;
}
theta += (curTouch.x-oldX)*0.001f;
phi += (curTouch.y-oldY)*0.001f;
oldX = curTouch.x;
oldY = curTouch.y;
}
我不看到,從變換的投影矩陣眼座標剪輯座標(由'theta' /'phi'旋轉)。這可能是你的問題的一部分......除此之外,它可能有助於澄清「不太可能發生」。 – rickster
GLKMatrix4 projectionMatrix = GLKMatrix4MakeLookAt(newX,0.0,newZ 0.0,0.0,0.0, 0.0,1.0,0.0); 這是一個投影矩陣?或者我錯過了什麼?在這種情況下也不會發生意味着白屏,沒有任何東西。 – Stpn