* WalrusIRC

You need to have 5 posts and not be part of restricted usergroups in order to use the WalrusIRC embedded shoutbox. However, you can also access our IRC channel called #CodeWalrus via EFnet.

Author Topic: Lua3D Smooth Terrain Demonstration  (Read 2099 times)

0 Members and 1 Guest are viewing this topic.

Offline Tag365

  • New User
  • Join Date: Mar 2016
  • Location:
  • Posts: 6
  • Post Rating Ratio: +1/-0
    • View Profile
Lua3D Smooth Terrain Demonstration
« 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
« Last Edit: April 24, 2016, 05:55:12 am by DJ Omnimaga »



Offline Lionel Debroux

  • Full User
  • Join Date: Jan 2015
  • Location:
  • Posts: 215
  • Post Rating Ratio: +11/-0
    • debrouxl
    • 58/5891
    • View Profile
Re: TI-Nspire Lua3D Smooth Terrain Demostration
« Reply #1 on: 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) ;)
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TIEmu and TILP.
Co-admin of TI-Planet.

Offline KermMart̕ian

  • Full User
  • Join Date: Dec 2014
  • Location:
  • Posts: 29
  • Post Rating Ratio: +4/-7
    • View Profile
Re: TI-Nspire Lua3D Smooth Terrain Demostration
« Reply #2 on: 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.

Offline Tag365

  • New User
  • Join Date: Mar 2016
  • Location:
  • Posts: 6
  • Post Rating Ratio: +1/-0
    • View Profile
Re: TI-Nspire Lua3D Smooth Terrain Demostration
« Reply #3 on: 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.

Offline KermMart̕ian

  • Full User
  • Join Date: Dec 2014
  • Location:
  • Posts: 29
  • Post Rating Ratio: +4/-7
    • View Profile
Re: TI-Nspire Lua3D Smooth Terrain Demostration
« Reply #4 on: March 31, 2016, 08:54:47 pm »
Actually, it's just the two users from Cemetech that came over here to comment. :D

Offline Adriweb

  • Full User
  • CodeWalrus Supporter
  • *
  • Join Date: Jan 2015
  • Location: France & Canada
  • Posts: 397
  • Post Rating Ratio: +7/-0
    • Adriweb
    • @Adriweb
    • Adriweb
    • @UC-UIrbk5SuaUCvnV6SQvt-Q
    • /u/Adriweb
    • Adriweb
    • View Profile
    • TI-Planet.org
  • Gender: Male
Re: TI-Nspire Lua3D Smooth Terrain Demostration
« Reply #5 on: 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)
  • 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

Offline Caleb Hansberry

  • Full User
  • CodeWalrus Supporter
  • *
  • Safe-haven access
  • Join Date: Jan 2015
  • Location:
  • Posts: 161
  • Post Rating Ratio: +3/-0
  • I am a Christian
    • caleb_hansberry
    • View Profile
    • Skylites Computers
  • Gender: Male
Re: TI-Nspire Lua3D Smooth Terrain Demostration
« Reply #6 on: March 31, 2016, 08:59:57 pm »
That is real nice work!
  • Consoles, mobile devices and vintage computers owned: HP Portable Plus 110, Toshiba T3100, GRiD 1660, TI-99/4A, and much more than I can list here

Offline Jkolade936

  • All Around Coolio
  • Super User
  • Join Date: Jan 2016
  • Location: Horseheads, NY
  • Posts: 1515
  • Post Rating Ratio: +9/-1
  • I'm an unknown loner. I try to change that.
    • Jkolade936
    • View Profile
    • My Sprites and Walrii Collection
  • Gender: Male
Re: TI-Nspire Lua3D Smooth Terrain Demostration
« Reply #7 on: March 31, 2016, 09:10:09 pm »
That's fancy!  :thumbsup:
  • Calculators owned: None of them. :'(
Does this qualify as a signature? 
The answer is "Sure."


Online DJ Omnimaga

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Forum Maintenance
  • Original 5
  • CodeWalrus Supporter
  • *
  • Topic Management
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 17827
  • Post Rating Ratio: +89/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • View Profile
    • DJ Omnimaga music store
  • Gender: Male
Re: TI-Nspire Lua3D Smooth Terrain Demostration
« Reply #8 on: April 01, 2016, 02:41:22 am »
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

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:

Quote
Page 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 »
  • Calculators owned: TI-73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)
??? ??? ??? ???

Offline Jim Bauwens

  • Full User
  • Join Date: Feb 2015
  • Location:
  • Posts: 25
  • Post Rating Ratio: +1/-0
    • View Profile
Re: TI-Nspire Lua3D Smooth Terrain Demostration
« Reply #9 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.

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 »

Offline Tag365

  • New User
  • Join Date: Mar 2016
  • Location:
  • Posts: 6
  • Post Rating Ratio: +1/-0
    • View Profile
Re: TI-Nspire Lua3D Smooth Terrain Demostration
« Reply #10 on: April 01, 2016, 02:39:46 pm »
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).

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 »

Online DJ Omnimaga

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Forum Maintenance
  • Original 5
  • CodeWalrus Supporter
  • *
  • Topic Management
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 17827
  • Post Rating Ratio: +89/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • View Profile
    • DJ Omnimaga music store
  • Gender: Male
Re: TI-Nspire Lua3D Smooth Terrain Demostration
« Reply #11 on: April 01, 2016, 03:45:27 pm »
It doesn't run at all on OS 3.6 :(
  • Calculators owned: TI-73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)
??? ??? ??? ???

Offline Tag365

  • New User
  • Join Date: Mar 2016
  • Location:
  • Posts: 6
  • Post Rating Ratio: +1/-0
    • View Profile
Re: TI-Nspire Lua3D Smooth Terrain Demostration
« Reply #12 on: April 01, 2016, 03:56:45 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.

Online DJ Omnimaga

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Forum Maintenance
  • Original 5
  • CodeWalrus Supporter
  • *
  • Topic Management
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 17827
  • Post Rating Ratio: +89/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • View Profile
    • DJ Omnimaga music store
  • Gender: Male
Re: TI-Nspire Lua3D Smooth Terrain Demostration
« Reply #13 on: April 01, 2016, 03:59:16 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-73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)
??? ??? ??? ???

Offline Tag365

  • New User
  • Join Date: Mar 2016
  • Location:
  • Posts: 6
  • Post Rating Ratio: +1/-0
    • View Profile
Re: TI-Nspire Lua3D Smooth Terrain Demostration
« Reply #14 on: April 01, 2016, 04:23:28 pm »
I have fixed compatibility with apiLevel < 2.4. It should now work correctly.

 


You can also use the following HTML or bulletin board code to share it on your page or forum signature!


Also do not forget to check our affiliates below.
Planet Casio TI-Planet Calc.news BroniesQC BosaikNet Velocity Games