Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
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 1187 times)
0 Members and 1 Guest are viewing this topic.
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


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 Kernel


Medals: 238
Projects: 11
Exp: 2 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« 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 Ninja


Medals: 16
Projects: 4
Exp: 14 years


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!
Legends of Yore - The Casual Retro Roguelike
Offline HeroesGraveDev

JGO Kernel


Medals: 238
Projects: 11
Exp: 2 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« 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.

Offline sproingie

JGO Kernel


Medals: 201



« 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 Ninja


Medals: 16
Projects: 4
Exp: 14 years


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: 742
Projects: 4
Exp: 16 years


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
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


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 Ninja


Medals: 16
Projects: 4
Exp: 14 years


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!
Legends of Yore - The Casual Retro Roguelike
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


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  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

ctomni231 (39 views)
2014-07-18 06:55:21

Zero Volt (36 views)
2014-07-17 23:47:54

danieldean (29 views)
2014-07-17 23:41:23

MustardPeter (32 views)
2014-07-16 23:30:00

Cero (47 views)
2014-07-16 00:42:17

Riven (48 views)
2014-07-14 18:02:53

OpenGLShaders (38 views)
2014-07-14 16:23:47

Riven (37 views)
2014-07-14 11:51:35

quew8 (33 views)
2014-07-13 13:57:52

SHC (70 views)
2014-07-12 17:50:04
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
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!