Jammer622
|
  |
| Joined: 19 Nov 2008 |
| Total Posts: 1739 |
|
|
| 20 Jun 2015 08:17 PM |
Anyone know a good way to find the approximate XYZ or just XZ size of a model? It's tough having to program separate, similar lines of code each time I'm working with a smaller or bigger model. x.x
If possible, I'd like a quick method. Something like walls that move outward and returning distances could work, but that's a line-expensive method that may take time. |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2015 08:21 PM |
| print(workspace.Model:GetExtentsSize()) |
|
|
| Report Abuse |
|
|
Jammer622
|
  |
| Joined: 19 Nov 2008 |
| Total Posts: 1739 |
|
|
| 20 Jun 2015 08:23 PM |
Wait a second THAT'S A THING? THAT'S A LEGITIMATE THING I CAN DO?
Somebody punch me. |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2015 08:24 PM |
*punches*
Lol yes, it's a thing. |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2015 08:26 PM |
There's also:
model:SetPrimaryPartCFrame() (equivalent to setting the CFrame of the primary part and then moving the rest of the model with it) model:GetPrimaryPartCFrame() (equivalent to model.PrimaryPart.CFrame)
model:GetModelCFrame() (incorrectly deprecated, as there is no replacement for it) model:GetModelSize() (same as GetExtentsSize() (I think), but I prefer this naming convention) |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2015 08:29 PM |
Here:
void BreakJoints ( ) Breaks any surface connection with any adjacent part, including Welds and other JointInstances. Vector3 GetExtentsSize ( ) Returns the size of the smallest bounding box that contains all of the Parts in the Model. CoordinateFrame GetPrimaryPartCFrame ( ) Returns the CFrame of the Model's PrimaryPart. void MakeJoints ( ) Goes through all parts contained in the Model. If any part's side has a SurfaceType that can make a joint it will create a joint. void MoveTo ( Vector3 position ) Moves the center of the PrimaryPart to the given position. void SetPrimaryPartCFrame ( CoordinateFrame cframe ) Sets the CFrame of the PrimaryPart. All other parts in the model will also be moved and will maintain their orientation and offset respective to the PrimaryPart. void TranslateBy ( Vector3 delta ) Shifts a model using a given offset.
@above
GetModelCFrame and GetModelSize are both deprecated, neither incorrectly. GetModelCFrame is no longer required because that's what PrimaryPart is supposed to be used for, and GetModelSize is replaced by GetExtentsSize |
|
|
| Report Abuse |
|
|
Jammer622
|
  |
| Joined: 19 Nov 2008 |
| Total Posts: 1739 |
|
|
| 20 Jun 2015 08:35 PM |
| This is going to be used for moving objects, so does the GetExtentsSize also account for the rotation of the object? |
|
|
| Report Abuse |
|
|
Jammer622
|
  |
| Joined: 19 Nov 2008 |
| Total Posts: 1739 |
|
|
| 20 Jun 2015 08:37 PM |
| On top of that, is there a way to see how far a certain piece is from each side? |
|
|
| Report Abuse |
|
|
| |
|
|
| 20 Jun 2015 08:40 PM |
"GetModelSize is replaced by GetExtentsSize" GetModelSize is not deprecated incorrectly. I just prefer "GetModelSize" because the keys required to type it are closer to my fingers, it's less characters, and it's unrelated to PrimaryPartCFrame so I don't even know why they changed the name.
"neither incorrectly. GetModelCFrame is no longer required because that's what PrimaryPart is supposed to be used for"
Tell me how I can create a selection box over a model without :GetModelCFrame(). Tell me how I'm supposed to shift a model in one direction by its own size (i.e. if the model is sized <2,2,4> and I want to shift it in the positive Z direction it shifts 4 studs backwards) without using :GetModelCFrame() Tell me how I'm supposed to check if a model intersects with a wall without :GetModelCFrame()
The only way is to manually loop through all the parts, keeping track of their maximum and minimum X,Y, and Z coordinates and then determining the CFrame from those results which is not only ugly but also slower than :GetModelCFrame() which is executed C side. There was no reason to deprecate :GetModelCFrame().
|
|
|
| Report Abuse |
|
|
Jammer622
|
  |
| Joined: 19 Nov 2008 |
| Total Posts: 1739 |
|
|
| 20 Jun 2015 08:42 PM |
| So basically it's back to the wall method. Then I'd be able to tell the distance a vehicleseat is from the front and back of a car.. |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2015 08:44 PM |
| You can set a sBox's adornee to a model..... |
|
|
| Report Abuse |
|
|
| |
|
|
| 20 Jun 2015 08:46 PM |
"You can set a sBox's adornee to a model....." Alright, create a bounding box out of parts around a model******* |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2015 08:47 PM |
| And you still haven't addressed the other two. |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2015 08:47 PM |
@Echo
Why do that when i can do:
local model = workspace.Model
Instance.new("SelectionBox",model).Adornee = model |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2015 08:49 PM |
"Tell me how I'm supposed to shift a model in one direction by its own size"
I'm not even sure what you meant by that XD
As for intersecting with a wall, you can't do that with GetModelCFrame either? You'd have to iterate through every wall possible wouldn't you? |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2015 08:51 PM |
And what happens when you don't want it to look like the default selection box? What happens when you want to create a selection box like this?
http://www.roblox.com/SelectionBoxCustom-item?id=260841831 |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2015 08:53 PM |
| You would use GetExtentsSize lol |
|
|
| Report Abuse |
|
|
| |
|
|
| 20 Jun 2015 08:55 PM |
"As for intersecting with a wall, you can't do that with GetModelCFrame either? You'd have to iterate through every wall possible wouldn't you?"
Dude. Once you have a list of the surrounding walls gathered using Region3, you have to check if the model is intersecting any of them. You can't check if they're intersecting if you don't know the model's CFrame. With only size you can't tell if the model is on top of the wall, in the wall, or 999 studs away from the wall.
"I'm not even sure what you meant by that XD" I have a model sized <2,2,4>. I want to shift the model by its own size. In this case I want to shift it in the Z direction by its own size. I move it 4 studs. If it were <2,2,9>, I'd move it 9 studs. If I wanted to shift <6,2,1> in the X direction, I would shift it 6 studs on the X axis. |
|
|
| Report Abuse |
|
|
Jammer622
|
  |
| Joined: 19 Nov 2008 |
| Total Posts: 1739 |
|
|
| 20 Jun 2015 08:55 PM |
Why are you guys rambling about selectionboxes .-. Would those even help with finding the center positions of each side of a model? |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2015 08:56 PM |
"You would use GetExtentsSize lol"
You two...
That gets the size of the model. Where do you place the selection lines though? Do you place them at <0,0,0>? At <20,50,10>? At <30,20,10>? You need the CFrame of the model in order to know where to place them. |
|
|
| Report Abuse |
|
|
Jammer622
|
  |
| Joined: 19 Nov 2008 |
| Total Posts: 1739 |
|
|
| 20 Jun 2015 08:56 PM |
| I just realized my wall method won't work if the model is directly next to any other non-flat surface. i cri. |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2015 08:57 PM |
| You would use the GetPrimaryPartCFrame (assuming you're using PrimaryPart correctly) and GetExtentsSize |
|
|
| Report Abuse |
|
|