Hello Guest

Author Topic: Mixing a 2D mesh with sprites  (Read 4551 times)

iTris666

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 3
    • View Profile
Mixing a 2D mesh with sprites
« on: June 11, 2012, 05:51:04 pm »
Hi,

I'm trying to mix a 2D procedural mesh (on all vertices z == 0 ) and sprites. I try to have some sprites on front then my mesh then a lot of sprites behind.

The problem is that my mesh is always in front of all sprites even if the z value would place it between sprites.

First I tried with my own shader : a very simple shader with light off and blending a constant color.
Since it didn't work I tried with tk2D own BlendVertexColor shader, but the result is the same.

Strangely enough I can order 2 of my meshes by using the z value of their transform ( like I do with the sprites ), but the sprite will never be drawn on front of my mesh.

The sprites I use are either tk2DSprites or tk2DAnimatedSprites ( no sprite batcher ).

Any ideas on how to have my mesh z ordering respected ?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Mixing a 2D mesh with sprites
« Reply #1 on: June 11, 2012, 07:52:25 pm »
Hi iTris666,
Did you calculate bounds for the mesh after creating it?

iTris666

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Mixing a 2D mesh with sprites
« Reply #2 on: June 12, 2012, 09:41:43 am »
Thanks,

Actually I did call mesh.RecalculateBounds() but it was messed up but the fact that I added an invalid point at -10000 -10000 -10000. which put the center of bounds at -5000 instead of 0. setting the point at -10000 -10000 0 fixed the problem.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Mixing a 2D mesh with sprites
« Reply #3 on: June 12, 2012, 09:48:42 am »
Glad its sorted now