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 (404)
games submitted by our members
Games in WIP (289)
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  
  Isometric sorting, really hard to find?  (Read 3640 times)
0 Members and 1 Guest are viewing this topic.
Offline Twixly

Senior Newbie





« Posted 2009-10-12 14:24:52 »

Hello. I am running into problems when sorting my objects, well all is fine until an object takes up a certain amount of "height" as in Y pixels.

Here's sort of what I am aiming at : http://retromedia.ign.com/retro/image/article/910/910219/dream-arcades-20080915023523710.jpg

Best solution I found so far is using an sorting strictly on an objects ScreenY position (getScreenY+getHeightInPixels).. to sort of find the "feet" of the player. But this does not work if an object (a house for example) is several tiles wide, since then when I walk along side it I will obviously get above the house lowest point while I am still in front of it, which makes the house draw over my character.

I've googled my eyes out, but only found some Flash AS3 examples etc, I do not know flash unfortunately.

I mean really, there must been many Isometric games made in Java, can't someone help me out here? Smiley
Offline Orangy Tang

JGO Kernel


Medals: 48
Projects: 11


Monkey for a head


« Reply #1 - Posted 2009-10-12 14:35:36 »

There's no easy solution to that I'm afraid - for static objects you're probably best splitting it into multiple sprites. Usually you want to do that anyway so you can piece them together in different ways in your level editor.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 437
Projects: 4


Hand over your head.


« Reply #2 - Posted 2009-10-12 16:33:01 »

You can make OpenGL figure this out using the depthbuffer, as isometric perspective is 3D too.

http://www.java-gaming.org/topics/isometric-engine-rct-style-major-update-14-sep/10237/msg/82081/view.html#msg82081

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
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Twixly

Senior Newbie





« Reply #3 - Posted 2009-10-13 09:04:36 »

It's not 3d, it's actually 2d only.

Point of isometric is to give the illusion of 3d, which requires this "depth sorting".
I think it's commonly referred to as 2.5D?

Just like that link you gave me up there.
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 437
Projects: 4


Hand over your head.


« Reply #4 - Posted 2009-10-13 09:19:54 »

Quote
It's not 3d, it's actually 2d only. Point of isometric is to give the illusion of 3d, which requires this "depth sorting".
You can make the GPU solve this for you, pixel perfect, by using 3D geometry.

Quote
I think it's commonly referred to as 2.5D?
So because everybody fakes isometric with some 2D algorithms, you don't allow yourself work with 3D ? Ofcourse if you really want to work with 2D, that's fine Smiley

The screenshot in that link, was just a 3D scene, rendered in isometric perspective.


Isometric perspective is achieved using a specific projection-matrix. You can easily handle the most complex shapes, even intersecting geometry, just like any 3D perspective, using the depthbuffer.

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 Twixly

Senior Newbie





« Reply #5 - Posted 2009-10-13 15:45:56 »

That looks like the exact thing I am after.
However, I've never ever worked with 3d.
Yes I do realize that using 3d and displaying it as isometric is a solution, one that I would have to learn from scratch..
However, isometric games been around for ages, there's a ton of them. And I mean games that use only 2d Smiley

I would not mind terribly to go down the 3d path, just that it's a steep path indeed when starting from nothing.
Offline Eli Delventhal
« League of Dukes »

JGO Kernel


Medals: 39
Projects: 12


Game Engineer


« Reply #6 - Posted 2009-10-13 16:24:33 »

What you're doing (sorting by the Y and the height of the object) is the right way to do it if you're not doing everything in 3D. However, if you're doing this in OpenGL then you're using ortho mode, and ortho mode uses the Z-buffer automatically anyway like Riven already said. So instead of changing the drawing order based on the Y, you can just make the Z coordinate match the Y (or whatever sorting you want) and rotate it towards or away from the camera (along the X or Y axis) based upon how it is meant to be aligned, and voila it's taken care of. You don't really need to know any 3D to know how to do this, it's just clever usage of glTranslatef and glRotatef.

If you don't want to deal with that, then Orangy is right - you're just going to have to split the image up into multiple pieces. If you made yourself a level editor, you can just have it do that for you. Or even better you can have only one image but you can draw it twice - just trim your texture rect to only draw each piece where you want. This is cheap because you've still only bound that texture once.

See my work:
OTC Software
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars and Titan!

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 (37 views)
2013-05-17 21:29:12

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

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

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

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

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

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

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

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

UnluckyDevil (153 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.091 seconds with 20 queries.