When I rotate a model using a Dragger object, I would like it to also update the model’s CFrame so that its size corresponds to its orientation when I draw a box around it.
repro:
When I rotate a model using a Dragger object, I would like it to also update the model’s CFrame so that its size corresponds to its orientation when I draw a box around it.
repro:
GetModelCFrame is deprecated. Therefore I would not expect there will be any fix for this.
How the hell are you supposed to draw a bounding box around the Model then?
How the hell are you supposed to draw a bounding box around the Model then?[/quote]
It’s outrageous. We’ve never been able to get an answer as to why it was deprecated. I’ve already clarified that PrimaryPart is not a replacement, and there’s nothing else that comes even close to replacing it.
You can’t get the bounding box of a model without using GetModelSize and GetModelCFrame.
Actually I’m pretty sure GetExtentsSize is the same thing as GetModelSize.
You could go through the corners of each part and find the min/max for each dimension
You could go through the corners of each part and find the min/max for each dimension[/quote]
Yes, but compare:
function getModelCenter(model)
local function recurse(root,callback)
for i,v in pairs(root:GetChildren()) do
callback(i,v)
if #v:GetChildren() > 0 then
recurse(v,callback)
end
end
end
local minX,maxX,minY,maxY,minZ,maxZ
recurse(model, function(_,v)
if v:IsA("BasePart") then
if not minX then
minX = math.min(v.CFrame * v.Size.X/2, v.CFrame * -v.Size.X/2)
maxX = math.max(v.CFrame * v.Size.X/2, v.CFrame * -v.Size.X/2)
minY = math.min(v.CFrame * v.Size.Y/2, v.CFrame * -v.Size.Y/2)
maxY = math.max(v.CFrame * v.Size.Y/2, v.CFrame * -v.Size.Y/2)
minZ = math.min(v.CFrame * v.Size.Z/2, v.CFrame * -v.Size.Z/2)
maxZ = math.max(v.CFrame * v.Size.Z/2, v.CFrame * -v.Size.Z/2)
else
minX = math.min(minX, v.CFrame * v.Size.X/2, v.CFrame * -v.Size.X/2)
maxX = math.max(maxX, v.CFrame * v.Size.X/2, v.CFrame * -v.Size.X/2)
minY = math.min(minY, v.CFrame * v.Size.Y/2, v.CFrame * -v.Size.Y/2)
maxY = math.max(maxY, v.CFrame * v.Size.Y/2, v.CFrame * -v.Size.Y/2)
minZ = math.min(minZ, v.CFrame * v.Size.Z/2, v.CFrame * -v.Size.Z/2)
maxZ = math.max(maxZ, v.CFrame * v.Size.Z/2, v.CFrame * -v.Size.Z/2)
end
end
end)
return Vector3.new((minX+maxX)/2, (minY+maxY)/2, (minZ+maxZ)/2)
end
local center = getModelCenter(workspace.Model)
with
local center = workspace.Model:GetModelCFrame()
The getModelCenter code above doesn’t even take into account rotation – that’d be a whole different ballgame. You’d have to find the alignment most parts are pointing towards, and that’d take a lot of work. GetModelCFrame does it all for you in one predefined function.
You could go through the corners of each part and find the min/max for each dimension[/quote]
what about unions