Jump to content

Isometric Camera Code


Recommended Posts

The new 45 degree camera is quite beautiful, but I always found isometric views more ...strategic. the "isometricity" makes it like a map. So here's my first draft of a basically isometric camera. It's hardly worth sharing, as I just changed the FOV and doubled or multiplied by 10 some numbers at random.


; Camera control settings
view.scroll.speed = 240.0
view.rotate.x.speed = 1.2
view.rotate.x.min = 28.0
view.rotate.x.max = 60.0
view.rotate.x.default = 35.0
view.rotate.y.speed = 2.0
view.rotate.y.speed.wheel = 0.45
view.rotate.y.default = 0.0
view.drag.speed = 5
view.zoom.speed = 1024.0
view.zoom.speed.wheel = 320.0
view.zoom.min = 500.0
view.zoom.max = 2000.0
view.zoom.default = 1000.0
view.pos.smoothness = 0.1
view.zoom.smoothness = 0.4
view.rotate.x.smoothness = 0.5
view.rotate.y.smoothness = 0.3
view.near = 2.0 ; Near plane distance
view.far = 4096.0 ; Far plane distance
view.fov = 5.0 ; Field of view (degrees), lower is narrow, higher is wide

The more interesting thing I noticed was with this camera, the game would frequently run into sorting issues issues with close meshes when zoomed out to get a decent amount of map on screen. I'm going to take a wild guess as to the cause: Because to get enough area on the screen with that FOV, the camera has to be very far way / zoomed out. What ever variable stores the sorting data has to account for so large range of "camera z-axis", that it is no longer precise enough to avoid good ol' rounding errors with meshes that close.

If that is true, I would propose fixing that problem like this: make a bounding box with a base inscribing the portion of the map visible, and a height corresponding the to the heighest object that could exist in game, or some fixed substitute, figure out the longest line segment spanning the box collinear with a line emanating from the camera, and finally scale the sorting variable to account for that range and nothing more. If my novice prediction is at all right, that should make it so that sorting errors are equally prevalent/hopefully-nonexistent regardless of the camera setup, with the benign side effect that geometry in positions relative to the camera that should never happen are culled.

Now that I think of it, I have seen similar errors in other 3D renders. Hopefully this is something that can be fixed, and isn't to prohibitively buried in the bowls of SDL or OpenGL to be fixed on 0 A.D.'s end.

Link to comment
Share on other sites

view.near is the key thing to change, I set it to 32.0 with your other settings and things looked ok. I seem to remember philip (Ykkrosh) saying that the depth resolution is on a log scale so changed 2 to 4 actually doubles the resolution. Also I noticed that the carpets at the front of the persian CC show z fighting on every camera setting I tried (including the defaults) so ignore them.

Link to comment
Share on other sites

O f*** you, I love that so hard! This is awesome! No really, it's so great! Fantastic! One of the most intense steps forward in the development of 0 A.D. in the last couple of months! :banana:

This reminds me on Age of Kings and the Conquerors and the old AoE 1 and so on! This is incredible! I didn't thought that something like this is possible with the pyrogenesis engine!

edit: The only bad thing, taht I realize that some of the textures on some of the buildings are now flickering while scrolling. This is better when I set view.near to 32.0 but there's still some flickering. Why do the textures flicker anyway?

Edited by Almin
Link to comment
Share on other sites

Wow, I did not expect this much of a positive response.

view.near is the key thing to change, I set it to 32.0 with your other settingsand things looked ok. I seem to remember philip (Ykkrosh) saying that the depthresolution is on a log scale so changed 2 to 4 actually doubles the resolution.Also I noticed that the carpets at the front of the persian CC show z fightingon every camera setting I tried (including the defaults) so ignore them.

A ha, the culling feature was under my nose all along. How is it logarithmic,though? if 2→4 doubles it, isn't that linear? Thanks for the tip on the Persian carpets too, It was the first instance I noticed.

Hi,

this is the changeset that modified the FOV in the last Alpha:

http://trac.wildfire...changeset/10548

Thanks. I just copied in the old rotation settings to begin fixing that.

But kinda hurts my eyes strangely. Like, my brain expects it to be 3D, but yetit's (nearly) isometric.

I know what you mean. Maybe I just liked zoomed out RTSs (aoe2wide, look it up), but I found that being zoomed out (or maybe even the act of zooming out) help a lot.

Edited by Sonarpulse
Link to comment
Share on other sites

A ha, the culling feature was under my nose all along. How is it logarithmic,though? if 2→4 doubles it, isn't that linear? Thanks for the tip on the Persian carpets too, It was the first instance I noticed.

It is a range from 2-4096 so if it was split linearly into say 4000 pieces then the resolution is 1 everywhere, changing the 2 to 4 effectively makes no difference, even setting it to 1024 only makes it about 0.75 units. In the OpenGL docs I found it said that the z buffer value is the reciprocal of z (so saying it was logarithmic was wrong). With this example, the far plane is at 4096 and 1/4096 is small so lets call it 0 for convenience. So for near=2 we have a range of 0 to 0.5, for near = 4 we have 0 to 0.25 so the resolution is doubled, for near=8 we have 0 to 0.125 doubling the resolution again.

Link to comment
Share on other sites

Making an Iso option, with restrictions on camera and buildings rotation (45 degree) would change the look and feel completely.

There are some open source games that has the option to change the game's look and feel just by modifing parameters in the render engine (Smokin Guns, for example, has the option to make it look like a comics style).

I love both FOVs the same, and it would be cool to switch :)

Link to comment
Share on other sites

@iap: I think you get this, but just to reiterate, this doesn't bind the camera angle or anything like that. Ideally, I would like to see 0ad support defining multiple cameras in local.cfg (and maybe share the logic for multiple hotkey sub-profiles). Then for uber-competitive multiplayer, one camera can be agreed upon, and for everything else, they can be switched between easily.

@quantumstate. Thanks so much, I think I get it now.

Link to comment
Share on other sites

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...