Exemplo n.º 1
0
void vrlib_nav_unlock (void)
{
    vrUserTravelLockRelease (VR_ALLUSERS);
    return;
}
Exemplo n.º 2
0
void update_world()
{
static	vrTime		lastTime = -1;
	vrTime		deltaTime;
	float		joy_x, joy_y;
	vrVector	vec;
	int		input;

	if (lastTime < 0)
		lastTime = vrCurrentSimTime();

	/* do some traveling. */
	deltaTime = vrCurrentSimTime() - lastTime;
	lastTime += deltaTime;

	joy_x = vrGetValuatorValue(0);
	joy_y = vrGetValuatorValue(1);

	vrUserTravelLockSet(VR_ALLUSERS);
	if (fabs(joy_x) > 0.125) {
		vrUserTravelRotateId(VR_ALLUSERS, VR_Y, deltaTime * joy_x * -25.0);
	}

	if (fabs(joy_y) > 0.125) {
		vrVectorGetRWFrom6sensorDir(&vec, 1, VRDIR_FORE);
		vrVectorScale(&vec, deltaTime * joy_y * 2.5);
		vrUserTravelTranslateAd(VR_ALLUSERS, vec.v);
	}

	/* NOTE: this if relies on lazy evaluation -- the second condition */
	/*   shouldn't be checked if the first isn't true.                 */
	if (vrContext->input->num_2ways > 1 && vrGet2switchValue(1)) {
		vrUserTravelReset(VR_ALLUSERS);
	}

	/* NOTE: this if statement relies on lazy evaluation */
	if (vrContext->input->num_2ways > 2 && vrGet2switchValue(2)) {
		vrUserTravelTranslate3d(VR_ALLUSERS, 0.1, 0.0, 0.0);
	}
	/* NOTE: this if statement relies on lazy evaluation */
	if (vrContext->input->num_2ways > 3 && vrGet2switchValue(3)) {
		vrUserTravelTranslate3d(VR_ALLUSERS, -0.1, 0.0, 0.0);
	}
	vrUserTravelLockRelease(VR_ALLUSERS);

	/* set DebugLevel to 200 to print this info to screen every frame */
	if (vrDbgDo(RARE_DBGLVL)) {
		vrMsgPrintf("TRAVEL: controller --");

		vrMsgPrintf(" buttons:");
		for (input = 0; input < vrContext->input->num_2ways; input++)
			vrMsgPrintf(" %d", vrContext->input->switch2[input]->value);

		vrMsgPrintf(" valuators:");
		for (input = 0; input < vrContext->input->num_valuators; input++)
			vrMsgPrintf(" %6.3f", vrContext->input->valuator[input]->value);

		vrMsgPrintf("\n");
	}

#if 1
	/* Demonstration of how to segment different portions of the simulation in the statistics display */
	vrSystemSimCategory(1);		/* up until this point, count time spent in simulation as category-1 */
	vrSleep(10000);
	vrSystemSimCategory(2);		/* between last Stats call and this one, count time spent as category-2 */
	vrSleep(5000);
	/* NOTE: time spent from last stats call (or beginning) is counted as category-1 */
#else
	/* allow other processes to get some work done */
	vrSleep(1);
#endif
}