|
| 29 Jan 2014 10:25 AM |
No-one seemed to know the answer around SH, so you guys are my last resort.
For such a simple object, a simple one brick door.
How can I rotate it by its "corner" and not the center like it rotates regularly? D: |
|
|
| Report Abuse |
|
|
TaaRt
|
  |
| Joined: 26 Apr 2009 |
| Total Posts: 5039 |
|
|
| 29 Jan 2014 10:32 AM |
Answer is in the replies;
http://www.roblox.com/Forum/ShowPost.aspx?PostID=124126824 |
|
|
| Report Abuse |
|
|
|
| 29 Jan 2014 10:34 AM |
I found this, and I can see how to set the "pivot", but how do I actually rotate it from that?
cf = CFrame.new(1, 2, 3) -- CFrame at (1, 2, 3); this is our "pivot" part = Workspace.Part
rx, ry, rz = math.pi/2, math.pi/2, math.pi/3
part.CFrame = (cf * CFrame.Angles(rx, ry, rz)):toWorldSpace(cf:toObjectSpace(part.CFrame)) |
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
|
| 29 Jan 2014 02:00 PM |
Simple. You translate to the point, rotate, and translate back.
local off = part.Size * Vector3.new(1, 1, 1)/2
part.CFrame = part.CFrame * CFrame.new(off) * CFrame.Angles(0.1, 0.1, 0.1) * CFrame.new(-off)
Note that because (a*b)*c = a*(b*c) with matrices, you can do something to slightly speed up your program, but also potentially make it cleaner:
local off = part.Size * Vector3.new(1, 1, 1)/2 local frame = CFrame.new(off) * CFrame.Angles(0.1, 0.1, 0.1) * CFrame.new(-off)
for i = 1, 100 do part.CFrame = part.CFrame * frame wait(1/30) end |
|
|
| Report Abuse |
|
|
|
| 29 Jan 2014 02:03 PM |
Can I call a camera rotating around a part a pivotal CFrame? :P
|
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
|
| 29 Jan 2014 02:20 PM |
Also, just for the sake of it. This:
(cf * CFrame.Angles(rx, ry, rz)):toWorldSpace(cf:toObjectSpace(part.CFrame))
First I'll just simplify the variables a bit, and then simplify the functions:
(cf * rot):toWorldSpace(cf:toObjectSpace(part))
cf * rot * cf:toObjectSpace(part)
cf * rot * cf:inverse() * part
Is wrong, but almost the same as what I did. To make it correct, you simply put the part in the front, so it translates and rotates from there, as opposed to translating from the center of the world, and then rotating from that (Essentially right now it will rotate around somewhere in the center of the world). =/
part * cf * rot * cf:inverse()
Now, cf is what I used as 'off', but as a CFrame. See:
CFrame.new(Vector3) = CFrame.new(-Vector3):inverse() |
|
|
| Report Abuse |
|
|
suremark
|
  |
| Joined: 13 Nov 2007 |
| Total Posts: 6315 |
|
|
| 29 Jan 2014 05:02 PM |
| Oysi, the difference is you're rotating around a point in object space. The fellow in the other thread was rotating a part around another part, so in his case using world space coordinates were appropriate. |
|
|
| Report Abuse |
|
|
suremark
|
  |
| Joined: 13 Nov 2007 |
| Total Posts: 6315 |
|
|
| 29 Jan 2014 05:02 PM |
| *was appropriate (not 'were') |
|
|
| Report Abuse |
|
|