Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (293)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  viewport question  (Read 598 times)
0 Members and 1 Guest are viewing this topic.
Offline erikd

JGO Knight


Medals: 3
Projects: 3


Maximumisness


« Posted 2013-01-15 22:29:07 »

I find it difficult to put this question into words seeing how much I suck at math etc, but here it goes:

I'd like to change the view frustum as such that the center is no longer in the middle of the screen, but without rotating the camera.
Just shifting the viewport down a bit so that quads on the Z-plane still face the camera without an angle.
I suppose that means 'skewing' the view frustum so to speak.

Offline HeroesGraveDev

JGO Wizard


Medals: 64
Projects: 8


Muahahahahahaha...


« Reply #1 - Posted 2013-01-15 22:31:39 »

Just translate the matrix along the y axis using glTranslatef() or whatever other method you use.

Offline erikd

JGO Knight


Medals: 3
Projects: 3


Maximumisness


« Reply #2 - Posted 2013-01-16 00:04:47 »

doesn't that just move the camera instead of skewing the frustum?

Games published by our own members! Check 'em out!
Try the Free Demo of Titan Attacks
Offline HeroesGraveDev

JGO Wizard


Medals: 64
Projects: 8


Muahahahahahaha...


« Reply #3 - Posted 2013-01-16 00:15:25 »

Try it. If it doesn't work, could you please give a better explanation of the effect you want.

Online sproingie
« Reply #4 - Posted 2013-01-16 00:22:21 »

Stereoscopic projections skew the frustum to the left and right.  You could take a look at how those are set up and just tweak the equations to skew on the Y axis instead of X (or just use them as-is and rotate your whole scene).

I believe that's only necessary when doing stereo though.  If you just have the one camera, the effect should be identical to just translating.

Offline erikd

JGO Knight


Medals: 3
Projects: 3


Maximumisness


« Reply #5 - Posted 2013-01-16 00:44:02 »

Thanks spoingie, I'll look into that.

HeroesGraveDev, to explain it better:

Instead of this:


I want this:


If I translate down, the point where the road goes to infinity is still in the middle; the camera is just lower to the ground.
It's also not just rotating down because the purple square you see still faces the viewport without an angle.

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 438
Projects: 4


Hand over your head.


« Reply #6 - Posted 2013-01-16 02:23:17 »

I'd translate the projection matrix, then, not the modelview matrix.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Projects: Revenge of the Titans, Titan Attacks, Droid Assault, and Ultratron
Offline erikd

JGO Knight


Medals: 3
Projects: 3


Maximumisness


« Reply #7 - Posted 2013-01-16 15:03:26 »

But that still just moves the camera, doesn't it?
I've tried this but it's not what I'm looking for: The point of infinity along the Z-axis is still in the center of the screen while I'd like it more to the top.

Anyway, I was able to sort of get what I need by overriding libgdx's PerspectiveCamera.apply(), and put a glFrustumf() call in there for GL_PROJECTION (ignoring the projection matrix in the Camera class altogether).
It's a bit dirty, and I suppose it would be much better to understand how to change the projection matrix to get the same effect, but I'll try to figure it out somehow.

Offline CommanderKeith
« Reply #8 - Posted 2013-01-16 15:45:48 »

Sounds like you want to tilt the view so you're facing up a little rather than horizontal?

Offline erikd

JGO Knight


Medals: 3
Projects: 3


Maximumisness


« Reply #9 - Posted 2013-01-16 16:27:56 »

Actually in my screenshot in the WIP section the view is still simply tilted down slightly, but that has problems with the alpha particles on the X/Y plane that then also appear slightly tilted, which looks a bit unnatural imho (which is especially apparent when the fov increases when you speed up).

Another solution would of course be to rotate the camera down and tilt those particles back up towards the screen, but I had the idea that not rotating but just moving the vanishing point slightly upwards would be easier and look a bit better (especially in cases where opaque elements and blended elements would collide because of the tilted blended elements).

Games published by our own members! Check 'em out!
Try the Free Demo of Revenge of the Titans
Offline erikd

JGO Knight


Medals: 3
Projects: 3


Maximumisness


« Reply #10 - Posted 2013-01-16 23:22:38 »

Here's a screenshot of how I did it now:


quite happy with the result now; imho it looks better than slightly tilting down the camera

Pages: [1]
  ignore  |  Print  
 
 

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Browse for soundtracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (73 views)
2013-05-17 21:29:12

alaslipknot (85 views)
2013-05-16 21:24:48

gouessej (114 views)
2013-05-16 00:53:38

gouessej (109 views)
2013-05-16 00:17:58

theagentd (120 views)
2013-05-15 15:01:13

theagentd (109 views)
2013-05-15 15:00:54

StreetDoggy (154 views)
2013-05-14 15:56:26

kutucuk (176 views)
2013-05-12 17:10:36

kutucuk (173 views)
2013-05-12 15:36:09

UnluckyDevil (182 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.088 seconds with 21 queries.