This page was last modified on the 18th of August, 1997.
The information published in this page will be much easier to understand if you run the listings we publish in the Examples part and look at the ASCII files produced with a word processor. As we explain in other pages of this site, the VR Cocha club uses a specific ASCII text format as a unique source to produce 3D files in various standard formats. As our club was founded in Cochabamba, Bolivia, the name of our format is Cochabamba (and the extension is .CBB). Before we begin, we must say something about : That having been said, the features allowed by our format are these : |
General aspects of the format |
Files written in the CBB format are plain DOS ASCII text files, with ends of lines coded as chr$(13) and chr$(10). There is normally a chr$(26) character at the end, although its absence should have no consequence. In other words, these files are exactly what the DOS EDIT program normally writes. Macintosh ASCII files and Unix ASCII files code the end of lines in a slightly different way, and that may cause some minor incompatibility problems; but DOS and Windows users can forget that. The CBB format only uses 7-bit ASCII characters: no characters with accents are ever used. That means you can forget the difference between DOS ASCII texts and Windows ASCII (ISO) texts. The CBB format uses a line-by-line logic. That means that (unlike what is done with HTML or VRML) you cannot put end of lines anywhere in the files, but only when a complete piece of information has been defined. In a symetric way, you cannot put two independent pieces of information on the same line. In other words, to define a point, a face, a color or a basic shape, you'll always have to use exactly one line. Every line constitutes a piece of information, but various lines are grouped in logical units by markups. The markups to open a logical unit have the form <markup> (inferior sign, name of the markup, superior sign; all that constitutes one independent line), and the markups to close a logical unit have the form </markup> (inferior sign, slash, name of the markup, superior sign; all that constitutes another independent line). This is obviously inspired from HTML, but do not forget that the CBB format uses a line-by-line logic and not an opening sign-closing sign logic as HTML and VRML do. The lines must begin and end with a readable character. They cannot begin or end with a tab or a space character. The VR Cocha format is not case-sensitive. There cannot be empty lines between an opening and a closing markup. Empty lines between a closing and an opening markup will be ignored. The CBB format uses a cartesian 3-dimensional coordinate system. The X axis is horizontal and its direction is eastwards. The Y axis is horizontal and its direction is northwards. The Z axis is vertical and its direction is upwards. The unit for lengths and distances is meters. The unit for angles is degrees. |
The keywords |
As the VR Cocha club was founded in Bolivia, the very few keywords we use at the present time are... Spanish words. It would not have been absurd to translate them in the material we publish on this Web site, but it would have created compatibility problems with the material we already created here, in Bolivia. So we thought it would be more reasonable to go on with a little bit of Spanish vocabulary. This should not be a big problem, as the geometry words are more or less international: cubos means cubes, cilindros means cylinders, etc. Anyway, this is a complete list of our keywords:
The lines between these markups use the abbreviations: - Complex shapes - Miscellaneous The lines between these last two markups use the abbreviations: |
Create simple shapes very easily |
Simple shapes are cubes, cylinders, cones and spheres, but their x, y and z proportions can be modified to create parallelepipeds and oval shapes. Simple shapes are always defined in a parallelepiped whose sides are parallel with the axes x, y and z (of course, it is possible to move and rotate them afterwards). You will define the position and proportions of this parallelepiped, which are not always the same as the ones of the included shape. Have a look at these examples: |
Posi 1.5,1,0,so Tama 2,2.5,1.5 </cubos> |
Posi 1.5,1,0,so Tama 2,2.5,1.5 Punt 36 </cilindros> |
Posi 1.5,1,0 Tama 2,2.5,1.5 Punt 36 </conos> |
Posi 1.5,1,0 Tama 2,2.5,1.5 Punt 18,18 </esferas> |
Circular sides of cones and cylinders are horizontal (unless you rotate them). The arrow of a cone is put upwards (unless you rotate it).
- Syntax
If the shape is a cone or a cylinder, it is recommended to add on the same line:
And if the shape is a sphere, it is recommended to add:
- Position and reference point
|
In this series of examples, the green spot indicates where is the point used as a reference. |
or Posi 1,1,0 Tama 1,1,1 |
||
This feature is extremely useful in architecture: it is much easier to determine where are the corners of a wall than its center. |
Create truncated and simplificated shapes |
In order to reduce the number of triangles that your browser will have to deal with, the CBB format use two techniques: it may destroy the sides of a shape that are not supposed to be seen, and reduce the number of vertices in a round shape.
- Destroying unnecessary sides
|
Posi 1.5,1,0,so Tama 2,2.5,1.5 Excl sup </cubos> |
Posi 1.5,1,0,so Tama 2,2.5,1.5 Excl sup,n,s </cubos> |
Posi 1.5,1,0,so Tama 2,2.5,1.5 Excl n,s,o,inf </cubos> |
Posi 1.5,1,0,so Tama 2,2.5,1.5 Excl inf,sup,s,o </cubos> |
Have a look at the "Mormon temple" in the Examples section. It is a typical example of what you can do with that feature of the CBB format, not only with parallelepipeds, but also with round shapes.
- Reducing the number of vertices in a round shape
|
8 triangles |
36 triangles |
84 triangles |
72 triangles |
540 triangles |
135 triangles |
Define any shape by its characteristic points |
We have already described in another page of this site the general method to define a shape by its characteristic points. The syntax we use in the CBB format is extremely simple and does not need many explanations.
- Syntax
The number of the first point is 1 and not 0. Defining points that will not be used in the description of sides, or leaving gaps between used points, will have no consequence except a useless occupation of memory. Although we always do it and think you should do it too, it is not necessary to define the points in a regular order from number 1 to the biggest number. The lines that define a face are written between the markups
<lados> and
</lados> (lados means sides).
They must have that structure:
We recommend that the list of points should be written counterclockwise (looking from outside the object).
- Non-triangular sides
|
Define colors with a simple hue-saturation-grayscale model |
As the computer screens form the colors melting red, green and blue spots, nearly all the Virtual Reality programs force their users to define colors according to that abstract and complicated model. In the VR Cocha Club, we think that computation should adapt itself to human logic, not the countrary. For that reason, we prefer to define colors with a hue-saturation-grayscale model, which is much easier to understand.
- Syntax
Hue is a position on the classic chromatic circle. That value will be expressed in degrees, as you can see on this figure: Saturation is a value between 0 and 1. The bigger the value, the more aggressive the color will be. If saturation is set to 1, the color will be pure; if it is set to 0, it will only be gray. For instance, here are some variants of the same colors, realized with small changes of the saturation parameter, leaving unchanged the hue and grayscale parameters. From left to right, the values for saturation are 0, 0.2, 0.4, 0.6, 0.8 and 1. Grayscale is also a value between 0 and 1. The bigger the value, the brighter the color will be. If grayscale is set to 1, the color will be white; if it is set to 0, it will be black. It is important to notice that, in our model, the hue value has no influence on the grayscale: blue is not darker than yellow, for instance. Look at what the chromatic circle becomes when saturation is set to 0 (in other words, when everything is converted to gray). Grayscale is set to 0 at the center of the circle, and set to 0.8 on its perimeter. |
Modify the coordinates of any shape |
It would be boring and absurd to have to calculate the coordinates of an object everytime you want to modify its place or orientation only, without changing its aspect at all. The CBB format allows you to move, rotate or modify the proportions of any object adding only a few lines in the source file. You can also write long series of modifications of coordinates of that type, and combine them in logical structures.
- Let's begin with an example
On the right side, you can see the CBB code that produces each scene. Do not try to understand the whole syntax at the present time, just notice when moving, scaling and rotating are used, and where are the lines that we added to do that (the new lines appear in green, and the most important in bold characters). You'll come back to these examples after having read the explanations that follow. You'll understand that it is much simpler than it seems at the beginning. |
Basic shapesAt the beginning, we only have a cylinder and a sphere. Both of them were defined in reference with the southwest angle of the bottom side of the parallelepiped in which they are included, as we explained earlier. At the present time, the sphere is inside the cylinder. |
<cilindros>
Posi 0,0,0,so Tama 1,1,1 Punt 12 </cilindros> <esferas> Posi 0,0,0,so Tama 1,1,1 Punt 12,11 </esferas> |
Moving near the O pointEach of the two objects is now moved so that the O point could be in some strategic place (because scaling and rotating are always done in reference with the O point). In order to do that move, we added two groups of lines around the code that describes each of the basic shapes: a first group to define the modification of coordinates, and a second group to put an end to it so that the following code should not be affected. |
<modifcoord>
Posi -0.5,-0.5,-1 </modifcoord> <cilindros> Posi 0,0,0,so Tama 1,1,1 Punt 12 </cilindros> <modifcoord> Fin </modifcoord> <modifcoord> Posi -0.5,-0.5,-0.5 </modifcoord> <esferas> Posi 0,0,0,so Tama 1,1,1 Punt 12,11 </esferas> <modifcoord> Fin </modifcoord> |
Moving near the O point,
|
<modifcoord>
Posi -0.5,-0.5,-1 Tama 1,1,2 </modifcoord> <cilindros> Posi 0,0,0,so Tama 1,1,1 Punt 12 </cilindros> <modifcoord> Fin </modifcoord> <modifcoord> Posi -0.5,-0.5,-0.5 Tama 1,1,2 </modifcoord> <esferas> Posi 0,0,0,so Tama 1,1,1 Punt 12,11 </esferas> <modifcoord> Fin </modifcoord> |
Moving near the O point,
Now, the two basic shapes have exactly the aspect that we wanted, but
we do not want their orientation to remain parallel with the three axes.
So we will now rotate the objects around these axes. |
<modifcoord>
Rotx -90 Rotz 30 </modifcoord> <modifcoord> Posi -0.5,-0.5,-1 Tama 1,1,2 </modifcoord> <cilindros> Posi 0,0,0,so Tama 1,1,1 Punt 12 </cilindros> <modifcoord> Fin </modifcoord> <modifcoord> Posi -0.5,-0.5,-0.5 Tama 1,1,2 </modifcoord> <esferas> Posi 0,0,0,so Tama 1,1,1 Punt 12,11 </esferas> <modifcoord> Fin </modifcoord> <modifcoord> Fin </modifcoord> |
Moving near the O point,
|
<modifcoord>
Rotx -90 Rotz 30 Posi 2,2,0.5 </modifcoord> <modifcoord> Posi -0.5,-0.5,-1 Tama 1,1,2 </modifcoord> <cilindros> Posi 0,0,0,so Tama 1,1,1 Punt 12 </cilindros> <modifcoord> Fin </modifcoord> <modifcoord> Posi -0.5,-0.5,-0.5 Tama 1,1,2 </modifcoord> <esferas> Posi 0,0,0,so Tama 1,1,1 Punt 12,11 </esferas> <modifcoord> Fin </modifcoord> <modifcoord> Fin </modifcoord> |
- Syntax
Rotations around the Z axis are the most common, as they are the ones that allow you to modify the orientation of an horizontal object. Rotations around the X and Y axes are generally orthogonal, and used to transform an horizontal object into a vertical one or viceversa.
- General logic
- Defining the modification of coordinates
In order to understand the result, we recommend that you use the order we have seen in the example: Of course, you can skip one or more of these steps if you do not need it.
- Putting an end to the modification
Fin does not put an end to all the modifications of coordinates, but only to the current one. If there is an imbrication of modifcoord instructions, Fin will only have the effect to come back to the previous logical level of modifications. |
Use hierarchical structures |
This feature allows you to call a CBB file from another. Generally, this will be used so that a file describing a complex scene will call some simpler objects: a file describing a house will call files describing rooms, a file describing a room will call files describing its furniture, a file describing a chair will call files describing its legs, etc. The current version of our translating program manages one hundred hierarchical levels... and you'll probably never need more than ten. The coordinates of the included files may be modified with the modifcoord instructions we just saw: you'll only have to write the lines describing the inclusion between the two modifcoord groups of lines. This is extremely useful, especially if you work with other fans' files and do not want to lose time to understand their logic: you just include them where you want. The same file may be called various times by a file of higher hierarchical level. For instance, you can use four times the same file describing a chair to put four different chairs around a table. That makes your code smaller, easier to understand, to test and to modify.
- Syntax
The DOS name of the file may not include its path, if you launch your Basic interpreter from the correct subdirectory when you translate the file. |
Transform all that to standard files |
Nothing new: we already talked about that topic in the other pages of this site. We only wanted to insist on the fact that all the efforts you will do to understand our format will be useful to you when you work with more standard software, as you can translate all the CBB files that you'll write with our translating program. Enjoy, and let us know your creations... or the problems that you've met. |