Home Examples Screenshots User manual Bluesky logo
OghmaNano Simulate organic/Perovskite Solar Cells, OFETs, and OLEDs DOWNLOAD

Ray-Tracing Tutorial (Part D): Adding Shapes and Materials

In the previous parts you worked with objects that were already set up for you: two prisms, a lens, an aperture and a detector. In this part you will add a completely new object to the scene. This involves two steps:

We will create a new free object, enable a complex mesh taken from the shape database, and then replace the default box with a classic ray-tracing shape: the teapot.

Step 1: Create a new free object

Start from the scene you finished in Part C (lens, aperture and detector in place). To add a new object:

  1. Right-click on an empty region of the floor grid (make sure you are not clicking on an object).
  2. From the context menu select Objects β†’ New free object, as shown in ??.
  3. A new box-shaped object will appear in the scene, as in ??. You may need to zoom out slightly to see it.
Right-click menu on the floor grid showing Objects β†’ New free object
Creating a new free object. Right-click on an empty region of the floor grid, then choose Objects β†’ New free object.
Scene with a new red box object above the floor grid
After adding the free object a red box appears in the scene. This is a placeholder mesh that we will now replace with a teapot.

Step 2: Enable a complex mesh

New free objects start with a simple box mesh. To use one of the more complex shapes from the database (such as the teapot), you must first enable a complex mesh:

  1. Right-click the new box and choose Mesh editor, as in ??.
  2. The mesh editor will open. At first the mesh is disabled – this means the object uses the simple box geometry only.
  3. Click the Disabled button to enable a complex mesh. The panel now shows a Shape Database entry with box selected, as in ??.
Mesh editor with the mesh disabled for the new object
Mesh editor opened for the new object. Initially the complex mesh is disabled, so the object behaves like a simple box.
Mesh editor with the Shape database enabled and box selected
After clicking Disabled the Shape database becomes active. The default entry is box, which still gives a simple cube mesh.

At this stage the object has a full mesh representation, but we are still using a box. In the next step we will swap the shape for a teapot.

Step 3: Load the teapot from the Shape database

In the mesh editor, stay on the Shape Database tab. We now choose the teapot and set its size:

  1. Set the xyz size fields to dx = 5.0e-2 m, dy = 5.0e-2 m, dz = 5.0e-2 m as in ??. This keeps the teapot small enough to fit comfortably in the scene.
  2. Click the ... button next to Shape from database. This opens the shape browser shown in ??.
  3. Double-click teapot to select it.
  4. Close the mesh editor.
Mesh editor showing the teapot shape with dx, dy, dz set to 5.0e-2 m
Setting the teapot size in the mesh editor. A size of 5 cm Γ— 5 cm Γ— 5 cm works well for this demo.
Shape database browser with the teapot shape selected
The Shape database browser. Double-click teapot to assign the classic teapot mesh to your object.

When you close the mesh editor, the scene should now contain a teapot-shaped object instead of the original box, similar to ??.

Scene with a teapot mesh placed to the right of the existing optics
After closing the mesh editor, the new object appears as a teapot in the scene.
Teapot moved into the beam path between the lens and detector
By dragging with the mouse you can move the teapot into the optical beam. Use Shift while dragging if collision detection prevents the object from passing through others.

Step 4: Set the optical material

The mesh defines only the geometry. To complete the object you also need to select the material from which the teapot is made:

  1. Right-click the teapot and choose Edit object, as in ??.
  2. In the object editor, under Optical material, choose a suitable glass from the material database (for example glasses/flint/BAF10.yml), as in ??.
  3. Optionally adjust the Alpha value to change how transparent the teapot appears in the 3D view.
  4. Click the green tick icon to close the object editor.
Object editor open for the teapot object
Opening the object editor for the teapot. Here you can adjust position, rotation, color and other attributes.
Object editor showing the optical material field set to a flint glass
Selecting an optical material for the teapot. The refractive index of this material determines how the rays refract inside the teapot.

Step 5: Position the teapot and run the simulation

Finally, move the teapot into the beam and run the ray tracer:

  1. Drag the teapot using the left mouse button until it sits in the optical path between the lens and the detector, as in ??.
  2. If collision detection stops it moving through other objects, hold Shift while dragging to force the move.
  3. Click Run simulation (or press F9) to re-trace the rays with the teapot in place.

You should now see rays passing through and around the teapot, scattering onto the detector. Try rotating the camera to view caustics and shadow regions formed by the teapot. You can also repeat the steps from Part C to inspect the updated detector image and efficiency.

πŸ‘‰ Next step: Continue to Part E to learn learn about changing materials and how to set the world size.