WOLFRAM

Animating Surfaces in the Wolfram Language Bringing Geometric Design to Life

Animating Surfaces in the Wolfram Language: Bringing Geometric Design to Life

Around the beginning of the first COVID-19-related lockdown in Austria, I was confronted with the problem of keeping my motivation up. From 2012–2016, my main tool for creating several Wolfram Demonstrations in 3D was Mathematica. Now, in addition to the Wolfram Language, Blender offered the possibility for physically based rendering (PBR) and high dynamic range (HDR) lighting and rendering. So I decided to go forward with 4K videos from animations done in Blender.

As a starting point, any formalized description or image of a curve or surface could fuel my inspiration.

The first stop for testing my ideas was Mathematica. Blender was used to animate objects and to deliver interesting renderings for the final video. A guideline for me was not to be fixated on a prepared path. Instead, similar to water, I decided to allow ideas to flow toward a goal and to accept an open end.

Engage with the code in this post by downloading the Wolfram Notebook
&#10005

Video["ExampleData/Caminandes.mp4"]

Process

The following six examples use parts of the animations Structures and Connected. In the subsequent sections, problems are solved in the Wolfram Language and can be done in Blender using the mini-tutorials. The examples show important pieces of the process, from creating curves to making animations:

  1. Curve & Export I
  2. Curve & Export II
  3. Import & Beveling
  4. Extruding & Animation
  5. Material & Color
  6. Animation

Example 1: Curve & Export I

The number-one format in this project for exporting curves from the Wolfram Language to Blender was DXF.

The folder animating-surfaces-in-the-wolfram-language was used to export and import or open files for this project (download this zip folder for all the necessary files to experiment with the code in this post):

The closed curve implemented and plotted here was a starting point for the animation Structures. Here too it’s used more than once:

r = Cos
&#10005


The curve was exported in a DXF file:

Export
&#10005


Example 2: Curve & Export II

Each path in the animation Connected was given a profile. The profile curves were extracted via natural language input:

hypocycloid
&#10005


pcd = PlaneCurveData
&#10005


hypo = pcd
&#10005


Table
&#10005


hlist = Table
&#10005


Here, the first of the profiles was exported to minimize clutter:

Table
&#10005


Example 3: Import & Beveling

Let’s experiment with giving a curve a profile in Blender by giving the curve closed1.dxf the profile from curve hypo1.dxf.

Step 1: Open Blender.

Step 2: Select the cube by clicking it:

Blender start screen
&#10005


Step 3: Remove the cube by pressing the X key and clicking Delete in the dialog box:

Remove the cube
&#10005


Step 4: Import the curve closed1.dxf by selecting File/Import/AutoCAD DXF, navigating to the data folder and choosing closed1.dxf for import:

Import the curve
&#10005


Step 5: Select the curve by clicking it in the viewport/camera view.

Step 6: Select the symbol for object settings from the vertical Properties palette.

Step 7: Change the name of the curve from the current (temporary) name to curve:

Change the name of the curve
&#10005


Step 8: Import the profile hypo1.dxf.

Step 9: Select the profile by clicking it in the viewport/camera view.

Step 10: Select the symbol for object settings from the vertical Properties palette.

Step 11: Change the name for the profile from the current (temporary) name to profile:

Change the name of the profile
&#10005


Step 12: Select the Transform properties symbol and scale the profile by 0.1 for x, y and z:

Scale the profile
&#10005


Step 13: Select the first curve, not the profile:

Select the curve
&#10005


Step 14: Select the curve properties symbol, open the Geometry properties and scroll, if necessary, to the Bevel section:

Open Geometry properties
&#10005


Step 15: Choose Object in the Bevel properties, then click within the black field beneath Object. Select the profile curve in the dialog box. The beveled curve should look like this:

Choose Object in Bevel properties
&#10005


Step 16: Save the result as extrusion2.blend.

Example 4: Extruding & Animation

Next, we’ll extrude curves along curves in the Wolfram Language.

First, the extension of a 2D curve to 3D:

r = Cos
&#10005


pp1 = ParametricPlot3D
&#10005


Here’s an easy way to give a curve volume using Tube instead of Line:

