Using SVE for Virtual Environment Applications

Using SVE for Virtual Environment applications

I. Introduction

II. The simplest SVE program and what it means


#include "sve.h"

main(int argc, char *argv[])
{
	SVE_init("my_app", SVE_NORMAL, argc, argv);
	SVE_loadWorld("myworld.world");
	SVE_beginEventLoop();
}

III. A more advanced example

This example program presents a spinning cube in a virtual environment. It initially spins at 1 degree per frame. The rate of spinning can be increased by pressing the right mouse button, and decreased by pressing the left mouse button. This example illustrates the use of mouse and animation callbacks.


#include "sve.h"

SVE_object cube;
int num_degrees = 1;

SVE_status spinCube(SVE_state state)
{
	SVE_rotateObject(cube, num_degrees, 'y');
	return(EVENT_IGNORED);
}

SVE_status increaseDegrees(SVE_state state)
{
	if(SVE_IS_PRESS_EVENT(state->eventType) &&
		((SVE_stateChangeEvent *)state->eventData)->pressed)
			num_degrees++;

	return(EVENT_CONSUMED);
}

SVE_status decreaseDegrees(SVE_state state)
{
	if(SVE_IS_PRESS_EVENT(state->eventType) &&
		((SVE_stateChangeEvent *)state->eventData)->pressed)
			num_degrees--;

	return(EVENT_CONSUMED);
}

main()
{
	SVE_init("my_app", SVE_NORMAL);
	SVE_loadWorld("cube.world");
	cube = SVE_findWorldObject("cube");

	SVE_addAnimationCallback(spinCube);
	SVE_registerCallback(SVE_LEFT_MOUSE, decreaseDegrees);
	SVE_registerCallback(SVE_RIGHT_MOUSE, increaseDegrees);

	SVE_beginEventLoop();
}

IV. Distributed processes (servers)

V. How the user is modeled

VI. Important SVE functions

VII. Important SVE data structures