Home

> 4D Blocks

> Version 2

> 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
You can turn a block into glass so that it's transparent. For the moment, this also lets you fly through the block.

     block3 glass
You can stretch blocks by different amounts in different directions. Be sure to use one number per dimension, and to use 1 not 0 for directions with no stretching!

     block3 [2 1 1] scale
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.
Advanced shape-building commands:

[x y] r n polygon - This constructs a n-sided polygon of radius r around (x,y). The polygon is a two-dimensional shape, so you'll have to use one of the following two commands to add more dimensions. If you try to display it directly, who knows what will happen.

shape axis [min max] prism - This takes the given shape and adds a dimension to it to make a prism. The prism extends from min to max along the given axis (x=0, y=1, z=2, etc.).

shape point axis [min max] cone - This takes the given shape and adds a dimension to it to make a cone. The cone extends from min to max along the given axis. The given point has the same dimensionality as the starting shape and tells where the tip of the cone should be. So, you can make symmetrical or asymmetrical cones.

As a combined example, these commands create a hovering nine-sided prism.

     [1 1] 1 9 polygon 1 [1 3] prism