Descriptions and Examples for the POV-Ray Raytracer by Friedrich A. Lohmüller
    3D Animations with POV-Ray
        Some basics and examples on animations.
Italiano Italiano
Français français
Deutsch Deutsch
- 3D Animations Gallery
- POV-Ray Tutorial

  3D Animation Tutorial
   Index of Content
  0. Basic Knowledge
     1. Basic Example
     2. From Images to Video
     3. Basic Terms
     4. Animation Commands  
  I. Cyclic Animations
     1. Rotating Objects
     1.2. Planets in Orbit
     1.3. Clock Animation
     2. Rotating Camera
     2.1. Straight Moving Camera
     3. Western Wheel
     3.1. Rolling Wheels
     4. Gears
     4.1. Roller Chain
     4.2. Bike Chain
     5. Swinging Pendulum
     5.1. Newton's Cradle
     5.2: Rock the Rocker
     6. Spiral Pendulum
     7. Coupling Rods
     7.1. Connecting Rods
     8. Psychedelic + Op-Art
     9. Counters + Countdowns
  >10. Folding of a Cube
  II. Non-linear Movements
     1.0 Speed Up/Slow Down 1
     1.1 Speed Up/Slow Down 2
     2. Fall + Bounce
     3. Acceleration by
          physical Formulas
     4. Speed Controll by
          Spline Functions
  III. Animation Paths
      with Spline Curves
     1. Spline Curves
     2. Closed Splines
     3. Animation Paths

The Folding
of a Cube Net
How to animate the folding of geometric objects.

How to fold of a cube?
A cube consists of 6 squares folded against its neighbor square by 90°.
So we start by declaring a 'Square' object.
(First declare the according textures as you like it!)
// -------------------- dimensions
#declare D = 0.00001;
#declare S = 1;
#declare Rl = 0.02;// "edge" radius
#declare Rp = 0.04;//"point" radius
// ------------------------- square
// Quadrat, quadrato, carré
#declare Square =
 // the corners
  sphere{ <0,0,0>, Rp }
  sphere{ <S,0,0>, Rp }
  sphere{ <S,0,S>, Rp }
  sphere{ <0,0,S>, Rp }
  texture{ Corner_Texture } }
 // the edges
  cylinder{ <0,0,0>,<S,0,0>, Rl }
  cylinder{ <S,0,0>,<S,0,S>, Rl }
  cylinder{ <0,0,S>,<S,0,S>, Rl }
  cylinder{ <0,0,0>,<0,0,S>, Rl }
  texture{ Edge_Texture } }
 // the face
 box{ <0,-D,0>,<1,D,1>
  texture{ Face_Texture }}
} // end of union ------------------

Folding of a Cube
A square for folding of a Cube

Cube Net
A net of a cube

Building a chain of squares:
For folding a cube net (like here above right)
we have to make a chain of the squares A,B,C and D by nested unions.
We need to remember that rotation by 'rotate' always turns around the axes!
So we first have to apply the rotation and then the translation as shown in the image here right with the first two squares A and B.
Note: 'rotation around an axis' and 'translation' commonly are not commutative or not interchangeable, that means: We cannot change the sequence arbitrary!

Here how to animate the folding:
To achieve a smooth starting and ending movement we use the following macro:
#macro Cos_010( X ) //-----
#end //--------------------
#declare Fold_Angle =

The assembling of the cube components:
union{ // A + B + C
  object{ Square } // C ------
  union{ // A + B
     object{ Square } // B ------
     object{ Square   // A ------
           } //--------------
  } // end A + B
} // end A + B + C

object{ Square } // D ------
object{ Square   // E ------
      } //------------------
object{ Square   // F ------
      } //------------------

Folding a cube: rotate, move, add next!

The macro 'Cos_010(...)'
Folding a cube
Scene descriptions for POV-Ray:
"Folding_a_Cube_2.ini" and
For other examples for folding a regular polyhedron see:
Elementary Geometry for Raytracing or: 3D-Animations - Geometry

© Friedrich A. Lohmüller, 2010
email email: