Hi folks,
I'm fairly new to LOVE and graphics in general. I want to be able to design some "models" in MagicaVoxel or Goxel and use them for a pseudo-3d effect when the camera rotation changes. It works for single sprites, but a naive "tile set" implementation shows where my knowledge falls apart.
Basically, I:
- dumped the model files to an image (eg 32*8 x 32)
- load each as part of an arrayImage
- set quads to each section of individual images that are the stacks of each model (eg 32x32 8 times, stacking up)
- create a SpriteBatch from the arrayImage
- add layers that references the specified textures & quads so that the sections of each image are stacked
When I rotate the camera, the images properly 'rotate' in the sense that you can see the pseudo-3d effect, but in order to do that I have to pass the rotation of the camera to `:setLayer`. This causes the whole tile to be rotated (obviously).
The issue with this is that the tiles aren't rotated 'as a set'. So if I have a tile set [(x0,y0 1), (x0,y32 2)] and the camera is rotated, they are drawn independently instead of rotated as a group. If I remove the rotation factor and w2s and just use `gamera.draw` after rotating, they're drawn together but again, no rotation (so no "neat effect").
I'm not sure how to maintain this perspective trickery _and_ rotate the tiles as a group.
Does anyone have suggestions on how to do this properly? I feel like I'm just lacking some basic 3d-2d knowledge that would make this work.
Note: I will attach a .love file that demonstrates this. It's probably easier to see the details if you zoom in (mousewheel up), and rotating is done by holding down left mouse button and moving left<->right. It's a bad implementation right now so rotating too far draws the tiles out of view, but you can see the perspective change with just tiny rotations. I apologize if this is difficult to see!
(edit: s/psuedo/pseudo/g)
[SOLVED] Rotating a "tile map" where individual tiles rotate
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
[SOLVED] Rotating a "tile map" where individual tiles rotate
- Attachments
-
- rotate.love
- example
- (4.26 KiB) Downloaded 161 times
Last edited by illd on Sat Aug 15, 2020 8:32 pm, edited 2 times in total.
Re: Rotating a "tile map" where individual tiles rotate
By any chance you mean Mode7?
Re: Rotating a "tile map" where individual tiles rotate
How about having one spritebatch per layer? Then you draw all layers from bottom to top, doing a translation for each before calling gamera:draw().
Edit: Proof of concept attached (replaces your main.lua).
Edit: Proof of concept attached (replaces your main.lua).
- Attachments
-
- main.lua
- (4.27 KiB) Downloaded 140 times
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Rotating a "tile map" where individual tiles rotate
Also, pseudo, not psuedo.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: Rotating a "tile map" where individual tiles rotate
Wow, this is embarassing, lol. Thank you.
I haven't heard of this, actually. I'm new to a lot of the concepts here so I'm not exactly sure what I'm going for yet, just trying to understand some basics. But thank you - I will be watching this video closely.
pgimeno - THANK YOU. This is exactly what I was attempting to do. I sincerely appreciate you taking a look and writing this example, I will refactor my code to use this.
Future reader: this is what pgimeno's PoC does.
Who is online
Users browsing this forum: No registered users and 4 guests