Manipulating 3D Objects with Perl

April 2024

Workflow

  1. Edit the POV-Ray scene
  2. Render...
    • Fix errors in the scene file
    • Rinse and repeat...
  3. Improve the design
  4. Rinse and repeat...
This sucks. I want a GUI.

Candidates

Can I do it in Perl?

Perl GUI Toolkits

Can we do ... faster?

Tk is ... a bit slow for thousands of polygons.

Time to learn something new.

OpenGL

"The Industry's Foundation for High Performance Graphics"

I learned it from an online version of "The Official Guide to Learning OpenGL, Version 1.1" (1998)

I could easily translate the examples from C to Perl's OpenGL module (which says it supports version 1.2) ๐Ÿ‘

...but the guide is no longer online ๐Ÿ˜ข

OpenGL

...is about to be superseded by Vulkan

"Vulkan is a cross-platform industry standard enabling developers to target a wide range of devices with the same graphics API."

...for which there are no Perl bindings (yet)

Edited to add: ChatGPT says "Writing a Perl XS binding for the Vulkan graphics API would be quite an involved task,..."

So let's stick with what we have

Prima

...is a GUI toolkit which can be built and works on Linux and Windows (and Mac/OSX)

...Dmitry Karasik is an active maintainer (e.g. 5 releases in 2023) ๐Ÿ‘

...and it allows use of OpenGL in a widget ๐Ÿ‘

A Viewer

In the early days of the web, with 256-color images, Netscape used a universal palette. This rendering of the "Netscape color cube" has more than 100000 polygons.

On my PC at home this renders in 5 milliseconds.

Persisting a Scene

Unimplemented.

3D file formats

...don't look too attractive.

Or...

Or maybe not?

Modern Times

But also...

Box Construction in 3D

POV-Ray
X3D

Use the Power of Perl

As of today, I write scenes with an editor and use the programs only as viewers.

The next slides show some examples.

All values have defaults

Appearance and Transformations
are Methods

Curlies for Grouping

...and for Animation!

Color Cube

A Timer

What's Next?

ChatGPT's Take

Write me an x3dom representation of an old castle

ChatGPT's Take 2

Write me an x3dom representation of Balmoral castle