Week2: Computer-aided Design

  • |
  • 08 February 2022
Post image

Introduction

Computer Aided Design forms an important part in digital design and digital fabrication. My history with computer aided design began in 1994 with 3d Studio R1 for DOS. Later I learned about Rhinoceros and 3dsMax, worked with AutoCad during college and finally settled on a workflow combining the features of Blender, Rhinoceros and OpenSCAD for modelling. Some parts of computer aided design I hardly touch:

  • Visual parametric modelling
  • Materials and mapping
  • Animation and simulation
  • Rendering and compositing

For each of these I will have to learn something new.

Result

Because the text below will be quite long, it’s probably best to first show what this week’s work has lead to.

The instrument that can not play a wrong note. (which still needs a better name)

If the video doesn’t work: watch on youtube.

Think

Visual parametric modelling

I will use FreeCAD to draw an initial sketch of my final product.

Materials and mapping

By importing the FreeCAD model to blender I hope to assign fitting materials and textures to my object

Animation and simulation

Blender will also be used to animate and possibly simulate parts of the model. Animation would be particularly useful to show how I might make force sensitive buttons that still can be back-lit.

Rendering and compositing

Because my design will feature back-lit buttons, I will add realistic lighting to my final renders.

Make

Rhinoceros

Rhinoceros3d is familiar terrain form me. It allows for very fast previews of final products. Unfortunately, its destructive modelling workflow makes it cumbersome to iterate on previously constructed models. If measurements need to be altered once the model is made, parts of the geometry have to be deleted and rebuilt. For a first visualization, the free-form modelling workflow is great, so that’s what I used.

rhino_sketch_construct rhino_sketch_trim
Base shape constructed from two circles and tangent lines Used the trim command to delete lines
rhino_curves_stacked rhino_stacked_curves_lofted
Base shape duplicated and offset to indicate height Used the loft command to create the 3d shape of the base
rhino_single_key_constructed rhino_single_key_extruded
A single key was made using two circles, connected by 2 lines _ExtrudeCrv command used to extrude to a solid
rhino_keys_sketch rhino_keys_3d
Key shape duplicated 24 times with ArrayPolar command 3d keys
rhino_top_plate top_plate_textured
Used a boolean to cut keys from the top plate Gave the top-plate a wood texture, for now
rhino_preview_render.jpg
The final render from within Rhino gives a nice impression of what the end-result could be

FreeCAD

To start a part in FreeCAD, one has to select the option “part design” in the combobox at the to of the screen. The first part I want to make is the circular keyboard.

freecad_parametric
To make the design parametric, I will start a spreadsheet.

The keyboard will consist of buttons that describe 1/24th of a ring.

freecad_keys_construction
Two circles where made and two lines were drawn from the center to the edge of the outer circle.A horizontal construction line was made to keep the two outer edges of the button fixed in the horizontal center
2d_key 3d_key
By trimming, a 2d sketch of the key was constructed… … and turned 3d by making a pad
3d_keyboard_no_spaces
Using the PolarPattern command the key was copied in a circular pattern to make up the keyboard
FAILURE
As it turns out, using the trim function in a constrained sketch will lead to unconstrained geometry."
dont_trim
The key shape could be deformed and follow-up calculations weren’t executed correctly.

The second mistake was to confuse PolarPattern with PolarArray. PolarPattern joins copied geometry into one single mesh. I deeded PolarArray from the draft menu.

Solution
I was approaching this the Rhino way, where destructive modelling is the main approach. In programs like FreeCAD you draw construction lines that help you draw the actual sketch. I added three more construction lines as anchor points for the endpoints of the inner and outer arc that make up the circular edges of the key.
constrained_key_sketch
Now I was able to draw the key and it stayed fully constrained.

Spacing between keys

To parametrically have spaces between the keys I had to calculate the angle between keys based on the desired spacing.

calc_angle_known_distance
x: the desired spacing between keys, r1: the inner radius, alpha: the desired angle

which led to the equation:

\[ \alpha=\arcsin{x \over r_1}\]

to calculate the angle of the spacing.

spreadsheet_spacing
Entered the formulas into the spreadsheet

Adjusting the spacing in my spreadsheet directly changes this in the sketch, therefore changing it in the 3d object. The main keyboard is now fully parametric.

Top panel

