@Simeon Is there a reason why the m.model.positions file doesn’t contain all the position values. Here’s an example showing the positions (white spheres) that make up the Capsule model using m.model.positions. There are just a few white spheres at the top and bottom of the Capsule. If you tap on the drawObj parameter, the obj file is read and all the positions are shown for the Capsule.
viewer.mode=STANDARD
function setup()
assert(OrbitViewer, "Please include Cameras as a dependency")
parameter.action("drawObj",drawObj)
scene = craft.scene()
m = scene:entity()
m.model = craft.model(asset.builtin.Primitives.Capsule)
m.material = craft.material(asset.builtin.Materials.Standard)
m.material.map = readImage(asset.builtin.Blocks.Wood_Red)
v = scene.camera:add(OrbitViewer, vec3(0,0,0), 5, 0, 2000)
v.rx=60
msg="vertices drawn (white spheres) using model positions file"
for a,b in pairs(m.model.positions) do
createSphere(b,.01)
end
fill(255)
end
function update(dt)
scene:update(dt)
end
function draw()
update(DeltaTime)
scene:draw()
text(msg,WIDTH/2,HEIGHT-100)
end
function drawObj()
str=readText(asset.builtin.Primitives.Capsule)
for a,b,c in string.gmatch(str,"v (%g+) (%g+) (%g+)") do
createSphere(vec3(a,b,c),.01)
end
msg="vertices drawn (white spheres) using model obj file"
end
function createSphere(p,s)
local pt=scene:entity()
pt.position=p
pt.model = craft.model.icosphere(s,2)
pt.material = craft.material(asset.builtin.Materials.Specular)
pt.material.diffuse=color(255)
end