Skip to content

Instantly share code, notes, and snippets.

View lpberg's full-sized avatar

Leif Berg lpberg

View GitHub Profile
@rpavlik
rpavlik / CenteredModel.lua
Last active December 27, 2015 04:39
Load a model and translate the center of its bounding sphere to the origin
function NodeLocationAndSize(node)
local bound = node:getBound()
print("Position:", bound:center())
print("Bounding sphere radius:", bound:radius())
end
function CenteredModel(name)
local m = Model(name)
NodeLocationAndSize(m)
local bound = m:getBound()
local getRoomToWorld = function()
return RelativeTo.World:getInverseMatrix()
end
--- This is a HIDEOUS HACK @todo
local matrixMult = function(a, b)
local val = osg.Matrixd(a)
val:preMult(b)
return val