These are chat archives for pixijs/pixi.js

29th
Jan 2016
Micheal Winger
@mordof
Jan 29 2016 01:29
@ivanpopelyshev
woops
so why is it any harder to create full iso tile textures rather than half-tile textures (triangle)?
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:31
quad is two triangles
you can split it two ways
in your case - vertical or horizontal
I recommend to split into 4 triangles, just add a center point :)
Micheal Winger
@mordof
Jan 29 2016 01:32
what's the usefulness in that though?
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:32
because that's universal
you dont have to favor one direction :)))
Micheal Winger
@mordof
Jan 29 2016 01:32
no i mean, in any of that - splitting into triangles vs not
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:32
and that way you'll have more details :))))
that's how WebGL handles quad
it splits into two triangles
Micheal Winger
@mordof
Jan 29 2016 01:34
only thing i can think of is that it changes the way i draw my textures
instead of a full tile, it's split into 4 chunks
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:34
you dont have to draw them at all
how do you do that anyway?
you can ask pixi to draw a mesh instead :)))
that will deal with all your tilemap in just one drawcall
Micheal Winger
@mordof
Jan 29 2016 01:35
sprite = new Sprite(texture_for_tile_formation_X) sprite.x, sprite.y. done
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:36
you wont need that
mordof @mordof looks into meshes with pixi
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:36
create a mesh and specify vertices
ivanpopelyshev @ivanpopelyshev ./ME WORKS HERE
Micheal Winger
@mordof
Jan 29 2016 01:37
lol
yep
ok so... since all of my tile variations are in one texture - it's just specifying the vertices, and setting the invs properly?
uvs*
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:37
yes
Micheal Winger
@mordof
Jan 29 2016 01:38
is it difficult to modify the mesh after the fact?
this feels like Three.js buffergeometry...
seems like it's similar
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:39
you can just change vertices and indices and set dirty = true
it will update
I recommend to change it while scrolling
Micheal Winger
@mordof
Jan 29 2016 01:39
why while scrolling?
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:39
if some new tiles appear on screen, re-calculate the geometry
Micheal Winger
@mordof
Jan 29 2016 01:39
hm
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:39
add in mesh only ones which are actually intersect the screen
that way you'll be able to have really big maps :))
Micheal Winger
@mordof
Jan 29 2016 01:40
right.. that has to happen for the entire geometry on the screen?
yeah, anything more than 400x400 tiles right now is just killing my fps with the way i'm doing it
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:40
can you calculate which tiles are likely to be drawn ? (i1,j1) -> (i2, j2) ?
in our coordinates its just a rectangle :)))
Micheal Winger
@mordof
Jan 29 2016 01:41
yeah, it's simple with the change
thank you again for that, by the way
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:41
add some space below according to your maximum height
then just FOR FOR FOR it and add to geometry
Micheal Winger
@mordof
Jan 29 2016 01:42
hmmmm
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:42
you either add only vertices, and its TRIANGLES , either add indices too and its TRIANGLE_MESH
look into Mesh soure
source
the only thing i dont like is that its not possible to set length for those arrays
Also, MeshRenderer
Micheal Winger
@mordof
Jan 29 2016 01:44
why is it good to add length to them?
i'll definitely check those out
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:44
because that way you'll be able to use the same arrays every time
and not create from scratch
mordof @mordof doesn't know how setting a length helps that
Micheal Winger
@mordof
Jan 29 2016 01:45
can't you just overwrite the details inside an array regardless?
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:46
yeah, but what about remainder?
need to specify actual length
its native array, not javascript array
Micheal Winger
@mordof
Jan 29 2016 01:46
hm
when you talk - sometimes the stuff just sounds like nonsense ;_;
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:47
UGH
also its DYNAMIC not STATIC...
you know what
new method
Micheal Winger
@mordof
Jan 29 2016 01:47
xD sorry
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:47
split all map to a number of chunks
create mesh for each chunk
Micheal Winger
@mordof
Jan 29 2016 01:48
oooh and just have a few chunks at a time
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:48
call getBounds() of every chunk, that way you'll know which will be on screen
Micheal Winger
@mordof
Jan 29 2016 01:48
then swap them out when i need to
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:48
render only those which are on screen
yeah
you'll add or remove new chunks
Micheal Winger
@mordof
Jan 29 2016 01:48
i like that method better...
^^;;
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:49
that's better when you want to show really BIG worlds
Micheal Winger
@mordof
Jan 29 2016 01:49
yeah, which i'm intending to have
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:49
you donnt have to FOR FOR FOR every time
just remember that you have to cache getBounds() value once you poositioned the chunk in the map
Micheal Winger
@mordof
Jan 29 2016 01:50
yep - i imagine that'd be a heavy call to do over and over
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:50
otherwise it will be computed each time you need it
Micheal Winger
@mordof
Jan 29 2016 01:50
unnecessary also
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:50
ok, about UVs, i can tell you about a trick
mordof @mordof listens intently
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:50
if you make tiles and pack them with texturepacker, i'll tell you how to get UVs for them using latest pixi version that includes my cheating GroupD8 class :)
do you see what happens when texture rotated by ,1,3,5, odd values?
Micheal Winger
@mordof
Jan 29 2016 01:52
mhmm
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:52
UV-s are going to center of texture edges :)
if you load a spritesheet which has many "diamond tiles"
and then rotate tthe texture, you'll get _uvs that you can copy to your mesh
for every type of your tile
Micheal Winger
@mordof
Jan 29 2016 01:53
oooooh
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:53
you wont have to calculate it
Micheal Winger
@mordof
Jan 29 2016 01:53
does that mean i can make my textures square?
and flat
lol
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:54
no, that means you can use current diamond-shaped ones :)
Micheal Winger
@mordof
Jan 29 2016 01:54
or will that still look weird
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:54
if you want square - then make square textures and use them, standart UVs of textures will do fine
mordof @mordof nods
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:55
you can extract uvs for square texture just ffine
but ffor diamond one you have to "rotate" them so they'll become a diamond :)
Micheal Winger
@mordof
Jan 29 2016 01:55
i don't do any rotating at the moment...
i imagine i'll understand once i get to that point
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:55
yeah
the point is - from standart PIXI atlas and texture you'll get UVs for corners
and if your tile is diamond-shaped then it wont be right, you need to select the diamonds
Micheal Winger
@mordof
Jan 29 2016 01:56
ooh right - it'll take my diamond shaped texture and then twist it yet again
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:56
*if your tile in your original texture is diamond_shaped
Micheal Winger
@mordof
Jan 29 2016 01:57
because the texture is still a square
mapped to differently positioned uv positions
mordof @mordof may have butchered that...
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:57
so you will have both diamond-shaped positions on screen in mesh
and diamond_shaped UVs in your texture
it will map 1:1
Micheal Winger
@mordof
Jan 29 2016 01:57
right :)
gotcha
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:58
for texturePacker i prefer to use "shoebox"
its free
ok, now i go sleep
Micheal Winger
@mordof
Jan 29 2016 01:58
oh good
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 01:58
its 5:00AM here
Micheal Winger
@mordof
Jan 29 2016 01:58
yikes!!!
thanks for the help! :D
Ivan Popelyshev
@ivanpopelyshev
Jan 29 2016 12:34
Micheal Winger
@mordof
Jan 29 2016 13:31
haha, nice