Пример #1
0
int main ()
{
	Screen primary; //Declaring the primary output Screen object.

	Window cartesian; //Declaring the output Window for the 3D display.

	R3Cam camera; //Declaring the 3D camera object (initially placed at coordinates (0, 0, 0)).

	TreasureChest chest0; //Declaring an example TreasureChest object.


	/*Insert TreasureChest class commands, such as openlid, movechest, and rotchest here to view the effects of these functions.*/


	primary.addlayer (&cartesian); //Adding the 3D output window to the screen.

	camera.setviewsize (40, 78); //Setting the view size of the 3D camera object.

	camera.setcampos (-5.00, 3, 1.50); //Adjusting the camera position to center its view of the object.

	camera.addobject (chest0.putchest ()); //Adding the instantaneous R3Object data for chest0 to the camera's field of vision.

	camera.drawobjects (); //Calculating and drawing the 3D perspective to the camera's output vector.

	cartesian.loadfromvector (camera.putview (), 78); //Dumping the newly constructed camera image to the window.

	primary.displayscr (); //Outputting the screen contents to the terminal.

	return 0;

	/*This is only one possible way of implementing an advanced object in the TEROS Engine. The purpose of this example is primarily to clarify the meaning and intent of advanced object functionality.*/
}
Пример #2
0
int main ()
{
	Screen primary; //Declaring primary Screen object.

	Window content; //Declaring a Window object to hold the programmatic vector content.

	vector <char> pattern (0); //Declaring a character vector to hold the content to be loaded into the Window object.


	primary.addlayer (&content); //Adding the content window to the screen.


	/*Creating a checker pattern within the character vector.*/

	for (int i = 0; i < 40; i++)
	{
		for (int j = 0; j < 78; j++)
		{
			pattern.resize (pattern.size () + 1);
			pattern [pattern.size () - 1] = ((i + j)%2) == 0 ? ' ' : '#';
		}
	}


	content.loadfromvector (pattern, 78); //Loading the character vector information into the content window. The number of columns is specified in the arguments.

	primary.displayscr (); //Outputting the screen contents.

	return 0;

	/*This might seem a bit unintuitive at first, so you might want to try doing this with a vector containing more complex information.*/

}
Пример #3
0
int main ()
{
	Screen primary; //Declaring the primary output Screen object.

	Window cartesian; //Declaring the output Window for the 3D display.

	R3Cam camera; //Declaring the 3D camera object (initially placed at coordinates (0, 0, 0)).

	R3Object obj; //Declaring the 3D container object.

	NPolygon shape; //Declaring the n sided polygon to be defined.

	vector <double> x (0); //Declaring vectors to hold the x, y, and z coordinates of the NPolygon vertices.
	vector <double> y (0);
	vector <double> z (0);

	x.resize (4); //Resizing the vertex coordinate vectors to reflect the number of vertices in the NPolygon.
	y.resize (4);
	z.resize (4);

	/*Setting the coordinates for the NPolygon vertices in counter-clockwise order.*/

	x [0] = 10;
	x [1] = 10;
	x [2] = 10;
	x [3] = 10;

	y [0] = -3;
	y [1] = 0;
	y [2] = 3;
	y [3] = 0;

	z [0] = -3;
	z [1] = 0;
	z [2] = -3;
	z [3] = 3;

	shape.generatenpoly (x, y, z); //Creating the sub-Polygons that comprise the NPolygon (populates the 'triangles' list within the NPolygon).

	obj.addnside (&shape); //Adding the NPolygon to the R3Object, obj.

	primary.addlayer (&cartesian); //Adding the 3D output window to the screen.

	camera.setviewsize (40, 78); //Setting the view size of the 3D camera object.

	camera.addobject (&obj); //Adding the object containing the NPolygon to the 3D camera's field of vision.

	camera.drawobjects (); //Calculating and drawing the 3D perspective to the camera's output vector.

	cartesian.loadfromvector (camera.putview (), 78); //Dumping the newly constructed camera image to the window.

	primary.displayscr (); //Outputting the screen contents to the terminal.

	return 0;

	/*Try defining other polygons with more than 3-vertices.*/
}