Okay, this question is more of a request for ideas on equations etc. that will basically rotate a frame into perspective, e.g:
http://prntscr.com/bdaje7
to this:
http://prntscr.com/bdajho
(this is in PS, but you get the idea)
My only idea for this to set/tween the size and position in some way as well as the rotation. I attempted it, but it didn't work very well.
Here is my code if you want it (although it's not very important):
01 | wait( 1 ) |
02 | local f = script.Parent.Frame |
03 | local num = 80 |
04 | local num 2 = . 25 |
05 | local t = 0.025 |
06 | local pos = UDim 2. new( 0 ,(num*t)* 5 , 0 ,(num*t)* 8 ) |
07 |
08 | print (num*t) |
09 |
10 | f:TweenSizeAndPosition(f.Size - UDim 2. new( 0 , 0 , 0 ,(num*t)* 10 ),f.Position-pos, "InOut" , "Quad" ,num*t, true ) |
11 | for i = 1 ,num do |
12 | f.Rotation = f.Rotation + num 2 |
13 | wait(t) |
14 | end |
Thank you! Any help with this would be greatly useful!
~TDP
This is a fun question because there are quite a few possible answers! There are two ways I can think of off the top of my head.
The first is to use a lot of vertical frames and math to scale them based on the perspective/depth etc. I personally wouldn't use this method because it would require me to do more work than I have to.
The second way, which is what I'll give an example of, is to simply triangulate your shape and draw it with triangles. I used this module to triangulate and this article to draw 2D triangles. I then used WorldToScreenPoint to get the corners of one of the surfaces on the shape just for ease of testing/showing how it works.
01 | local camera = game.Workspace.CurrentCamera; |
02 | local screen = script.Parent; -- screengui |
03 | local cleanup = screen:WaitForChild( "cleanup" ); -- something we can put the drawn triangles in and clear the next frame |
04 |
05 | local triangle = require(script:WaitForChild( "triangle" )); -- for drawing 2D triangles |
06 | local delaunay = require(script:WaitForChild( "delaunay" )); -- for 2D trianglation |
07 |
08 | function get 2 DPoints(part) |
09 | local points = { } ; |
10 | for x = - 1 , 1 , 2 do |
11 | for y = - 1 , 1 , 2 do |
12 | local p 3 = (part.CFrame * CFrame.new(part.Size/ 2 * Vector 3. new(x, y, 1 ))).p; |
13 | local p 2 = camera:WorldToScreenPoint(p 3 ); |
14 | table.insert(points, p 2 ); |
15 | end ; |