Home> 4D Blocks > Version 6 Controls Settings Block Motion Examples > Scene Language Kinds of Blocks Goals History Versions General Information Constants Geometry Commands
Elevated Train Commands Scenery Commands |
More Geometry CommandsComposite ShapesIf you want to move or place a group of shapes as a single unit, you can glue them together for great convenience. For example, if you wanted to make a lot of little towers, you could start by saying this.
[ Then you can create and place a whole tower just as you would any other primitive shape with commands like this.
tower [x 0 z] translate Most commands that operate on primitive shapes also operate on composite shapes. Here's a complete list of exceptions.
aligncenter Yes, for now it's unfortunately not possible to build train engines with smokestacks; maybe some day. For similar reasons, all composite shapes are unglued before being displayed, so you can't pick them up and move them as a unit within the game. Composite shapes can contain other composites, but for stupid technical reasons a composite must contain either all primitive shapes or all composites. If you really need to mix the two, you can either wrap the primitive shapes with "[ ... ] glue" or apply the "unglue" comand to the composite shapes. The latter is recursive, by the way. Ideal Shapes Every shape in the game has an "ideal shape" that holds two pieces of information about how the shape likes to be aligned to the grid. One piece of information is a point called the align center. This point is used to tell when the shape's position is aligned. It also defines the center of rotation when you pick the shape up. By default it's the average of all the vertices, but sometimes that's not what you want, in which case you can redefine it using the "aligncenter" command. For example, the definition of the "half3" shape in "library2" includes the following command so that it will fit nicely next to other blocks.
[0.5 0.5 0.5] aligncenter The second piece of information is a set of axes that define when the shape is oriented correctly. You can't change these directly, but you can reorient the shape using some rotate commands and then say "idealize" to set the current orientation as the ideal. There's one other command that affects the ideal: "scale". It's not obvious what the ideal should be after a scaling operation, so the current position and orientation are used. The axes are usually fine, but you'll often need to adjust the align center afterward. For example, if you scale a 1x1 block to get a 2x1 block, the alignment point will be at the 2x1 center, but to fit well with other blocks it needs to be moved to the center of one of the 1x1 units. Custom Textures Normal textures are the patterns controlled by the keys 1-9 that show you where the faces of shapes are. Sometimes, though, you want a shape to have a custom texture instead, an arbitrary pattern that's drawn on one face for some special purpose. The dice and the jigsaw puzzles in the Toys and Puzzles section are good examples. Here I'll explain how to set up your own custom textures. Fundamentally a texture is just a set of vertices and edges. Those can be specified as two arrays, like so.
[ Textures, like shapes, can be two-, three-, or four-dimensional. The one above is two-dimensional. It also has no particular color, and will by default inherit its color from whatever face it gets attached to. If you want a different color, you can use a "texturecolor" command like "red texturecolor". If you want to have multiple colors in a single texture, you can either use the "cedge" command (color edge, looks like "0 1 red cedge") or use the "union" command discussed below. The easiest way to create a texture is to take an existing shape and throw away all information other than the vertices and edges. The "shapetexture" command does that. Once you have a texture, you'll need to attach it to some face of some shape. This is the tricky part. Ideally the vertices of the texture would already lie both in the plane of the face and within its bounds, but sometimes it's not convenient to arrange that. So, as part of the attaching step, we project the texture into the plane of the face and clip it to fit within the bounds. The command that does all this is "facetexture", and it looks like this.
shape facenumber texture projectionmode datum facetexture There are four projection modes.
PROJ_NORMAL is the mode you normally want to use, in which projection is done along the face's normal vector. The datum isn't used in this case and can be null. If a texture isn't lined up right for projection, you can use the following commands on it just as you would on a shape.
translate The "union" command combines two textures by taking the union without simplifying the result in any way. If you want to combine duplicate vertices and edges, you should wait until you're done taking unions and then run the "merge" command, which takes a single texture as argument and does all the simplification possible. The "normalize" command normalizes all the vertices to have unit distance from the origin. This is mainly useful for the scenery meshes discussed in Scenery Commands. Finally, there are "lift" and "project" commands that are useful for adding and removing dimensions. For example, "texture y 3 lift" inserts a new dimension as y and gives it the value 3, and "texture y project" removes the y dimension. Saved Games When you use the menu command "Save" to save the game, there are some special commands that the program uses to record the game state. These can occasionally be useful in handmade files too. viewinfo position axes viewinfo - This sets the user's initial position and orientation. The "position" argument is a vector, and the "axes" argument is an array of vectors. The axis vectors can either be arrays of numbers or uppercase codes for the standard unit vectors. For example, this command produces the default position and orientation in 3D.
[0.5 0.5 -2.5] [X+ Y+ Z+] viewinfo See the "Mats" section at the start of Scenery Commands for a bit more about the coordinate system. drawinfo textures shapecolor drawinfo - This sets some of the display settings.
[1 0 1 0 0 1 0 0 1 0] false drawinfo The "textures" argument tells which textures are turned on, and the "shapecolor" argument tells whether the boundary texture should be drawn using the shape color ("true") or just white ("false"). place shape position axes place - This does the same thing as viewinfo, but for a shape rather than the user's point of view. Like most other shape commands, it leaves the shape on the stack afterward. Note that you can turn a shape into its mirror image by specifying a left-handed set of axes! edgecolor shape edge color edgecolor - This does the same thing as facecolor, but for a single edge. The edge color is only used for the boundary texture, not textures 1-9.
|