Page 2 of 2

Re: Lovox - Load and render voxels in Love2d

Posted: Thu Dec 15, 2016 1:49 pm
by SSG_DEV
This is amazing :ultrashocked: I would love to make an RTS with this aesthetic.

Re: Lovox - Load and render voxels in Love2d

Posted: Thu Dec 15, 2016 9:06 pm
by evgiz
Hey, I'm the guy who made Sprit3r, cool that you mentioned it. I was wondering, do you do any optimizations when it comes to rendering, or just drawing images on top of each other? I wrote a similar render system for my Ludum Dare game, and I found it to be fairly slow especially with love.js for the web. My solution was using spritebatches and only update them when the camera angle changed. I imagine it could be possible to optimize even further though.

Re: Lovox - Load and render voxels in Love2d

Posted: Fri Dec 16, 2016 11:15 am
by Tjakka5
SSG_DEV wrote:This is amazing :ultrashocked: I would love to make an RTS with this aesthetic.
Do it! I'd love to see what you come up with.
evgiz wrote:Hey, I'm the guy who made Sprit3r, cool that you mentioned it. I was wondering, do you do any optimizations when it comes to rendering, or just drawing images on top of each other? I wrote a similar render system for my Ludum Dare game, and I found it to be fairly slow especially with love.js for the web. My solution was using spritebatches and only update them when the camera angle changed. I imagine it could be possible to optimize even further though.
I dont do any other optimizing except for the way you just described. (And only rendering objects that are in the camera's view in my LD game.)
From my testing I was able to have atleast 1000 models on screen at good fps on my decent laptop.
Of course the results may vary with model size, you seem to be using bigger models?


On a side note; Im currently trying to make the Z-buffer work better. It fails in some situations.
I also got an idea to (majorly) optimize the image/func to model functions, which could make them very usuable in games without having a big performance impact.

Re: Lovox - Load and render voxels in Love2d

Posted: Thu Jul 05, 2018 5:37 pm
by drikdrok
Hi, I realize this is an old post, but I would like to use this library for a game.

My question is how do you rotate the camera around a point, like seen in the second gif?

Other than that, awesome work man!

Re: Lovox - Load and render voxels in Love2d

Posted: Thu Jul 05, 2018 5:48 pm
by drikdrok
drikdrok wrote: Thu Jul 05, 2018 5:37 pm Hi, I realize this is an old post, but I would like to use this library for a game.

My question is how do you rotate the camera around a point, like seen in the second gif?

Other than that, awesome work man!
Okay so I figured out my problem. By default it rotates around the camera's position. However, I was using another camera lib to handle camera movement (so I was using 2 cameras). That of course results in the camera rotating around 0,0.

But then I have another question:
How do you move the camera left and right, relative to the current rotation?

I've got forwards and backwards movement figured out like so:

Code: Select all

Camera:move(-(math.sin(Camera.rotation) * 200 * dt), -(math.cos(Camera.rotation) * 200 * dt)) -- Forwards

Camera:move(math.sin(Camera.rotation) * 200 * dt, math.cos(Camera.rotation) * 200 * dt) -- Backwards

Re: Lovox - Load and render voxels in Love2d

Posted: Thu Jul 05, 2018 6:10 pm
by drikdrok
drikdrok wrote: Thu Jul 05, 2018 5:48 pm
But then I have another question:
How do you move the camera left and right, relative to the current rotation?
I figured it out... Sorry for just writing 3 posts to myself here haha.

The solution is to just add or subtract 90 degrees to the movement and you got it. I can't believe could't figure this out for so long I asked for help here.

So here's the result:

Code: Select all

Camera:move(-(math.sin(Camera.rotation) * 200 * dt), -(math.cos(Camera.rotation) * 200 * dt)) -- Forwards
Camera:move(math.sin(Camera.rotation) * 200 * dt, math.cos(Camera.rotation) * 200 * dt) -- Backwards
Camera:move(math.sin(Camera.rotation-math.pi/2) * 200 * dt, math.cos(Camera.rotation-math.pi/2) * 200 * dt) -- Left
Camera:move(math.sin(Camera.rotation+math.pi/2) * 200 * dt, math.cos(Camera.rotation+math.pi/2) * 200 * dt) --Right
Hopefully this might help someone in the future!