3D Spinner

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
kalle2990
Party member
Posts: 245
Joined: Sat Sep 12, 2009 1:17 pm
Location: Sweden

3D Spinner

Post by kalle2990 »

I made a little demo showing what effects you can use quads for, a spinner.
The spinner spins the LÖVE logo around its own center in 3D and the script works with any Image. This is just a quick demo and the code is a bit messy :roll:
But it could easily be made into a library and even a stretch function between 4 points. And because everyone should be able to see this, the source image is a Power of 2 :ultrahappy: And the fact that it's very fast makes it even better, on my PC I get up to 800 FPS (with vsync disabled for testing purposes) :)

Feel free to comment ^^
Spinner.love
A spinning LÖVE logo
(4.64 KiB) Downloaded 359 times
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: 3D Spinner

Post by TechnoCat »

This is brilliant. Now someone go remake GTA. Or even possibly include this in that raycasting demo.
pekka
Party member
Posts: 206
Joined: Thu Jan 07, 2010 6:48 am
Location: Oulu, Finland
Contact:

Re: 3D Spinner

Post by pekka »

I just wanted to report it even runs on my old computer with Windows using its software GL renderer at about 20 to 40 FPS. That was much better than I expected, considering that most LÖVE programs just crash on it.

I'll see if I can do a little write-up about the math involved here at some later time, and look at how well this can be adapted to a more general case. This is not to prevent anyone else from doing the write-up first, of course :)

Good show, Kalle.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: 3D Spinner

Post by TechnoCat »

It just creates a quad for each column.
pekka
Party member
Posts: 206
Joined: Thu Jan 07, 2010 6:48 am
Location: Oulu, Finland
Contact:

Re: 3D Spinner

Post by pekka »

I didn't imply that it would be hard to understand, just that it might be interesting to go over it in some detail and also see how well the technique generalizes. You know, because it is cute.
User avatar
kalle2990
Party member
Posts: 245
Joined: Sat Sep 12, 2009 1:17 pm
Location: Sweden

Re: 3D Spinner

Post by kalle2990 »

Hmm.. making this stretching between 4 points is a bit harder than I thought. :? If ImageData supported pasting quads (or more important, scaling :x ) this would be a piece of cake.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: 3D Spinner

Post by Jasoco »

I too wish we could specify X and Y coordinates for each corner of an image. We could do some nifty fake 3D effects like Coverflow and such.

I could make my 2D adventure engine into a pseudo PSX-style half-3D game.
pekka
Party member
Posts: 206
Joined: Thu Jan 07, 2010 6:48 am
Location: Oulu, Finland
Contact:

Re: 3D Spinner

Post by pekka »

I really have to stop distracting myself with this LÖVE 3D business. There are real 3D APIs, you know. Well, okay okay, this is done for fun. I understand.

And since I am posting yet again, I have something useful to say too. What this method could possibly approximate in its most general form is known as perspective correct texture mapping. Reading about it might be helpful if you are intent on hacking together something like this in LÖVE.

http://en.wikipedia.org/wiki/Texture_ma ... orrectness

I confess I have a perverse fascination as to how fast it can be made, but I must really not start working at it myself. I. Must. Not. :o
pekka
Party member
Posts: 206
Joined: Thu Jan 07, 2010 6:48 am
Location: Oulu, Finland
Contact:

Re: 3D Spinner

Post by pekka »

This is somewhat relevant to the topic.

I suggested a new feature for a future version of LÖVE, namely shear mapping. It's a transformation that can help in building pseudo-3D effects, and will perhaps find some use as a result.

http://en.wikipedia.org/wiki/Shear_mapping

http://love2d.org/forum/tracker.php?p=2&t=193

The math in the Wikipedia article is not an exact match with what is appropriate for LÖVE.

I have taken a PNG screenshot of the program I posted into the feature suggestions. It shows a rectangular array of circles sheared (shorn?? no way) with the parameters 0.2 and 0.1 . The image is hosted at imgur to avoid making you download it (unless you want to), though it is only 42.7 KB by the looks of it.

http://imgur.com/UA7HJ

Let's hope the LÖVE devs decide to include it in a future version.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: 3D Spinner

Post by Jasoco »

It'll only be useful if it can be skewed as well. In that one edge is shorter than the other. Then you'd have real perspective.
Post Reply

Who is online

Users browsing this forum: No registered users and 26 guests