Callisto is provided as a Windows DLL. It has been tested with Microsoft Visual 2010.
To start using the library, take the following steps:
- First install the package.
- Next, start a new project in Visual C++, this can be any type of project, but here we will assume it is a Win32 command line project.
- Go to project properties->General->Additional include directories and add the path to the header files there.
- The next step is to add the library to the input list. Go to the project properties->linker->input and add callisto50.lib to the addition dependencies list.
- Now include callisto50.h (and callisto50Types.h if necessary) in your code.
- Finally, copy the content of the bin directory to your debug and/or releases directory.
Thats all! Now Callisto is ready to be used.
An example, see the comments in the code for explanation:
#include "../include/callisto50.h"
#include <conio.h>
#include <iostream>
int main(int argc, char* argv[])
{
// initialize Callisto
if (CAL_Initialisation (true, "callisto.log")!=CAL_SUCCESS) {
printf ("Error creating log (do you have write permissions in this folder?).");
_getch();
return -1;
}
// show a visualisation
CAL_ShowView (0, "Callisto Sample");
CAL_SetViewOptions (0, CAL_HIDEGROUNDPLANE | CAL_HIDEGRID);
// it is good practise to suspend visualisation until the scene has been set-up
// this speeds up operation
CAL_SuspendVisualisation();
// add a texture resource
CAL_AddTextureResource (".");
int textureId=0;
int res = CAL_LoadTexture (textureId, "grass_1024.jpg");
// create some object groups and create some objects
int groupId0, groupId1, groupId2, sphereId, coneId, boxId, tetrahedronId, elevationGridId;
CAL_CreateGroup (&groupId0, 0, true, "Cone group");
CAL_CreateGroup (&groupId1, 0, true, "Sphere group");
CAL_CreateGroup (&groupId2, 0, true, "Grass group");
// create a cone and a sphere
CAL_CreateCone (groupId0, 20, 50, &coneId);
CAL_SetObjectPosition (coneId, 0, 25, 0);
CAL_CreateSphere (groupId1, 10, &sphereId);
CAL_SetObjectPosition (coneId, 0, 40, 0);
// define the four corners of the tetrahedron
float t[12] = {40,0,40, 50,0,40, 40,0,50, 40,30,40};
CAL_CreateTetrahedron (groupId2, t, &tetrahedronId);
// use a loop to create some boxes
for (float i=0; i<10; i++) {
float angle = i*(6.28f/10);
CAL_CreateBox (groupId2, 5, 35, 5, &boxId);
CAL_SetObjectPosition (boxId, 40*sin(angle), 17.5f, 40*cos(angle));
}
int nrCols;
// check if sphere group collides with cone group
CAL_CheckGroupCollision (groupId0, groupId1, false, &nrCols);
if (nrCols>0) {
// if they collide, change color of sphere
CAL_SetObjectColor (sphereId, 0, 1, 0);
}
// give the cone label
CAL_CreateLabel (coneId, "My first\nCone", 5, 20, 20, 20);
// create an elevation grid
float heights[2601];
for (int i=0; i<2601; i++) {
heights[i] = (float)rand()/(RAND_MAX/10.0f);
}
CAL_CreateElevationGrid (groupId2, 50, 50, 50, 50, heights, &elevationGridId);
CAL_SetObjectPosition (elevationGridId, -1250, 0, -1250);
CAL_SetObjectTexture (elevationGridId, textureId, 20, 20);
// resume rendering
CAL_ResumeVisualisation();
_getch();
// let the sphere rotate around the cone
float spherePos[3] = {0, 40, 0};
for (float i=0; i<6.28f; i+=0.1f) {
spherePos[0] = sin(i)*40;
spherePos[2] = cos(i)*40;
CAL_SetObjectPosition (sphereId, sin(i)*40,50,cos(i)*40, i);
}
_getch();
// end Callisto
CAL_End();
return 0;
}
All functions and their descriptions can be found in the documentation.
|