Home

> 4D Blocks

> Version 1

> Scene Language
  Kinds of Blocks

Scene Language

The scripting language used to describe scenes is stack-based, like PostScript or Forth. You can comment and uncomment things in C/C++ style. Brackets are used to define arrays / vectors.

The simplest command is just the name of a type of block, which creates a new block of that type at its default location (which should typically have coordinates ranging from 0 to 1). For example ...

     block3
When you have more than one block, you'll want them to be in different places. Here's how you create a block3 that's moved one unit in the x direction (i.e. to the right). There's no way to rotate blocks yet, but I'll probably add that some time soon.

     block3 [1 0 0] translate
You can change the colors of blocks using the same kinds of colors as in HTML. The color-setting operation can come before or after translation, doesn't matter.

     block3 #FF0000 shapecolor
You can change the colors of individual faces too. Faces are identified by numbers from 0 to N-1. You can figure out which faces are which by experimenting or by digging into the "library" file where they're defined.

     block3 5 #FF0000 facecolor
That's all there is to know about editing the scene file, except, don't mix 3D and 4D blocks in the same scene. If you want to get into defining new block types, see the "library" file for examples. Here are a few hints about the format.

  1. Each shape starts with a list of vertices. Like everything else here, these are numbered from 0 to N-1.
  2. Next is a list of edges. "M N edge" creates an edge that connects vertices M and N.
  3. Next is a list of faces. Faces have a list of edges ( not vertices! ) and also an outward normal vector. If you can't be bothered with the normal vectors at first, you can just put ? in place of that whole vector. In that case, the face will always be drawn no matter which side of the block you're on.