aliens

Author Topic: Problem: Sprites have the center lined doubled compared to voxel/lofts  (Read 1135 times)

Offline Skybuck

  • Colonel
  • ****
  • Posts: 223
    • View Profile
So the sprites look like this  at the bottom center:

XX         XX
     XXXX

Instead of

XX     XX
     XX


So basically the voxel x = 0, voxel =0, voxel z = infinite is repeated twice !

One time for SpriteX = 15 and one time for spriteX=16

Is there a formula to solve this ?

So far I have:

   SpriteStartX = 16; // tile width
   SpriteStartY = 24; // tile depth

            SpriteX = (SpriteStartX + VoxelX) - VoxelY;
//            SpriteY = ((SpriteStartY + (VoxelX / 2)) + (VoxelY / 2)) - VoxelZ;  // original formula.

                                // for increased accuracy:
//            ComponentX = VoxelX / 2;
//            ComponentY = VoxelY / 2;

//            SpriteY = (SpriteStartY + (ComponentX  + ComponentY)) - VoxelZ;

                                // for speed up and maybe even slightly more accuracy:
            Component = VoxelX + VoxelY;
            Component = Component >> 1;

            SpriteY = (SpriteStartY + Component) - VoxelZ;


However the original formula is not sprite accurate in some cases, it doesn't cover the sprite 32x40 exactly... sometimes pixels go missing it seems.
It might be off by 1 pixel.

So something better is needed that compensate for the center line of the sprite to be duplicated...

I will show example what I am talking about with the red and blue line in the following image:

and also illustrate this line in the voxel data, where it's only blue, it overlaps the red line with the formula described in the picture.
Something better is needed, which somehow duplicates the center red line pixels and copies them to blue line... or maybe it has to recompute blue line, not sure yet if a copy would suffice or if it has to be recomputed.





« Last Edit: April 07, 2022, 09:43:28 am by Skybuck »

Offline Yankes

  • Commander
  • *****
  • Posts: 3210
    • View Profile
Solution is simple, each voxel is 2 pixel wide.
Then bottom of tile surface look like:

Code: [Select]
433  334 //some overlap each other! you see only one part of `44` voxel
  2112     //same with `22`
where this edge in voxel space look like:
Code: [Select]
1 2 3 4
2 . . .
3 . . .
4 . . .