Incorrect rendering polygons on isometric map with Berry


(ldurniat) #1

Hi,

I’m working on adding support for isometric maps to Berry but I have problem with positioning polygons in Corona Simulator. Everything works great with orthogonal maps as you can see below

However, on the isometric map polygons are rotated and traslated from their orignal position in Tiled Editor

I have noticed that coordinates in bottom-left corner are the same as anchor points for polygons on orthogonal map but they different on isometric maps. I’m not sure it is related. An red dot indicate cursor of mouse on the screen.

I use Tiled v1.2.1 and JSON as fromat output.

level.json (isometric map)

{ "height":10,
 "infinite":false,
 "layers":[
        {
         "data":[5, 5, 5, 5, 15, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 15, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 15, 15, 15, 15, 6, 6, 6, 6, 6, 6, 6, 4, 4, 4, 4, 15, 6, 6, 6, 6, 6, 6, 6, 4, 3, 3, 4, 15, 6, 6, 6, 6, 6, 6, 6, 4, 3, 3, 4, 15, 6, 6, 6, 6, 6, 6, 6, 4, 4, 4, 4, 15, 6, 6, 6, 6, 6, 6, 6, 6, 15, 15, 15, 15, 6, 6, 6, 6, 6, 6, 6, 6, 15, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 15, 6, 6, 6, 6, 6, 6, 6],
         "height":10,
         "id":1,
         "name":"Tiles",
         "opacity":1,
         "type":"tilelayer",
         "visible":true,
         "width":12,
         "x":0,
         "y":0
        }, 
        {
         "draworder":"topdown",
         "id":3,
         "name":"Polygons",
         "objects":[
                {
                 "height":0,
                 "id":8,
                 "name":"",
                 "polygon":[
                        {
                         "x":0,
                         "y":0
                        }, 
                        {
                         "x":-71.7378410438909,
                         "y":-69.7520184544406
                        }, 
                        {
                         "x":-22.30871886121,
                         "y":-122.916666666667
                        }, 
                        {
                         "x":51.1788256227758,
                         "y":-53.1646482122261
                        }],
                 "rotation":0,
                 "type":"",
                 "visible":true,
                 "width":0,
                 "x":365.639356195406,
                 "y":413.94696969697
                }, 
                {
                 "height":0,
                 "id":9,
                 "name":"",
                 "polygon":[
                        {
                         "x":0,
                         "y":0
                        }, 
                        {
                         "x":-56.5634638196916,
                         "y":-56.5109573241061
                        }, 
                        {
                         "x":-17.5898576512456,
                         "y":-99.5833333333333
                        }, 
                        {
                         "x":40.3532028469751,
                         "y":-43.0723760092272
                        }],
                 "rotation":0,
                 "type":"",
                 "visible":true,
                 "width":0,
                 "x":271.79831230454,
                 "y":201.280303030303
                }, 
                {
                 "height":0,
                 "id":10,
                 "name":"",
                 "polygon":[
                        {
                         "x":0,
                         "y":0
                        }, 
                        {
                         "x":-119.595492289443,
                         "y":-115.906574394464
                        }, 
                        {
                         "x":-37.19128113879,
                         "y":-204.25
                        }, 
                        {
                         "x":85.3211743772242,
                         "y":-88.3434256055363
                        }],
                 "rotation":0,
                 "type":"",
                 "visible":true,
                 "width":0,
                 "x":659.497007440958,
                 "y":622.613636363636
                }, 
                {
                 "height":0,
                 "id":13,
                 "name":"",
                 "polygon":[
                        {
                         "x":0,
                         "y":0
                        }, 
                        {
                         "x":-135.158956109134,
                         "y":-131.039215686274
                        }, 
                        {
                         "x":-42.0311387900356,
                         "y":-230.916666666667
                        }, 
                        {
                         "x":96.4243772241992,
                         "y":-99.8774509803921
                        }],
                 "rotation":0,
                 "type":"",
                 "visible":true,
                 "width":0,
                 "x":618.393804593982,
                 "y":313.94696969697
                }, 
                {
                 "height":0,
                 "id":15,
                 "name":"",
                 "polygon":[
                        {
                         "x":0,
                         "y":0
                        }, 
                        {
                         "x":-56.5634638196916,
                         "y":-56.5109573241061
                        }, 
                        {
                         "x":-17.5898576512456,
                         "y":-99.5833333333333
                        }, 
                        {
                         "x":40.3532028469751,
                         "y":-43.0723760092272
                        }],
                 "rotation":0,
                 "type":"",
                 "visible":true,
                 "width":0,
                 "x":-260.20168769546,
                 "y":378.613636363637
                }],
         "opacity":1,
         "type":"objectgroup",
         "visible":true,
         "x":0,
         "y":0
        }, 
        {
         "draworder":"topdown",
         "id":4,
         "name":"Object Layer 2",
         "objects":[
                {
                 "gid":1,
                 "height":64,
                 "id":16,
                 "name":"",
                 "rotation":0,
                 "type":"",
                 "visible":true,
                 "width":128,
                 "x":249.333333333333,
                 "y":377.333333333333
                }],
         "opacity":1,
         "type":"objectgroup",
         "visible":true,
         "x":0,
         "y":0
        }],
 "nextlayerid":5,
 "nextobjectid":17,
 "orientation":"isometric",
 "renderorder":"right-down",
 "tiledversion":"1.2.1",
 "tileheight":64,
 "tilesets":[
        {
         "columns":4,
         "firstgid":1,
         "image":"handpainted.png",
         "imageheight":256,
         "imagewidth":512,
         "margin":0,
         "name":"ground",
         "spacing":0,
         "tilecount":16,
         "tileheight":64,
         "tilewidth":128,
         "transparentcolor":"#000000"
        }],
 "tilewidth":128,
 "type":"map",
 "version":1.2,
 "width":12
}

Problem affect also object positioning.

Sorry for my english:)

Have a nice day:)

ldurniat

EDIT: I solved my issue using


(Thorbjørn Lindeijer) #2

Nice to see you’ve already got it figured out!

Projecting the polygons onto the ground plane made sense to me, because the existing rectangle objects did the same thing, which in turn was because I expected them to be mostly used to mark areas of the map.

When I later added tile objects, projecting the image did not make sense, so for these objects only their position is projected, and the sprite is aligned upwards from there (and horizontally centered).

In the end it’s all rather more inconsistent than I’d like it to be. Maybe eventually we’ll make a new start and find a way to make it all consistent, while retaining the current features somehow… :slight_smile: