GwieF.com : project.GrieF.com : Language Definition
logo

Language Definition

/* comments */
// comments

shape <name> ( <shape type> ) {
<shape options>
}

light <name> {
<light options>
}

node <name> ( <nodea> , <BOOLEAN OPERATOR>, <nodeb> ){ <node options> }

startnode <node>




See an Example Input File



Naming

Names like the rest of the language are case independent (i.e. CHAIR is the same as chair is the same as ChAiR). A name can be any letter followed by any series of numbers or letters. Spaces and other characters are not valid and will cause an error. every shape and node must have a unique name. If you try to create a shape with a name already in use an error will be given.




Nodes

A node is a shape or result of boolean operations between shapes. Each node must have a unique name which allows it to be referenced




Objects

A number of objects go together to make up a model. This is a description of them and how they interact

Shapes

syntax:

	shape <name> ( <shape type> ) { <options> } 

A Shape is the basic building block for your model. Its the only thing that actually gets drawn to the screen.
There are various different shapes available see shape types for specific information

 
Lights

syntax:

	light <name> { <light options> } 

A Light provides illumination for your shapes. You can't actually see a light, only its affect on shapes around it.
just like in the real world you need lights to be able to see things. Lights can be given an intensity (brightness), a color, and a position

 
Nodes

syntax:

	node <name> ( <nodea> , <BOOLEAN OPERATOR> , <nodeb> ){ <node options> } 

A node is a way of combining shapes. nodea and nodeb in this context can be either other nodes or shapes. This way you can build up a tree like structure of combinations of shapes to give the end result

 
Startnode

syntax:

	startnode <node>

startnode is a special case. It does not create anything, it just points to a node (node or shape). You must set startnode to the top level node in your tree. If you don't define a nodestart, or if a shape isn't a leaf of the tree starting from nodestart then the shape/shapes will not be rendered.

 



comments

/* comments */

anything surrounded by /* */ (C style comments) will be ignored

 
// comments

anything after // until the end of the line will also be ignored (C++ style comments)

 



Shape Types

sphere

syntax:

	shape <name> ( sphere ) { <options> }
   

creates a sphere diameter 1 (radius 0.5), centered around (0,0,0).

 
box

syntax:

	shape <name> ( box ) { <options> }
   

creates a box (cube) with each side of length 1 with sides in the X,Y,Z axies, centered around (0,0,0).

 
cylinder

syntax:

	shape <name> ( cylinder ) { <options> }
   

creates a cylinder height 1, diameter 1 with the ends in the Y axis (facing up and down), centered around (0,0,0).

 
cone

syntax:

	shape <name> ( cone ) { <options> }
   

ceates a cone height 1, base diameter 1 with the point facing up (positive Y), centered around (0,0,0).

 
hyperboloid

syntax:

	shape <name> ( hyperboloid ) { <options> }
   

ceates a hyperboloid height 1, diameter 1 (at ends) with ends in the Y axis (facing up and down), centered around (0,0,0).

 



Shape Options

note The order that the translate, rotate, and scale operators DOES matter. The correct order is translate then rotate then scale. Other orders are valid but will produce strange results

translate

syntax:

	translate ( X , Y , Z );

x,y,z are double precision coordinates.
note : right handed coordinate system so positive Z goes into the screen.

 
rotatex

syntax:

	rotatex ( ø );

ø is an angle in degrees to rotate by.

 
rotatey

syntax:

	rotatey ( ø );

ø is an angle in degrees to rotate by.

 
rotatez

syntax:

	rotatez ( ø );

ø is an angle in degrees to rotate by.

 
scale

syntax:

	scale ( X , Y , Z );

X,Y,Z are double precision numbers which scale alone the relevent axis.
for example scale(1,1,2); would double the height (y axis) of the shape.

 
color

syntax:

	color( R , G , B );

R,G,B are the RED, GREEN and BLUE values that make up a color.
R,G,B must be in the range 0 - 1
note Values outside the range 0-1 are reduced to the nearest correct value.

 
shine

syntax:

	shine ( n );

n is a measure if the 'shineyness' of the object.
typical values 1 for matte object - 20 for highly polished metal.

 
specular

syntax:

	specular ( Ks );

Ks is a measure of how much of the incoming light is reflected in a specular (shiney) fashion.
must be in the range 0 - 1
0 = no specular reflection, 1 = max specular reflection.

 
diffuse

syntax:

	diffuse ( Kd );

Kd is a measure of how much of the incoming light is reflected in a diffuse (matte) fashion.
must be in the range 0 - 1
0 = no diffuse reflection, 1 = max diffuse reflection.

 
transparency

syntax:

	transparency ( T );

T is a measure of how much light passes through the shape.
must be in the range 0 - 1
0 = no transparency, 1 = max transparency.

 
reflection

syntax:

	reflection ( R );

R is a measure of how much light is reflected off the shape.
must be in the range 0 - 1
0 = no reflection, 1 = mirror like.

 
density

syntax:

	density ( D );

D is a measur of how 'dense' a shape is (thus how much light refracts when passing through it)
note only applicable to shapes with a transparency > 0.
must be in the range 0 - 1
0 = max refraction, 1 = no refrection.

 



Light Options

color

syntax:

	color ( R , G , B );
   

sets the color of the light to be the color represented by (R,G,B). Default = white.

 
position

syntax:

	position ( X , Y , Z );
   

sets the position of the light. Default = (0,0,0);

 
intensity

syntax:

	intensity ( I );
   

sets the intensity of the light. Recomended range 0 - 1. Default = 1.

 



Boolean Operators

add

syntax:

	node <name> ( <nodea> , add , <nodeb> ){ <node options> }
   

The 'and' keyword causes the shapes represented by the 2 nodes to be added together

 
subtract

syntax:

	node <name> ( <nodea> , subtract , <nodeb> ){ <node options> }
   

The 'subtract' keyword causes nodeb to be 'cut out' of nodea.

 
intersect

syntax:

	node <name> ( <nodea> , intersect , <nodeb> ){ <node options> }
   

The 'intersect' keyword results in the volume that both nodea and nodeb occupy.

 



Node Options

translate

syntax:

	translate ( X , Y , Z );

x,y,z are double precision coordinates.
note : right handed coordinate system so positive Z goes into the screen.
causes all objects within this node to be translated by the specified amount

 
rotatex

syntax:

	rotatex ( ø );

ø is an angle in degrees to rotate by.
causes all objects within this node to be rotated by the specified amount.

 
rotatey

syntax:

	rotatey ( ø );

ø is an angle in degrees to rotate by.
causes all objects within this node to be rotated by the specified amount.

 
rotatez

syntax:

	rotatez ( ø );

ø is an angle in degrees to rotate by.
causes all objects within this node to be rotated by the specified amount.

 
scale

syntax:

	scale ( X , Y , Z );

X,Y,Z are double precision numbers which scale alone the relevent axis.
for example scale(1,1,2); would double the height (y axis) of the all objects within this node.