i’ve searched through some documentation, but i can’t necessarily find anything to assist me. this is kind of what i am looking for.
*a function that takes a model, gets its min and max position in world space, and then spits out a region that represents that
if anybody could give me a prod in the right direction, that would be very helpful. thank you for your time
*dont mind my amazing writing skills with the mouse
Katrist
(Katrist)
January 7, 2024, 11:02pm
#2
thanks for your reply! the problem with boundingbox and extentssize is that it returns something like this
when i am looking for a function that can do this
Katrist
(Katrist)
January 7, 2024, 11:35pm
#4
Do you need to find that area for a model or just a part?
it isn’t exactly the area/volume. i’m looking for how to make a region based off of the min position and max position of the model but on the world axis. to answer your question, my code needs to support a model
i’m sorry if my explanations are a little hard to understand. try to look at my reference pictures
Katrist
(Katrist)
January 7, 2024, 11:44pm
#7
Get the position of every corner in your model, and put it into a table.
Then find the lowest position, the highest position, the most north position, etc to generate height, width, and length.
You can position the part in the middle of the model, and size it accordingly with the values you generated.
ahh, that seems a tiny bit expensive, though. this function is meant to be run every frame at some times. i guess i could try doing it outside of a table. i’ll tell you how it turns out.
Katrist
(Katrist)
January 7, 2024, 11:47pm
#9
There’s a lot of optimizations you can do by only searching parts the furthest from the center for example.
Not expensive at all unless you’re doing it for many parts, which would just be bad design. Its all super simple operations, cpu’s chew through them at a lightning rate.
Heres some implementations you can work off of
Solutions that just add the size fail to account for cases where the part is rotated. I think the best solution is to use the part’s bounding box.
function PartToRegion3(part)
local abs = math.abs
local cf = obj.CFrame -- this causes a LuaBridge invocation + heap allocation to create CFrame object - expensive! - but no way around it. we need the cframe
local size = obj.Size -- this causes a LuaBridge invocation + heap allocation to create Vector3 object - expensive! - but no way around it
…
2 Likes
system
(system)
Closed
January 22, 2024, 7:52am
#12
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.