f64 userdatas have the following arithmetic operations:
add, sub, mul, div, mod, min, max, idiv
We can create a few additional useful operations using just these.
local function ud_floor(x) return x-x:mod(1) end local function ud_floor(x) return x:idiv(1) end -- Alternative. Faster for userdatas smaller than ~270 elements. local function ud_round(x) x += 0.5 return x-x:mod(1) end local function ud_ceil(x) return (0-x):mod(1)-x end local function ud_abs(x) return x:max(0-x) end local function ud_sign(x) return x/(x:max(0-x)) end -- Not zero-safe. local function ud_positive(x) return x:max(0)/x end -- Not zero-safe. local function ud_negative(x) return x:min(0)/x end -- Not zero-safe. local function ud_tern(c,a,b) return a*c+b*(1-c) end |
Here are some other useful userdata math tricks:
local function sum(x) return vec(0):add(x,true,0,0,1,1,0,#x)[0] end local function prod(x) return vec(1):mul(x,true,0,0,1,1,0,#x) [ [size=16][color=#ffaabb] [ Continue Reading.. ] [/color][/size] ](/bbs/?pid=159743#p) |
I made this demo to quickly demonstrate how to use Blade3D, a 3D rendering API I'm working on. It doesn't make full use of the API, but it does give you a starting point if you want to make your own projects using (this version of) Blade3D. Hopefully I can make a slightly more comprehensive introduction to the API with full documentation in the near future, but for anyone willing to look at the underlying code, it should be pretty easy to accomplish whatever you need with just this template.
Something that isn't included in the template is a .obj to .ptm converter, which is provided here. It expects the .obj to include material references (not the .mtl file itself) and for the mesh to be triangulated.




Arrow keys to edit the variables.
Click (and hold, if you like,) to set the target position.
If you're just interested in the API, you can grab it here:
[hidden]
local Sod = {} Sod.__index = Sod function Sod:update(dt) local target_vel = (self.target-self.prev_target)/dt self.pos += self.vel*dt self.vel += ( self.target +self.k3*target_vel -self.pos -self.k1*self.vel )*dt/self.k2 self.prev_target = self.target end function Sod:config(frequency_rads,damping,response) local ifreq = 1/frequency_rads self.k1,self.k2,self.k3 = damping*ifreq*2, ifreq*ifreq, response*damping*ifreq end function sod(pos,frequency_rads,damping,response) local o = { pos = pos, prev_target = pos, target = pos, -- In case pos is a vector, or any other arithmetically capable data -- type, *0 guarantees we get the zero position of whatever type pos is. vel = pos*0, } setmetatable(o,Sod) o:config(frequency_rads,damping,response) return o end |
A clone of The Sound of Sorting I made just to test and diagnose my QuickSort algorithm.
It may sound a little ridiculous on web, since the array access sounds tend to get lumped together into far fewer frames.
- Press z to step
- Hold z to disable step mode
- Press x to switch sorting algorithm
- Use up and down to control the number of entries.
- Use left and right to control the speed.



The response to this has been pretty positive, so I'm throwing this demo up here on the forums.
This cart is a prototype for a point and click adventure with pre-rendered 3D graphics and a custom palette.
Included in this cart are elgopher's require module and snowkittykira's error explorer module







I made it as easy to use and as performant as I could. You certainly won't be getting the performance boost normally associated with an ECS, since that particular optimization doesn't exist in picotron, but you'll still get the architecture.
Here's a demo which showcases its use.
You can find the latest version and the documentation on github.
https://github.com/abledbody/picotron-ECS-framework/releases/
https://github.com/abledbody/picotron-ECS-framework/blob/main/README.md

Does what it says on the tin. Lets you see what's eating up your CPU time. If you make an extension to this, I'd love to see it.
API:
profile.enabled(detailed,cpu)
Turns on and off profiling tools.
detailed
: Whether or not to display results of profile
calls.
cpu
: Whether or not to display total CPU usage.
profile(name,linger)
Starts or stops a profile. Accumulates between profile.draw
calls. Extremely cheap when profiling is disabled.
name
: Arbitrary display name indicating which profile to start or stop.
linger
: Whether or not the profile should linger even if the profile is never called between draws.
profile.draw()
Draws profile and CPU information to the screen if they are enabled. Extremely cheap when profiling is disabled.
profile.clear_lingers()
Clears any lingering profile information.
Example:
include("profiler.lua") profile.enabled(true,true) local frames = 0 function _update() profile("_update") [ [size=16][color=#ffaabb] [ Continue Reading.. ] [/color][/size] ](/bbs/?pid=146421#p) |