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

  • SEARCH
  • Home
  • 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 9292537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:54:13+00:00 2026-06-18T20:54:13+00:00

Im building something in JOGL and im looking to make the camera move either

  • 0

Im building something in JOGL and im looking to make the camera move either through using the keyboard or mouse, it doesnt really matter, so long as the camera can pan around the object and possibly zoom in and out. If using the keyboard/mouse is difficult then I also dont mind using some buttons in the applications, e.g. arrows up, down, left and right and a plus and minus button for the zoom but basically whatevers easiest.
Im building something kind of like Lego but its proving to be quite difficult without being able to move the camera.

  • 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-18T20:54:15+00:00Added an answer on June 18, 2026 at 8:54 pm

    To move your “camera” you need to apply a glTranslate3f() transform at the beginning of your rendering function. If your camera’s location is to be

    cameraPos = <cx, cy, cz>
    

    then you should use

    glTranslate3f( -cx, -cy, -cz );
    

    This will offset everything that is drawn by that vector.

    In order to use the keyboard to make this happen, you will want to use a KeyListener implementation and define the functions specified by the interface.

    public void keyPressed( KeyEvent ke ){ // put something intelligent here... }
    public void keyReleased( KeyEvent ke ){}
    public void keyTyped( KeyEvent ke ){}
    

    Make sure to register this implementing class as a KeyListener to your GLJPanel (or whatever you’re using). Then, inside the keyPressed(…) function, check which key is being pressed and increment the appropriate coordinate of the camera.

    If you want to get really fancy and allow the mouse to enable you to look around, you can do a similar thing by creating a MouseMotionListener and registering it. The OpenGL transform that is needed to put this into play can vary based on what type of mouse behavior you are looking for. If you just want something simple that will allow you to look around, you can probably get away with tracking mouse motion in the x and y directions and allowing it to modify some offset angles. Moving the mouse in the x direction rotates about the y-axis. Movement in the y direction rotates about the x-axis. As an OpenGL call, as with the glTranslate3f(), you can use glRotatef() to rotate about each axis.

    glRotatef( angleX, 1, 0, 0 ); // to rotate about the x-axis
    glRotatef( angleY, 0, 1, 0 ); // to rotate about the y-axis
    

    Again, this is just a quick and easy solution. It won’t be beautiful, but it will work. If you want to implement something a bit fancier, you can look into computing an arbitrary axis rotation matrix.

    http://inside.mines.edu/~gmurray/ArbitraryAxisRotation/
    (one of many resources on this topic)

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

Sidebar

Related Questions

I'm building something using Google App Engine and I'm trying to create a java
I was building something using jQuery's AutoComplete plugin last week, but today I found
I'm building something ONLY for Chrome. I want to open several tabs with window.open
I'd like to start messing around programming and building something with an Arduino board,
I'm building a small CMS in PHP for a client and something I've noticed
Im building a Reversi program and i need to delay the program for something
building a site using PHP and MySQL that needs to store a lot of
Ok so, I am building something for my employer for them to input products,
Building on Tony's answer on this question : If I want to do something
I am building something for mobile and would like somehow to clear, null objects,

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.