Sign in to follow this  
Forenkazan

how can i animate a flipping cube ?

Recommended Posts

Hello 

 

i want to animate a cube that flip, like the one on Bloxorz mini game

 

but i dont want 2.5D. i want to Top-down version biggrin.png

 

so the first and the last frames are  normal square 

 

but i dont know what should i do between them sad.png

 

i Attached my animated cube 15 frames (First 7frames = the last 7 Frames but the opposite direction ^^ ) biggrin.png

 

 tell me if you need the frames :)

 

any tips or help ? smile.png

 

 

Thank you very much ^^

Edited by Forenkazan

Share this post


Link to post
Share on other sites

Hi.

There are some improvements to be made. A cube rotating when being looked at from above doesn't vary in vertical span, only in horizontal span.

Yours is not quite doing that: it has some vertical variation, which it shouldn't, and it's not varying enough horizontally. You need to fix that.

 

To know how much the cube needs to grow horizontally, read on.

Consider a "unit" cube (a cube with edges of length 1). When this unit cube is rotated half way, it has an exact ?2 horizontal span. This is given from its diagonal, which becomes aligned to the ground.

Since you want your cube to have a specific edge length (say, 150px), the middle frame would have a cube of horizontal span of ?2 x 150px = 212px. So from the start to the middle frames, you're simply interpolating a shape that grows from the first frame (150 x 150) to the middle frame (212 x 150), and then back again to the end frame (150 x 150).

Notice that for any frame the height doesn't vary at all.

 

 

2i7oi0n.png

 

 

 

 

2vuj7go.png

Edited by Kryzon

Share this post


Link to post
Share on other sites

Thank you very much ^^

 

but what should i do for the angles

 

i mean the first square has 90 degree angle and the mid must have something like 45o degree, is that right ?

 

another question :D why is it ?2 

Edited by Forenkazan

Share this post


Link to post
Share on other sites

another question why is it ?2 

Because of the Pythagorean Theorem. When you have a square of sides measuring 1, the diagonal of that square measures ?2.

A cube is made up of 6 squares, so the same relation is carried. The only difference is that instead of sides of length 1, you want sides of a certain length in pixels. You multiply that pixel length by ?2 to get the actual size of the diagonal in pixels. 

 

When the cube is in its middle frame (exactly at a 45º rotation), the diagonal of its side faces is aligned to the ground. That's precisely its entire horizontal span when looked at from above, so you know the biggest horizontal frame size you need is that.

This is what happens when you look at it from the side (not from above like you want), just to illustrate:

 

bhi1c6.png

 

 

Just, instead of the above values of (1) and (?2), in your actual animation it'll be (side_length_in_pixels) and (side_length_in_pixels * ?2), respectively. 

 


Also it would be slightly less than the square root of 2 of you were to be true to perspective.

Good point, I forgot to mention that I was referring to an orthogonal projection, so that's why it's exactly Sqr(2).

I would also animate it in 3D like you did - let the software do the interpolation and lighting, you just worry about animation.

Edited by Kryzon

Share this post


Link to post
Share on other sites

If you are looking for a outlined look like you attached to your first post then you can download the gif I posted, open it Gimp and trace the lines on each frame, delete the layers from my gif, and export the whole thing as a gif and BAM! you got it!

Share this post


Link to post
Share on other sites

i dont think i understood all of that sad.png sorry

 

can you tell me how the middle frame should look ? (length, angles)

 

Kryzon has explained it to you in detail and I don't think he could walk you through perspective drawing in any more detail than he has. Many, many kudos to Kryzon for his patience! :)

 

Chances are you will need to study perspective drawing theory if you want to make the game anything more than 2D (and even then it wouldn't hurt). Even using Blender does require you to understand what you see, ie. how you should position the camera for different rendering results to match in the final game. I recommend you look into it some more, you have been presented a good amount of resources.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this