Game Development Community

Orthographic projection

by Alessandro Loureiro · in Torque Game Engine · 11/10/2004 (5:45 pm) · 41 replies

Hello all ^_^

I'd like to have my game use an isometric orthographic projection for the 3D view of the world. Now, I know that to make this I should change a few stuff on the engine code, but I'm not sure where, and how to do it. All my attempts resulted on distorted, impossible-to-play views. for those of you who aren't very sure of what I'm aiming at, look at these pictures from my first alpha which was made on another engine.

This one is using normal projection
[IMAGE]onfinite.com/libraries/142156/d7e.jpg[/IMAGE]

And this one, the correct orthographic projection:
[IMAGE]http://onfinite.com/libraries/142157/69c.jpg[/IMAGE]

Now my question is, how can this effect be achieved on TGE? I doubt you can turn the default camera into a isometric one by just messing with the projection matrix, let alone use this orthographic projection. If anyone could point me in the right direction, I'd mostly apreciate it. Thanks in advance :)
#21
03/18/2005 (6:58 am)
No no you won't have to worry about anything. in fact, the camera being so far is even better, because now you REALLY know you'll never have to worry about the camera object colliding with something in the scenery :)
#22
03/18/2005 (10:25 am)
Also you can animate smoothly between normal perspective and 'orthographic' for a kinda nifty effect.
#23
03/18/2005 (1:59 pm)
That is an effect I'd like to see... can you make a quick demo?

ah and by the way, the fake ortho effect is better with really really small FOVs, like 3 or 5. 20 is still too much, at least in my opinion.
#24
03/18/2005 (2:03 pm)
I'm not actually programming torque no more,
but i think just interpolating the FOV and the camera position at the same time should do it.
Offhand i'd put it somewhere in the camera following code.
#25
03/18/2005 (2:13 pm)
Well, you can still zoom in and out by changing the FOV. Nothing is forcing you to use a fixed fov all the time.
#26
03/18/2005 (2:27 pm)
I guess so, but you'd still need to move the camera closer to the plane. just changing the FOV wouldn't achieve much of a zooming effect...
#27
03/18/2005 (2:30 pm)
Yes, it does.

If you change the FOV from say 5 to 3,
it's pretty much equivelant to zooming.
#28
03/18/2005 (2:40 pm)
Actually real life camera zoom *is* FOV change. It's entirely different than just getting closer to things.

"Getting closer" technically is not zoom.
#29
03/18/2005 (2:45 pm)
Lol, true dat.
when i Zoom w/ my real-life camera,
i'm definitely not getting closer to things!
#30
03/19/2005 (10:42 am)
I know that. but when you use this fake ortho effect, the FOV changes you're allowed to make without changing too much the ortho aspect of the scene are too subtle, so you need to move the camera closer to the scene if you want to achieve a noticeable zooming effect.
#31
03/21/2005 (4:34 am)
Ah, yes, if your FOV is too small already, you can reduce it much... I forgot FOV changes get less and less significant the smaller the values are.
#32
03/21/2005 (5:41 am)
Exactly :)
#33
03/21/2005 (7:01 am)
Well, the advancedCamera's godViewMode requires you to specify the camera offset as a vector. So you can easily push the camera closer/further by scaling the offset vector.

That way you can use the smallest allowed fov: 1.
#34
02/12/2006 (3:41 pm)
I am going to have to go ahead and resurrect this post. I am using the advanced camera, attempting to create an orthographic sidescrolling platformer. I haven't found any way to access the FOV. setFOV() doesn't seem to be a valid call anymore from the script. Anybody know how to change this or achieve an orthographic view some other way?
#35
02/12/2006 (4:02 pm)
I am going to have to go ahead and resurrect this post. I am using the advanced camera, attempting to create an orthographic sidescrolling platformer. I haven't found any way to access the FOV. setFOV() doesn't seem to be a valid call anymore from the script. Anybody know how to change this or achieve an orthographic view some other way?
#36
02/13/2006 (4:35 am)
Open Playgui.gui and change the following field in the PlayGui GameTsCtrl:

forceFov = 8;

That forces a GameTSCtrl to render using a specific FOV value.
#37
02/13/2006 (7:54 am)
Thanks Manoel, that does the trick. Sorry about the double post. Dunno what happened there... I have noticed that even a tiny FOV of 1 or 2 doesn't always pass for ortho in the sidescrolling environment, but I guess I will have to make do with that.
#38
05/15/2007 (12:58 pm)
Now you know why they call me The Necromancer..

so still noone has gotten true ortho in TGE in a clean way ?

Ben, there is indeed a ortho flag in camera queries which gets passed to dglSetFrustum(),
however there's about a zillion (well 11) places in the code which call it, and only a few pass in the ortho flag.

The rest default to false.

I went ahead and did some quick hacks to pass in ortho = true (and don't forget to initialize leftRight and topBottom in CameraQuery::CameraQuery()) and the very basics work, but things like reverse projecting into the scene are all mussed up. - This is actually okay for my purposes, i mainly want it as a mode in the WorldEditor for artists to check if triggers are properly lined up with spaces, etc, so it's okay if the editing is done in perspective and just checked in ortho. But it would be nice if it worked cleanly.

So perhaps the best approach to this is still Move The Camera Way Back And Set The FOV Way Small ?
#39
05/15/2007 (1:11 pm)
The ortho flag stuff should have been fixed in 1.5, as I had to fix it to get the Map Ctrl to work with interiors. (Interiors were where it was being set to false, and screwing up the Map rendering which needed it to be true)

If your not a 1.5 person, just put in dglIsOrtho() instead of false. Not sure if dglIsOrtho() is a 1.4 or earlier thing, I may have made it to fix this. I submitted the original bug fix to be included for 1.5 :)
#40
05/15/2007 (1:22 pm)
Thanks for getting back, Sebastien.

yeah, i added dglIsOrtho() to the calls which weren't supplying it (notably the interiors) and yeah, that's what got the basics going. raycasts into the world are still busted, but i guess that should be reasonable to patch up.
(or possibly i broke them some other way)