Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8377559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:42:06+00:00 2026-06-09T15:42:06+00:00

I want to create a camera moving above a tiled plane. The camera is

  • 0

I want to create a camera moving above a tiled plane. The camera is supposed to move in the XY-plane only and to look straight down all the time. With an orthogonal projection I expect a pseudo-2D renderer.
My problem is, that I don’t know how to translate the camera. After some research it seems to me, that there is nothing like a “camera” in OpenGL and I have to translate the whole world. Changing the eye-position and view center coordinates in the Matrix.setLookAtM-function just leads to distorted results.
Translating the whole MVP-Matrix does not work either.

I’m running out of ideas now; do I have to translate every single vertex every frame directly in the vertex buffer? That does not seem plausible to me.

I derived GLSurfaceView and implemented the following functions to setup and update the scene:

public void onSurfaceChanged(GL10 unused, int width, int height) {

    GLES20.glViewport(0, 0, width, height);
    float ratio = (float) width / height;

    // Setup the projection Matrix for an orthogonal view
    Matrix.orthoM(mProjMatrix, 0, -ratio, ratio, -1, 1, 3, 7);

}

public void onDrawFrame(GL10 unused) {

    // Draw background color
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);

    //Setup the camera
    float[] camPos = {  0.0f,  0.0f, -3.0f }; //no matter what else I put in here the camera seems to point
    float[] lookAt = {  0.0f,  0.0f,  0.0f }; //  to the coordinate center and distorts the square

    // Set the camera position (View matrix)
    Matrix.setLookAtM( vMatrix, 0, camPos[0], camPos[1], camPos[2], lookAt[0], lookAt[1], lookAt[2], 0f, 1f, 0f);

    // Calculate the projection and view transformation
    Matrix.multiplyMM( mMVPMatrix, 0, projMatrix, 0, vMatrix, 0);

    //rotate the viewport
    Matrix.setRotateM(mRotationMatrix, 0, getRotationAngle(), 0, 0, -1.0f);
    Matrix.multiplyMM(mMVPMatrix, 0, mRotationMatrix, 0, mMVPMatrix, 0);

    //I also tried to translate the viewport here
    //  (and several other places), but I could not find any solution

    //draw the plane (actually a simple square right now)
    mPlane.draw(mMVPMatrix);

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:42:07+00:00Added an answer on June 9, 2026 at 3:42 pm

    Changing the eye-position and view center coordinates in the “LookAt”-function just leads to distorted results.

    If you got this from the android tutorial, I think they have a bug in their code. (made a comment about it here)

    Try the following fixes:

    1. Use setLookatM to point to where you want the camera to be.
    2. In the shader, change the gl_Position line

      from: " gl_Position = vPosition * uMVPMatrix;"
      to: " gl_Position = uMVPMatrix * vPosition;"

    3. I’d think the //rotate the viewport section should be removed as well, as this is not rotating the camera properly. You can change the camera’s orientation in the setlookat function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want create module which update list of usb devices automatically (not only mass
I want to create a camera application. What are the available ways to share
I want to create a very basic 3D modeling tool. The application is supposed
I Want Create a Win-Form Application Can be Connect to a Digital Camera Attached
i want create multiple search where statement $where_search is a multiple condition from post
I want create wordpress website into which I want create user management... That means
i want create a custom json data from the mssql 2008 results so that
I want create an application with animate button? how can i do? after click
i want create Dynamic Slideshow in Jquery i'm Write this code var ctx =
I want create a excel with Apache POI in java and I must insert

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.