Transform MyAvatarHeadTransformNode::getTransform() {
    auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();

    glm::vec3 pos = myAvatar->getHeadPosition();
    glm::vec3 scale = glm::vec3(myAvatar->scaleForChildren());
    glm::quat headOri = myAvatar->getHeadOrientation();
    glm::quat ori = headOri * glm::angleAxis(-PI / 2.0f, Vectors::RIGHT);

    return Transform(ori, scale, pos);
}
Exemplo n.º 2
0
void Stereo3D::setViewDirection(FGLRenderer& renderer) {
	// Set HMD angle parameters for NEXT frame
	static float previousYaw = 0;
	if (mode == OCULUS_RIFT) {
		PitchRollYaw prw = getHeadOrientation(renderer);
		if (oculusTracker->isGood()) {
			oculusTracker->update(); // get new orientation from headset.
			double dYaw = prw.yaw - previousYaw;
			G_AddViewAngle(-32768.0*dYaw/3.14159); // determined empirically
			previousYaw = prw.yaw;

			// Pitch
			int pitch = -32768/3.14159*prw.pitch;
			int dPitch = (pitch - viewpitch/65536); // empirical
			G_AddViewPitch(-dPitch);

			// Roll can be local, because it doesn't affect gameplay.
			renderer.mAngles.Roll = prw.roll * 180.0 / 3.14159;
		}
	}
}