pp1 /. Line -> (Tube
&#10005


The development of this combo was animated:

nn = 16; pp2 = Table
&#10005


ListAnimate
&#10005


The extrusion in the animation Structures was partially recreated:

nn = 16; curve2 = {curve1
&#10005


Example 5: Material & Color

Next, we’ll change the color of materials in Blender. First, we’ll give an object a material, and then change its base color.

Step 1: Open extrusion2.blend.
Step 2: Switch to Shading mode:

Switch to Shading mode
&#10005


Step 3: Select the extruded object in the viewport/camera view.

Step 4: Switch from World to Object in the Shader Editor (the window beneath the extruded object).
Step 5: Press New in the navigation bar of the Shader Editor.
Step 6: Click the Material properties symbol in the vertical Properties bar:

Click Material properties
&#10005


The object is ready for physically based rendering
&#10005


The selected object now has a material with a physically based rendering.

Step 7: Change the base color to red.

This can be done in multiple ways. One option for editing Material properties can be found at the bottom right of the screen. Click the white field with the text Base… to the left of it. Choose a reddish color. Exit the color-change popup:

Change the color to red
&#10005


Step 8: Change the viewing mode to your preference (e.g. material preview, render view) for showing colors and other material properties.

You can do this by selecting your preferred viewing mode either in the top-right navigation bar of the viewport/camera view or by using the pie menu found via the shortcut Z:

Change the viewing mode
&#10005


Step 9 (optional): Modify the color to your preference.
Step 10: Select Blender and press F12 to render the scene:

Render the scene
&#10005


Step 11: Dismiss the rendered graphics.
Step 12: Save the file as extrusion3.blend and then close Blender.

Example 6: Animation

Finally, let’s show the development of the colored, beveled curve from example 5 in an animation. First, we’ll change its look.

Step 1: Start Blender and open extrusion3.blend.

Step 2: Switch to Shading mode.

Give the object a metallic look.

Step 3: Click the Shader Editor window. Then enlarge the material node via the scroll wheel.
Step 4: Set the value of Metallic to 1 and decrease the roughness to around 0.1:

Give the object a metallic look
&#10005


Step 5: Switch to a rendered display:

Switch to a rendered display
&#10005


For this animation, keyframes are used.

Step 6: Set the frame counter to zero.

Step 7: Select the red object in the camera view.

Step 8: Choose the curve properties symbol/icon from the vertical Properties bar.

Step 9: Open the Geometry and Bevel properties and scroll down if necessary.

Step 10: Open Start & End Mapping:

Select Curve properties
&#10005


Open Start & End Mapping
&#10005


Step 11: Hover over the End Mapping and press I.

A keyframe is entered at frame counter 0. Don’t be shocked if the object disappears:

Set the keyframe
&#10005


Step 12: Move the frame counter to 60.

Step 13: Click the End Mapping, enter “1” and press Return.

Step 14: Hover over the End Mapping value and press I again.

The object reappears and a second keyframe is set at frame 60. If the keyframes are invisible, select the “keyframed” object:

Select the keyframed object
&#10005


Step 15: Set the end frame to 60.
Step 16: Save again.
Step 17: Let the animation run by clicking the forward play button or the space bar.
Step 18: Pause the animation.

Further Exploration

As a bonus, after the development of the beveled curve, append a rotation. You can find the necessary properties of the red object via the Object properties symbol (orange) in the vertical Properties bar.

Think of a tower and movable sightseeing platform:

The beveled curve with a cylinder
&#10005



This does require some basic Blender knowledge, but try to recreate the idea as simply as possible. Experiment with the results if the final product surprises you.

Hints & Tips

  • Download Blender.
  • In Blender, the import plugin for DXF files has to be loaded/enabled in Edit/Preferences/Add-ons (PC):
  • The Blender start screen
    &#10005

    
    

    Import plugins
    &#10005

    
    

    Choose Import-Export instead of all (plugins):

    Choose Import-Export
    &#10005

    
    

  • In Blender, hovering over a symbol or icon shows its name.
  • In data/test, blend files are saved with applied solutions to problems from the process.
  • Keyframe the z rotation of the red object at 0 and 360 degrees. Then add a cylinder. Keyframe the z translation of red object.

Guenther Gsaller was a teacher for chemistry, mathematics and computer science at the Bundesgymnasium and Bundesrealgymnasium Ried im Innkreis in Austria. During this time, he coauthored an interactive mathematics course with Mathematica for secondary schools (level 2). Visualizing scientific ideas has long been a driving factor in his life. Recently, he has turned to a more artistic approach, although his 3D animations still start from a mathematical curve or surface.

Get full access to the latest Wolfram Language functionality with a Mathematica or Wolfram|One trial.

Comments

Join the discussion

!Please enter your comment (at least 5 characters).

!Please enter your name.

!Please enter a valid email address.