Skip to content

Instantly share code, notes, and snippets.

@rpavlik
Last active December 27, 2015 04:39
Show Gist options
  • Save rpavlik/7268361 to your computer and use it in GitHub Desktop.
Save rpavlik/7268361 to your computer and use it in GitHub Desktop.
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 parent = osg.PositionAttitudeTransform
return Transform{
position = -bound:center();
m
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment