Ejemplo n.º 1
0
void vrlib_wand_posvec (float wand_pos[], float wand_vec[], int virt_world)
{
    vrPoint    pos;
    vrVector   vec;

    if (virt_world)
    {
        vrPointGetVWFromUser6sensor (&pos, 0, WAND_SENSOR);
        wand_pos[VR_X] = pos.v[VR_X];
        wand_pos[VR_Y] = pos.v[VR_Y];
        wand_pos[VR_Z] = pos.v[VR_Z];
        vrVectorGetVWFromUser6sensorDir (&vec, 0, WAND_SENSOR, VRDIR_FORE);
        wand_vec[VR_X] = vec.v[VR_X];
        wand_vec[VR_Y] = vec.v[VR_Y];
        wand_vec[VR_Z] = vec.v[VR_Z];
    }
    else
    {
        vrPointGetRWFrom6sensor (&pos, WAND_SENSOR);
        wand_pos[VR_X] = pos.v[VR_X];
        wand_pos[VR_Y] = pos.v[VR_Y];
        wand_pos[VR_Z] = pos.v[VR_Z];
        vrVectorGetRWFrom6sensorDir (&vec, WAND_SENSOR, VRDIR_FORE);
        wand_vec[VR_X] = vec.v[VR_X];
        wand_vec[VR_Y] = vec.v[VR_Y];
        wand_vec[VR_Z] = vec.v[VR_Z];
    }
    return;
}
Ejemplo 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
}