s LearnSqueak.com

03 / PROJECT SOURCE WALKTHROUGH · SQUEAK 6.0

Vertices become pixels.
A scene comes alive.

Build a torus, edit a live sphere, rotate a wireframe cube, and animate an orbital scene. Read the software renderer that turns this project’s 3D objects into a Morphic viewport.

4 executed examplesNative PNGs · copyable source

3D STUDIONATIVE SQUEAK WINDOW
A real window rendered by Squeak. Click to inspect the full-size capture.

FOLLOW THE OBJECTS

  1. 01Mesh vertices
  2. 02Transform + cull
  3. 03Project + shade
  4. 04Form → viewport

Lab3DVector supplies vector arithmetic. Lab3DMesh owns vertices and face-index arrays. Lab3DScene owns meshes, rotations, time, and camera settings. Lab3DRenderer writes to a 32-bit Form with BalloonCanvas. Lab3DViewportMorph displays it and routes gestures to Squeak3DLab. This project is a software polygon renderer built with Squeak classes; it does not depend on an OpenGL engine.

READ → RUN → INSPECT → CHANGE

Inside the implementation.

Evaluate a complete Workspace recipe, then switch to Project methods to read the code it uses. These classes belong to this project; install the source suite first.

DESIGN CHOICES IN THIS PROJECT

The projection in one equation

The renderer computes distance = cameraDistance − point z and focal = min(viewport width, viewport height) × 1.4 × zoom. Screen x is the center x plus point x × focal / distance; screen y subtracts the analogous y term. A nearer point therefore projects farther from the center.

Lighting and visibility

A cross product supplies a face normal. The renderer compares that normal with the direction toward the camera, sorts surviving polygons by their center z, and uses a light-direction dot product for diffuse brightness. A small view-facing shine term adds a highlight. BalloonCanvas fills the projected polygons into a 32-bit Form.

What this renderer teaches

This is the project’s own software 3D renderer. It uses painter-style polygon ordering, not a depth buffer. Intersecting faces or some overlapping geometry may sort incorrectly. Faces that cross the near-distance guard are discarded as a whole rather than clipped. Wireframe includes back faces. These choices keep the code readable and work well for the supplied teaching meshes.

The live timer measures elapsed time and caps a single update at 0.1 seconds. The GIF recordings instead call advanceSeconds: with a fixed 1/24-second interval. Their slower playback is documented next to each recording.

RUN THE SAME STUDIOS

Open the project in Squeak.

Use the existing Pen Studio image, or install the downloadable custom classes into Squeak 6.0. The bundle contains Smalltalk source and setup notes; it does not contain a saved image.

02 / Launch and inspect

Open a Workspace, select PenDemoLauncher run., and choose Do it. Each launcher action returns a native window in the same image. Alternatively open this studio directly with Squeak3DLab run.

The lesson recipes return a SystemWindow. Choose Inspect it, then inspect its model to follow the fields named in each example. Method listings belong in the System Browser; use the Workspace tab for a complete runnable expression.

03 / Browse and experiment

Find the class in the System Browser. Choose instance or class side as indicated above each method. Modify a message, accept the method, and rerun the example. These are live Smalltalk objects: you can inspect the scene, commands, Forms, and owner tree directly.

SOURCE AND RECORDING EVIDENCE

Recorded from the actual project.

The native runner files in the ten source files, compares every documented method with installed source, evaluates the exact Workspace recipes, and checks their resulting state. It stops automatic stepping before supplying the recording messages shown next to each GIF.

The PNGs are complete native window captures. GIFs use a shared reduced-color palette and repeat excerpts, so a loop boundary can jump. The website displays recordings; the live studios run inside Squeak. The runner closes its windows and exits without saving the image.

Return to the project guides →

Download original ↓