Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (603)
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 4484 times)
0 Members and 1 Guest are viewing this topic.
Offline Twixly

Senior Newbie





« Posted 2009-10-12 12: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: 56
Projects: 11


Monkey for a head


« Reply #1 - Posted 2009-10-12 12: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: 847
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #2 - Posted 2009-10-12 14: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
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 07: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: 847
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #4 - Posted 2009-10-13 07: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
Offline Twixly

Senior Newbie





« Reply #5 - Posted 2009-10-13 13: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

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #6 - Posted 2009-10-13 14: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.

 

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

The first screenshot will be displayed as a thumbnail.

Mr.CodeIt (20 views)
2014-12-23 03:34:11

rwatson462 (52 views)
2014-12-15 09:26:44

Mr.CodeIt (45 views)
2014-12-14 19:50:38

BurntPizza (80 views)
2014-12-09 22:41:13

BurntPizza (110 views)
2014-12-08 04:46:31

JscottyBieshaar (78 views)
2014-12-05 12:39:02

SHC (89 views)
2014-12-03 16:27:13

CopyableCougar4 (93 views)
2014-11-29 21:32:03

toopeicgaming1999 (155 views)
2014-11-26 15:22:04

toopeicgaming1999 (148 views)
2014-11-26 15:20:36
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
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!