Join us on Discord!
You can help CodeWalrus stay online by donating here.

[TI-Nspire] Lua3D Smooth Terrain Demonstration

Started by Tag365, March 31, 2016, 08:47:19 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Tag365

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

Lionel Debroux

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) ;)
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TIEmu and TILP.
Co-admin of TI-Planet.

KermMart̕ian

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.

Tag365

This thread got a reply very fast, this forum must be very popular. I fixed the download link as well.

KermMart̕ian

Actually, it's just the two users from Cemetech that came over here to comment. :D

Adriweb

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)
  • Calculators owned: TI-Nspire CX CAS, TI-Nspire CX, TI-Nspire CAS (x3), TI-Nspire (x2), TI-Nspire CM-C CAS, TI-Nspire CAS+, TI-80, TI-82 Stats.fr, TI-82 Plus, TI-83 Plus, TI-83 Plus.fr USB, TI-84+, TI-84+ Pocket SE, TI-84+ C Silver Edition, TI-84 Plus CE, TI-89 Titanium, TI-86, TI-Voyage 200, TI-Collège Plus, TI-Collège Plus Solaire, 3 HP, some Casios
Co-founder & co-administrator of TI-Planet and Inspired-Lua

Caleb Hansberry

  • Calculators owned: TI-82, TI-83, TI-83+SE, TI-84+SE, TI-85, TI-89, TI-99/4A
  • Consoles, mobile devices and vintage computers owned: HP Portable Plus 110, Toshiba T3100, Toshiba T5200, GRiD 1660, TI-99/4A, Apple IIgs, and much more than I can list here

Dudeman313

  • Calculators owned: TI-84 PCE
  • Consoles, mobile devices and vintage computers owned: Android O Phone
Does this qualify as a signature? 
The answer is "Sure."


Dream of Omnimaga

#8
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)
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Jim Bauwens

#9
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.

Tag365

#10
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?

Dream of Omnimaga

  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Tag365

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.

Dream of Omnimaga

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)
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Tag365

I have fixed compatibility with apiLevel < 2.4. It should now work correctly.

Powered by EzPortal