コード例 #1
0
ファイル: CameraSupport.cpp プロジェクト: AlphaPixel/3DNature
void ComputeOrientation(const osg::Vec3& lv,const osg::Vec3& up, osg::Quat &rotationDest)
{
osg::Vec3 f(lv);
f.normalize();
osg::Vec3 s(f^up);
s.normalize();
osg::Vec3 u(s^f);
u.normalize();


{
__asm NOP
}


osg::Matrix rotation_matrix(s[0],     u[0],     -f[0],     0.0f,
                            s[1],     u[1],     -f[1],     0.0f,
                            s[2],     u[2],     -f[2],     0.0f,
                            0.0f,     0.0f,     0.0f,      1.0f);
rotationDest.set(rotation_matrix);
//debug_matrix = rotation_matrix;
//debug_quat = rotationDest;
rotationDest = rotationDest.inverse();

} // ComputeOrientation
コード例 #2
0
static void invertOSGTransform(osg::Vec3d& trans, osg::Quat& quat,
        osg::PositionAttitudeTransform*& source, osg::PositionAttitudeTransform*& target,
        std::string& source_frame, std::string& target_frame)
{
    quat = quat.inverse();
    trans = -(quat * trans);
    std::swap(source, target);
    std::swap(source_frame, target_frame);
}
コード例 #3
0
/* Public functions */
void OculusHealthAndSafetyWarning::updatePosition(osg::Matrix cameraMatrix, osg::Vec3 position, osg::Quat orientation) {
	if (m_transform.valid()) {
		osg::Matrix matrix;
		matrix.setTrans(osg::Vec3(0.0, 0.0, -m_distance));
		matrix.postMultRotate(orientation.inverse());
		matrix.postMultTranslate(-position);
		m_transform->setMatrix(matrix*cameraMatrix);
	}
}