On sprite overlapping for objects

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

Post Reply
User avatar
GuilhermeJK
Engineer
Engineer
Posts: 53
Joined: 01 Nov 2014 05:24
Location: São José dos Campos, Brazil

On sprite overlapping for objects

Post by GuilhermeJK »

Hello there, I'm fiddling around an idea of creating a "fake docktypes" grf in nml, using objects that overlay the standard dock sprites. After initial attempts, I'm confused on which order does OpenTTD draw the sprites. I tried these two combinations:
doubt_overlay_1.png
Two overlap cases
(65.1 KiB) Not downloaded yet
The two sprites are basically one water tile that servers as the actual placement (marked on the picture by the mouse cursor) with the two green tiles that mark the overlap intent. So on the left picture, the water tile is SW of the dock water tile and on the right one, the water tile in NE of the dock water tile.

My question: look at the trees in front of the base of the docks (ignore the fact the overlay doesn't follow the shore slope). How would be possible to make this sprite in order to "stay behind the tree"? I also put another building in place of the trees and the building also stays behind the green tile (instead of in front of it).

michael blunck
Tycoon
Tycoon
Posts: 5877
Joined: 27 Apr 2005 07:09
Contact:

Re: On sprite overlapping for objects

Post by michael blunck »

"Sprite overlapping" is just an ugly hack and shouldn't be used at all.

regards
Michael
Image

User avatar
GuilhermeJK
Engineer
Engineer
Posts: 53
Joined: 01 Nov 2014 05:24
Location: São José dos Campos, Brazil

Re: On sprite overlapping for objects

Post by GuilhermeJK »

I fiddled around more and there was no way of making what I wanted to look nice. So I'm abandoning this idea. The proper way of doing this would be (I think) implementing DockTypes and custom ship depots which I know would require a lot of working fiddling around the game source.

So I'm moving to more simple ideas first, I'm still too much of a rookie :)

User avatar
kamnet
Moderator
Moderator
Posts: 7258
Joined: 28 Sep 2009 17:15
Location: Eastern KY
Contact:

Re: On sprite overlapping for objects

Post by kamnet »

IIRC, the order is from left to right, from the top-down.

If you want to overlap the dock, then your sprite should be to the left of the dock and then offset to the right.

User avatar
GarryG
Tycoon
Tycoon
Posts: 3610
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: On sprite overlapping for objects

Post by GarryG »

GuilhermeJK wrote:
22 Apr 2020 22:56
So I'm abandoning this idea.
Don't give up that easy .. have a break and try again.

What I have found with overlaps mostly depends where you place the main tile and how you make the overlap piece. Found them a bit hard to to place them right when slopes are involved.
template_overlap.png
template_overlap.png (6.99 KiB) Viewed 824 times
This is basically what I use these days. The yellow tile is where the main building goes. The overlap I found works better in either of the green or the red tile section.

If Overlap goes in the pink you can expect glitches.

Anything drawn in the green and red, the game thinks it part of the object in the yellow.

One other thing to look for is this in the code:

Code: Select all

        
        zextent: 16;
    }
The zextent is the height of your object in pixels.

Hope these help.
Soot Happens
Screenshot Of The Month Winner March 2020
All my projects are GPLv2 License unless stated.
Auz Road Sets: viewtopic.php?f=29&t=87335
Auz Project Releases: viewtopic.php?f=67&t=84725
Auz Trains: http://www.tt-forums.net/viewtopic.php?f=26&t=74193
Auz Industry Sets: http://www.tt-forums.net/viewtopic.php?f=26&t=74471
Auz Objects: viewtopic.php?f=26&t=75657
Auz Bridges: viewtopic.php?f=26&t=75248
Auz Stations: viewtopic.php?f=26&t=76390
Auz Tracks: viewtopic.php?f=26&t=82691
Auz Subway Stations: viewtopic.php?f=26&t=85335

User avatar
GuilhermeJK
Engineer
Engineer
Posts: 53
Joined: 01 Nov 2014 05:24
Location: São José dos Campos, Brazil

Re: On sprite overlapping for objects

Post by GuilhermeJK »

Hmm, interesting stuff, I'll give another try :)

User avatar
LaRoso
Engineer
Engineer
Posts: 103
Joined: 15 Sep 2017 22:29
Location: Augsburg, BY, Germany

Re: On sprite overlapping for objects

Post by LaRoso »

GarryG wrote:
24 Apr 2020 02:39
The overlap I found works better in either of the green or the red tile section.
How far can you go with this? How many tiles in NE or NW direction can you overlap?
Image

User avatar
kamnet
Moderator
Moderator
Posts: 7258
Joined: 28 Sep 2009 17:15
Location: Eastern KY
Contact:

Re: On sprite overlapping for objects

Post by kamnet »

LaRoso wrote:
24 Apr 2020 06:03
GarryG wrote:
24 Apr 2020 02:39
The overlap I found works better in either of the green or the red tile section.
How far can you go with this? How many tiles in NE or NW direction can you overlap?
As far as you want. But keep in mind that eventually you're going to run out of space on the map - you put it too close to the map edge and the graphics will show up somewhere off the screen. Also, keep in mind that overlays like this will display occasional glitches, especially if vehicles move through those areas or if the background scenery changes (like trees growing, grass dying, fields changing, buildings changing, etc.).

User avatar
LaRoso
Engineer
Engineer
Posts: 103
Joined: 15 Sep 2017 22:29
Location: Augsburg, BY, Germany

Re: On sprite overlapping for objects

Post by LaRoso »

kamnet wrote:
24 Apr 2020 09:21
Also, keep in mind that overlays like this will display occasional glitches, especially if vehicles move through those areas
Does the overlay object overlap vehicles or vice versa?
Image

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9414
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: On sprite overlapping for objects

Post by planetmaker »

LaRoso wrote:
24 Apr 2020 09:53
kamnet wrote:
24 Apr 2020 09:21
Also, keep in mind that overlays like this will display occasional glitches, especially if vehicles move through those areas
Does the overlay object overlap vehicles or vice versa?
Possibly yes. OpenTTD does only update tiles which need an update. So when you extent your sprite beyond the tile it belongs to to left or right, or beyond the stated z-extent, you will get such glitches pretty sure; it's sometimes a question of likelyness which also depends on conditions of the surroundings. Thus I'd encourage you to simply try and see (but not be too surprised if the result might not be as good as hoped for).

Usually the better answer to the problem you want to solve is actually some changes in OpenTTD's code for the kind of objects you want to modify in order be become more flexible and increased NewGRF control. It doesn't mean necessarily it's an easy answer which will happen quickly though and it might result in many more questions than you are ready to answer at this stage :P

Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 3 guests