You can help CodeWalrus stay online by donating here. | New CodeWalrus | Old (dark mode) | Old (light) | Discord server

[TI-Nspire] Lua3D Smooth Terrain Demonstration

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

0
b/Games publicado por u/Tag365 March 31, 2016, 08:47:19 PM
This is a Lua program demonstrating smooth voxel terrain on the TI-Nspire. Yes, you read it right, smooth voxel terrain on the TI-Nspire. You can modify and sculpt the terrain, but only inside the zone marked by white lines. You can also move and rotate the camera.

Here is a screenshot:



Download:
Lua3D Smooth Terrain Demonstration
Last Edit: April 24, 2016, 05:55:12 AM by DJ Omnimaga
Inicia sesión o crea una cuenta para dejar un comentario
u/Lionel Debroux March 31, 2016, 08:49:41 PM
Looks quite good :)

And thanks for cross-posting here. I'm not staff, but believe me, you'll garner more attention on CodeWalrus (and TI-Planet) ;)
u/KermMart̕ian March 31, 2016, 08:52:45 PM
Yes, Lionel advocated posting this here from SAX, since Cemetech purportedly has the least TI-Nspire activity in the community. You can find the original topic here, if you're looking for it. Awesome work, Tag365.
u/Tag365 March 31, 2016, 08:53:41 PM
This thread got a reply very fast, this forum must be very popular. I fixed the download link as well.
u/KermMart̕ian March 31, 2016, 08:54:47 PM
Actually, it's just the two users from Cemetech that came over here to comment. :D
u/Adriweb March 31, 2016, 08:56:15 PM
It looks very nice indeed :)

Reading the code very quickly, I suggest making some light modifications:
all the math.* functions you use can be localized, and since we want the best performance especially for such a program, it will be a bit better.
So, at the top of the file, for instance, do: local mathfloor, mathceil, mathmin, mathmax, mathabs = math.floor, math.ceil, math.min, math.max, math.abs
and use those everywhere instead :P (I see you've already used this technique for abs at some point, though)
u/Caleb Hansberry March 31, 2016, 08:59:57 PM
That is real nice work!
u/Dudeman313 March 31, 2016, 09:10:09 PM
That's fancy!  :thumbsup:
u/Dream of Omnimaga April 01, 2016, 02:41:22 AM
Quote from: KermMartian on March 31, 2016, 08:54:47 PM
Actually, it's just the two users from Cemetech that came over here to comment. :D
The CW users tend to be quiet outside IRC during weekday afternoons for some reasons  (which is ironic, considering most users live in Europe) :P

Quote from: Tag365 on March 31, 2016, 08:47:19 PM
This is a Lua program demonstrating smooth voxel terrain on the TI-Nspire. Yes, you read it right, smooth voxel terrain on the TI-Nspire. You can modify and sculpt the terrain, but only inside the zone marked by white lines. You can also move and rotate the camera.

Here is a screenshot:



Download:
Lua3D Smooth Terrain Demonstration
This looks really impressive, even more so by the fact it seems to be in Lua, which isn't known for its high speeds. I don't have time to test this right now, but I am wondering how is the frame rate like?


EDIT: Which OS does this require, by the way? Because on OS 3.6 I am getting an error on launch. It says in very large text fonts:

QuotePage 1.1 has encountered an error.
Please contact the author with the following informations.

Line 2409:
attempt to call method
'setBackgroundColor' (a nil value)
Last Edit: April 01, 2016, 05:59:24 AM by DJ Omnimaga
u/Jim Bauwens April 01, 2016, 09:49:31 AM
Interesting project!

I've tested it on my handheld, but sadly rendering per frame takes a couple of seconds. You probably tested on the computer or iPad software? Edit: I see that you mentioned this in your readme.

Looking at the code, you should try to avoid making tables to store data during rendering, as allocating data from the heap is an expensive operation. Of course, it does become more complex that way to store (for example) vector points, but you really do get a good speedup. The price being that your code gets larger and more messy. If you can avoid certain function calls, you should do that too.
Last Edit: April 01, 2016, 12:05:18 PM by Jim Bauwens
u/Tag365 April 01, 2016, 02:39:46 PM
Quote from: Jim Bauwens on April 01, 2016, 09:49:31 AM
Interesting project!

I've tested it on my handheld, but sadly rendering per frame takes a couple of seconds. You probably tested on the computer or iPad software? Edit: I see that you mentioned this in your readme.
I wasn't expecting it to run fast at all on an actual handheld device.

On Touch Lua, the framework that the library was first implemented, it would also take seconds to draw a frame using a script like this with the huge amount of triangles being rendered to the screen. Though, that was caused by Touch Lua's drawing functions being slow to begin with and me running my scripts on an iPhone 4s (newer devices are much more powerful than that device). I recall being able to draw only about 9,000 triangles a second, and 20,000 rectangles a second (this was the best case scenario as I was running a benchmark script to get that info.), and drawing images lagging up my scripts.

On the Love framework running on my computer, my games would slow down to 30 fps when drawing around 3,110 filled and textured triangles (about 93,510 triangles a second). This is not really a lot (at least for the block building game I was making, the chunk rendering distance is very low), but it was a significant speed up from what it was on Touch Lua. Also, unlike Touch Lua it was also drawing textured triangles (something which I have tried on Touch Lua, but it was slow and it was not complete).

Quote from: Jim Bauwens on April 01, 2016, 09:49:31 AM
Looking at the code, you should try to avoid making tables to store data during rendering, as allocating data from the heap is an expensive operation. Of course, it does become more complex that way to store (for example) vector points, but you really do get a good speedup. The price being that your code gets larger and more messy. If you can avoid certain function calls, you should do that too.

Ok, I will consider doing that. I will also see if doing similar optimizations will also increase rendering speed on other frameworks.
By the way, does moving local variable declarations outside a loop make the script run any faster?
Last Edit: April 01, 2016, 02:52:31 PM by Tag365
u/Dream of Omnimaga April 01, 2016, 03:45:27 PM
It doesn't run at all on OS 3.6 :(
u/Tag365 April 01, 2016, 03:56:45 PM
Quote from: DJ Omnimaga on April 01, 2016, 03:45:27 PM
It doesn't run at all on OS 3.6 :(
Tell me what I need to fix to make it work correctly. Also I updated it so check that version to see if that works correctly.
u/Dream of Omnimaga April 01, 2016, 03:59:16 PM
Quote from: Tag365 on April 01, 2016, 03:56:45 PM
Quote from: DJ Omnimaga on April 01, 2016, 03:45:27 PM
It doesn't run at all on OS 3.6 :(
Tell me what I need to fix to make it work correctly. Also I updated it so check that version to see if that works correctly.
Line 2409:
attempt to call method
'setBackgroundColor' (a nil value)
u/Tag365 April 01, 2016, 04:23:28 PM
I have fixed compatibility with apiLevel < 2.4. It should now work correctly.
Start a Discussion

b/Games

Video games for TI, HP, Casio calculators, as well as Android, PC and game consoles.

62
Topics
Explore Board
Website statistics


MyCalcs | Ticalc.org | Cemetech | Omnimaga | TI-Basic Developer | MaxCoderz | TI-Story | Casiocalc.org | Casiopeia | The Museum of HP Calculators | HPCalc.org | CnCalc.org | Music 2000 Community | TI Education | Casio Education | HP Calcs | NumWorks | SwissMicros | Sharp Calculators
Powered by EzPortal