Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
Valone
|
  |
| Joined: 08 Feb 2012 |
| Total Posts: 4371 |
|
|
| 09 Apr 2012 02:10 PM |
This is motion interpolation, no? I'd personally, for the same reasons use the second one, the first is a little unclear on quite how it works. But the second one I understand. |
|
|
| Report Abuse |
|
|
NXTBoy
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 4533 |
|
|
| 09 Apr 2012 03:33 PM |
You can simplify `getUpVector`:
function getUpVector(frame) return frame:vectorToWorldSpace(Vector3.new(0, 1, 0)) end
Also, `getRotation` looks suspiciously like an implementation of `CFrame.ToEulerAngles()`... |
|
|
| Report Abuse |
|
|
NXTBoy
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 4533 |
|
|
| 09 Apr 2012 03:35 PM |
And I'm pretty sure that:
CFrame.Angles(0, cy, 0) * CFrame.Angles(cx, 0, 0) * CFrame.Angles(0, 0, cz)
Is the definition of:
CFrame.Angles(cx, cy, cz)
The rotations are applied in the order YXZ, not in argument order. |
|
|
| Report Abuse |
|
|
manatee20
|
  |
| Joined: 07 Apr 2010 |
| Total Posts: 111 |
|
| |
|
|
| 10 Apr 2012 07:51 AM |
But oyusi, i think using angles has the problem that it will not go the straightest path on the surface of the magical rotation sphere.
Slerp fixes that.
What we should use, is quaternions, but having tried to learn them i dont think we are awesome enough to figure out how they work. They would go the straightest path (i believe....) and at a constant speed (if we use slerp or something)
Maybe we can just copypasta c++ code and translate to lua and add trigonometry until it works. |
|
|
| Report Abuse |
|
|
Valone
|
  |
| Joined: 08 Feb 2012 |
| Total Posts: 4371 |
|
|
| 10 Apr 2012 09:11 AM |
My code can position them perfectly, but just not rotate :/ @Radio, not quite sure if that's what you meant, but maybe it'd help.
☜▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬☜☆☞▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬☞ -Valone 32nd Empress of Unit 32. Join; http://www.roblox.com/My/Groups.aspx?gid=520434 |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2012 09:27 AM |
It meant that using euler angles will make the cframe rotate at a constant rate, and will work properly for a rotation around a single axis, but i think if the rotation is more complex, it will not rotate it in a straight line (and i think not even at constant velocity anymore)
Or did it rotate in a straight line... cant remember... |
|
|
| Report Abuse |
|
|
Valone
|
  |
| Joined: 08 Feb 2012 |
| Total Posts: 4371 |
|
|
| 10 Apr 2012 09:29 AM |
Ahaa, yes, this is what I produced, makes sense now.
function moveBetweenPoint(A,B) Frames = 30 local x0, y0, z0 = A:toEulerAnglesXYZ() local x1, y1, z1 = B:toEulerAnglesXYZ() local X, Y, Z = -(A.p.X-B.p.X)/Frames, -(A.p.Y-B.p.Y)/Frames, -(A.p.Z-B.p.Z)/Frames local CX, CY, CZ = -(x0-x1)/Frames, -(y0-y1)/Frames, -(z0-z1)/Frames for i = 1,Frames do Fram = CFrame.fromEulerAnglesXYZ(CX*i,CY*i,CZ*i) Vec = Vector3.new(X*i,Y*i,Z*i) Cam.CoordinateFrame = A*Fram+Vec Cam:SetRoll(math.abs(CZ*i)) wait() end end
Cam = game.Workspace.CurrentCamera
function runScene(Track) Cam.CameraType = Enum.CameraType.Scriptable for i = 1,#Track:GetChildren()-1 do moveBetweenPoint(Track[tostring(i)].CFrame,Track[tostring(i+1)].CFrame) end Cam.CameraType = Enum.CameraType.Custom end
runScene(game.Workspace.TrackB)
Perfect rotation upon the Y, but not the X and Z.
☜▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬☜☆☞▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬☞ -Valone 32nd Empress of Unit 32. Join; http://www.roblox.com/My/Groups.aspx?gid=520434 |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2012 09:46 AM |
| Though that could be just because the values toEulerAngles gives you might be weird like -180,180,0 because theres multiple ways to represent a rotation. So you cant really trust it. Thats why you use vectors. |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2012 09:47 AM |
Oh wow, thanks oysi! I really wanted a weld-rotation interpolation... as I have no idea of trigonometry. I only have a position interpolation, but not a rotation one.
"Knowledge talks, wisdom listens." |
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|