The top panel of the instrument will be a flat, milky-white (opal) acrylic plate. For now the plate is designed only with the keys cut, using the keyboard part, previously described. The sketch for the top-panel:

top_panel_sketch top_panel_minus_keys_3d
Top panel sketch Top panel

The command Cut command from the part workbench was used to make cut out the keys from the panel.

I decided to return to FreeCad at a later stage of the project because I really wanted to try rendering an animation in Blender.

Blender

Rhino is great for creating accurate but organic like models. It has a nice renderer but to generate a realistic image, Blender with it’s Cycles renderer would be a much better choice. Blender allows has some nice features I wanted to use and learn more about:

  • creating a material that would simulate backlit opal acrylic
  • lighting the object realistically
  • animating the LED’s
  • animating from different angles
  • simulating the OLED display
  • making clear LEDs and OLED are light emitting using a glow filter

Backlit RGB test

The final keyboard will partially communicate its state using RGB LEDs that are lighting an opal acrylic plate from the back. To visualize how that might look, an experiment was conducted in Blender, using the Cycles rendering engine and the Sub Surface Scattering material property.

blender_sss_experiment_setup blender_sss_material
A grid of thin, scaled cubes was constructed to act as walls that keep light from bleeding The grid was set to have a high value for sub-surface scattering
blender_sss_light_material blender_sss_lightsphere_follow_path
A sphere with an emission material was used to simulate an RGB LED The sphere was set to follow a circular path
blender_sss_animated_camera
The camera was animated to show the underside and the top-side of the geometry
blender_sss_denoise_composite
The final render was set to denoise the images using hardware desnoising using the compositor
The final result

If the video doesn’t work: watch on youtube

Exporting from Rhino Importing in Blender

I chose to export the model as an .obj object, because it would let me integrate the textures and keep texture mapping. First I tried to export it as a NURBS object but blender didn’t like it.

rhino_obj_export rhino_export_obj_polygons
I selected to export the object as a mesh Rhino allows you to determine the mesh detail generated from the NURBS objects

Blender assumes that one unit is one meter, while most CAD software will assume that one unit is one millimeter. This always leads to having huge objects in Blender.

blender_obj_way_too_large blender_imported_object_scaled
The imported objects are so large they fall outside of the z-buffer range and disappear Scaling the object brings it back in visible range

Furthermore, Rhino exports all the loose parts of an object as one single object.

blender_separate_parts
Blender has an option to separate all meshes

When separating meshes in loose parts, some surfaces may become separated.

blender_weld_modifier
Objects can be reconstructed from their loose parts using the weld modifier and applying it.
blender_scene_tree
The final scene graph looked like this

Realistic lighting and materials

Two tricks were used to simulate realistic lighting

blender_hdr_lighting.png blender_hdr_lightmap
Using a HDRI image to light the scene As an HDRI lightmap I chose an image of an indoor, industrial looking storage facility.

The added benefit was that this would also serve as the background of the animation.

blender_light_planes
For extra lighting I added two light planes, which also reflect on the wood surface

To create a glossy, slightly bumpy wood material I used the shader graph

blender_glossy_wood_material.png blender_glosy_wood
The wood shader-graph The final material, reflecting the light planes

Animating LED’s

Using the results of the backlight experiment I made the LEDs from spheres with a highly emissive material.

blender_led_spheres
I made two sets of LED’s to simulate two chords being played

The two sets of LEDs were interfering with each other so I had to hide and show them in during the animation by setting animation keys for object visibility

blender_animate_led_timeline
The resulting timeline for the LEDs looks like this, changing the emission value and the visibility of the LEDs over time

Audio synchronisation

To show the LED’s reacting to the audio, four chords were extracted from the original youtube video.

blender_audio_convert
OBS studio was used to rip the audio track from the youtube video. Audacity was used to extract four chord pairs .wav file was loaded into blender

Animating camera-angles

The animation sequence would show a couple of chord progressions being played on the device. Each different progression would show another camera angle, slowly panning before making a jump cut to the next angle.

blender_camera_trackto_constraint
To have more control over the camera a Track To constraint was added to the camera object, making it point towards another object as the target.
blender_animate_camera
A single camera was used to simulate multiple shots by making the camera jump from one position to another and then track slowly to another position.
blender_camerapath_bezier
Bezier path interpolation make the camera motion look more naturally
blender_camerapath_linear
But I didn’t like that so I made all movements linear, which gave a more controlled feel

Animate the OLED display

