How to set up a top view camera?

Questions regarding game mechanics and graphic programming should go here.

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard

How to set up a top view camera?

Postby Jami » Sun Aug 07, 2005 6:41 pm

Hey guys,

Can someone tell me how can i set up top view camera for my scene? I've tried using gluLookAt() but i couldn't figure out the way i wanted. Any ideas with starting code would be really apperciated. Thanks in advance!! =]
Reagrds,
Jami
--------------
Open GL graphics is awesome. It's great source for building an amazing game only if i knew how to.
Jami
 
Posts: 18
Joined: Mon Jul 11, 2005 8:48 am

Postby taymo2020 » Sun Aug 07, 2005 6:56 pm

Kinda Off Topic:

How did you start to learn OpenGL?
taymo2020
 
Posts: 998
Joined: Mon Mar 07, 2005 5:39 pm
Location: On the pot..

Postby Jami » Sun Aug 07, 2005 7:12 pm

lol From Nehe tutorials :oops: . Well, i'm beginner don't know a lot :(
Reagrds,
Jami
--------------
Open GL graphics is awesome. It's great source for building an amazing game only if i knew how to.
Jami
 
Posts: 18
Joined: Mon Jul 11, 2005 8:48 am

Postby Animatronic » Sun Aug 07, 2005 7:47 pm

from google the gluLookat func is gluLookAt( eyeX,eyeY,eyeZ,centerX,centerY,centerZ,upX,upY,upZ).

eyeX,Y,Z is the position of your 'camera' e.g. (0,10,20),
centerX,Y,Z is a point where your camera is looking e.g. (0,0,0),
upX,Y,Z is the up vector for you camera, just keep it (0,1,0),

make sure you do this call at the beginning of your game loop, before rendering anything.
Animatronic
 
Posts: 90
Joined: Wed Jun 23, 2004 9:08 pm

Postby Samuel » Mon Aug 08, 2005 4:29 am

Also Kinda Off Topic:

You cant really say that OpenGL has awesome graphics. 'Graphics' depend on the complexity of the game, like the poly count, antialliasing and other pretty things. Perhaps im being to picky :|
But apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, the fresh-water system, and public health, what have the Romans ever done for us?
User avatar
Samuel
 
Posts: 676
Joined: Wed Apr 06, 2005 7:43 pm
Location: Australia

Postby devil_slayer » Mon Aug 08, 2005 5:05 am

The way i always used to to do it is first draw all the objects and then use glTranslate and glRotate to "move" the camera to the designated position.
This, of course, moves the scene, not the camera, but the effect is the same.
User avatar
devil_slayer
 
Posts: 489
Joined: Wed Oct 01, 2003 3:44 am
Location: Warsaw, POLAND

Postby Emery » Mon Aug 08, 2005 3:31 pm

devil_slayer wrote:The way i always used to to do it is first draw all the objects and then use glTranslate and glRotate to "move" the camera to the designated position.
This, of course, moves the scene, not the camera, but the effect is the same.
gluLookAt is the correct way.
--~~~~
User avatar
Emery
 
Posts: 4313
Joined: Sat Mar 19, 2005 9:16 am

Postby devil_slayer » Mon Aug 08, 2005 5:06 pm

Sure...
User avatar
devil_slayer
 
Posts: 489
Joined: Wed Oct 01, 2003 3:44 am
Location: Warsaw, POLAND

Postby Animatronic » Mon Aug 08, 2005 5:33 pm

devil_slayer wrote:The way i always used to to do it is first draw all the objects and then use glTranslate and glRotate to "move" the camera to the designated position.
This, of course, moves the scene, not the camera, but the effect is the same.


I would be interested how this works?, I mean how do the camera transforms done at the end effect objects drawn before it ? Maybe I'm just mis-understanding your post.
Animatronic
 
Posts: 90
Joined: Wed Jun 23, 2004 9:08 pm

Postby Emery » Mon Aug 08, 2005 5:46 pm

Animatronic wrote:
devil_slayer wrote:The way i always used to to do it is first draw all the objects and then use glTranslate and glRotate to "move" the camera to the designated position.
This, of course, moves the scene, not the camera, but the effect is the same.


I would be interested how this works?, I mean how do the camera transforms done at the end effect objects drawn before it ? Maybe I'm just mis-understanding your post.
He's talking about moving the world around the camera rather than the camera around the world.
--~~~~
User avatar
Emery
 
Posts: 4313
Joined: Sat Mar 19, 2005 9:16 am

Postby devil_slayer » Mon Aug 08, 2005 6:07 pm

Animatronic wrote:I would be interested how this works?, I mean how do the camera transforms done at the end effect objects drawn before it ? Maybe I'm just mis-understanding your post.


Sry, you are right. This operation is meant to be done at the begining, before objects are drawn. The downside is that for drawing some objects you have to use glLoadIdentity() and in this approach you have to add the translation and rotation every time you do that also...

Anyways:
gluLookAt is equivalent to glMultMatrixf(M); glTranslated (-eyex, -eyey, -eyez);
User avatar
devil_slayer
 
Posts: 489
Joined: Wed Oct 01, 2003 3:44 am
Location: Warsaw, POLAND

Postby Animatronic » Tue Aug 09, 2005 10:01 am

if your using glLoadIdentity() to discard unwanted transforms (translations + rotations etc) then pushing / poping the matrix stack would be more appropriate, as then it would preserve the initial camera settings (be it gluLookAt or whatever)
Animatronic
 
Posts: 90
Joined: Wed Jun 23, 2004 9:08 pm


Return to Games and Graphics

Who is online

Users browsing this forum: No registered users and 0 guests

cron