当摄像机跟随时,Box2d抖动

时间:2014-07-17 16:11:26

标签: android opengl-es box2d

我正在开发一款关于android的box2d游戏,当opengl相机跟随玩家时,玩家会非常紧张。当相机静止时,它看起来很好。我尝试了box2d插值,这似乎有点帮助。有什么建议吗?

public static void setCamera() {

    // Position the eye behind the origin.
    float eyeX = cameraX;
    float eyeY = cameraY;
    float eyeZ = cameraZoom;

    // We are looking toward the distance
    float lookX = cameraX;
    float lookY = cameraY;
    float lookZ = -5.0f;

    // Set our up vector. This is where our head would be pointing were we
    // holding the camera.
    float upX = 0.0f;
    float upY = 1.0f;
    float upZ = 0.0f;

    // Set the view matrix. This matrix can be said to represent the camera
    // position.
    // NOTE: In OpenGL 1, a ModelView matrix is used, which is a combination
    // of a model and
    // view matrix. In OpenGL 2, we can keep track of these matrices
    // separately if we choose.
    Matrix.setLookAtM(mViewMatrix, 0, eyeX, eyeY, eyeZ, lookX, lookY,
            lookZ, upX, upY, upZ);
    // Matrix.scaleM(mViewMatrix, 0, cameraZoom, cameraZoom, 0f);

    // Matrix.orthoM(mProjectionMatrix, 0, left, right, top, bottom, near,
    // far);
    // Matrix.setLookAtM(mViewMatrix, 0, 1, 0, 1.0f, 1.0f, 0f, 0f, 0f, 1.0f,
    // 0.0f);
}

0 个答案:

没有答案