The OLED display had to change text once in a while.

minecraft_font
I found a nice font for the OLED display.

Using the GIMP I made a couple of diplay states in one file, as separate layers

gimp_oled_layers gimp_oled_merged
First as separate text objects… …and then merged to have 10 text states

Storing all LED states to one separate numbered files allowed me to have an image sequence as a shader

blender_oled_shader
An image sequence texture can point to any numbered image file
blender_oled_driver
But to have the texture change for a determined amount of frames proved challenging and I had to make a “driver”, linking multiple variables together

Post processing glow

When everything was moving the way I wanted it to I wanted something to make clear that the LEDs and the OLED were actually light sources. This was achieved by adding a glow in the compositor.

blender_final_composite
Linking the denoised image to the glow filter allows you to add glow to specific parts of the image

Movie and audio

Rendering 900 frames of animation resulted in 900 separate images. Using ffmpeg I could easily convert those images into an mp4 file

ffmpeg -r 24 -i %04d.png -vcodec libx264 -b:v 768k -vf scale=-2:720 -an instrument_previz.mp4

And lastly, I had to add the audio to the final animation. This didn’t succeed at first because the animation was rendered at a different framerate as ffmpeg was set to, but in the end it matched up nicely.

kdenlive_adding_sound
I used KDENLive to add the sound to the final animation

2D Vector drawing

A lot of 2d vector drawing software exists. The most familiar open source solution is InkScape. I am not fond of InkScape, as it is very slow on most systems, due to the lack of GPU support. Most 3d software have powerful 2d drawing capabilities and of the 3d packages I know it is my opinion that Rhino3D has one of the most capable 2d drawing capabilities. It has freeform capabilities that rival 2d drawing software but with tools that are often found in classic CAD software packages. I once bought Rhino3D because of it’s excellent 2d capabilities.

Kicad footprints

To show my proficiency in drawing 2d vector images, I decided to dust of an old project I created 13 years ago, but never published before. It is a set of KiCAD footprints that are essentially a set of coins, drawn at 1:1 scale, that can be loaded into any PCB design as a size reference. For this I needed vector drawings of coins. I tried to get these by converting bitmaps to vector drawings but the results weren’t good enough, so I proceeded to draw them by hand.

Rhino3D had good options for loading in background bitmaps to act as a reference. I traced all common US and EU coins using NURBS splines, circles and the trim operation.
In the KiCAD footprint editor there is an option to load .dxf files This results in a clean footprint to be used in a project.
Most common US and EU coins are represented

The resulting footprint library can be found here.

Check

Did I achieve my goals for this week?

Visual parametric modelling

I will use FreeCAD to draw an initial sketch of my final product.

It took me some time to get used to the parametric modelling mindset. I am confident now I will be able to model the rest of the device in FreeCAD but I wasn’t able to do the entire design using this workflow. Ultimately I resorted to my old tricks to proceed animating and lighting. This goal is half reached but will be a big part in future work.

Materials and mapping

By importing the FreeCAD model to blender I hope to assign fitting materials and texturemaps to my object

Which turned out to be the Rhino model, but nevertheless I think I was able to nicely visualize a glossy, blinky instrument.

Animation and simulation

Blender will also be used to animate and possibly simulate parts of the model. Animation would be particularily useful to show how I might make force sensitive buttons that still can be back-lit.

Although simulation hasn’t been part of the animation, I’m still happy how it turned out. The final animation quit glossy and glowy and gives a sort of tranquil feeling to the user. Due to the slow camera movements but probably als due to the isolated chords being played. It conveys nicely how the instrument should look but I’m not convinced this animation shows the entire purpose of the device. For that you still need my explanation.

Rendering and compositing

Because my design will feature back-lit buttons, I will add realistic lighting to my final renders.

It’s glowy!

Reflect

I set out to do parametric modelling but really liked having a chance to do some animation and visualization. I am happy with the end result but putting more time into modelling would probably have helped me out better in the course of the project.

Files

You May Also Like

Final Project

Final Project

Final project Initial conception (Febuary 2022) Learning to play any musical instrument takes a very long time and a lot of effort. To enjoy music …

Week18: Project development
  • 10 Jun, 2022

Week18: Project development

What I did. I created the enclosure and designed and milled all the PCBs. TODO Hardware Priority 1 20 x Button LED caps 8x Octave1 8x Octave2 4x chord …