generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Pivotal CFrame

Previous Thread :: Next Thread 
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
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 is not online. 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
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
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 is not online. 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
PsudeoPlayer is not online. PsudeoPlayer
Joined: 19 Jul 2013
Total Posts: 306
29 Jan 2014 02:03 PM
Can I call a camera rotating around a part a pivotal CFrame? :P
Report Abuse
Oysi is not online. 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 is not online. 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 is not online. suremark
Joined: 13 Nov 2007
Total Posts: 6315
29 Jan 2014 05:02 PM
*was appropriate (not 'were')
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image