void CameraTool::zoomout () { if ( _isInConstraintMode && ( _currentScale <= _minScale )) _currentScale = _minScale; else _currentScale /= 1.2; camera_scale ( _pview->camid(), _currentScale ); _pview->updateWindow (); }
float CameraTool::find_view ( const SGR::vec3f& minvec, const SGR::vec3f& maxvec, float percentOfView ) { // translate SGR::vec3f center = ( minvec + maxvec ) / 2.0f; // scale float s = calcScale ( minvec, maxvec ); if ( s != 0 ) { _currentScale = percentOfView / s; camera_reset ( _pview->camid() ); camera_translate ( _pview->camid(), center.x(), center.y(), center.z() ); camera_scale ( _pview->camid(), _currentScale ); _currentTranslate.xyz ( center.x(), center.y(), center.z() ); } return _currentScale; }
void CameraTool::locateAll () { float min[3], max[3]; get_bbox ( 0, min, max ); SGR::vec3f dimension ( max[0]-min[0], max[1]-min[1], max[2]-min[2] ); // calculate scale if ( dimension.x() > dimension.y() ) _currentScale = _pview->getHeight() / (_pview->getVPM() * SGR::vec4f(1,0,0,1)).mod(); else _currentScale = _pview->getWidth() / (_pview->getVPM() * SGR::vec4f(1,0,0,1)).mod(); // calculate center _currentTranslate = SGR::vec3f ( (max[0]+min[0])/2.0, (max[1]+min[1])/2.0, (max[2]+min[2])/2.0 ); // do change camera camera_translate ( _pview->camid(), _currentTranslate.x(), _currentTranslate.y(), _currentTranslate.z() ); camera_scale ( _pview->camid(), _currentScale ); _pview->updateWindow(); }
KFbxXMatrix FilmboxNode::GetWorldTransform( int frame ) const { KFbxXMatrix value; value.SetIdentity(); if( m_node ) { KFbxScene* scene = m_node->GetScene(); KFbxAnimEvaluator* evaluator = scene->GetEvaluator(); KTime frame_time; if( frame == 0xFFFFFFFF ) { frame_time = KTIME_INFINITE; } else { frame_time.SetTime( 0, 0, 0, frame ); } value = evaluator->GetNodeGlobalTransform( m_node, frame_time ); if( m_type == MCE::FBX::SceneObjectType::CAMERA ) { KFbxNode* fbx_target_node = m_node->GetTarget(); if( fbx_target_node ) { // For target cameras we need to manually replace the rotation to point towards the target KFbxVector4 camera_position = value.GetT(); MCE::FBX::FilmboxNode mce_target_node( fbx_target_node ); KFbxXMatrix target_transform = mce_target_node.GetWorldTransform( frame ); KFbxVector4 target_position = target_transform.GetT(); KFbxVector4 up_vector( 0.0, 1.0, 0.0, 0.0 ); KFbxVector4 look_axis = -( target_position - camera_position ); look_axis.Normalize(); KFbxVector4 right_axis = up_vector.CrossProduct( look_axis ); KFbxVector4 up_axis = look_axis.CrossProduct( right_axis ); KFbxMatrix rotation_matrix; rotation_matrix.SetRow( 0, right_axis ); rotation_matrix.SetRow( 1, up_axis ); rotation_matrix.SetRow( 2, look_axis ); rotation_matrix.SetRow( 3, KFbxVector4( 0.0, 0.0, 0.0, 1.0 ) ); KFbxQuaternion camera_rotation; double determinant; rotation_matrix.GetElements( KFbxVector4(), camera_rotation, KFbxVector4(), KFbxVector4(), determinant ); KFbxVector4 camera_scale( 1.0, 1.0, 1.0, 0.0 ); value.SetTQS( camera_position, camera_rotation, camera_scale ); } else { // Even though the SDK docs say that GetNodeGlobalTransform takes all transforms into account // For cameras it appears that you have to manually apply post-rotation KFbxVector4 post_rotation = m_node->GetPostRotation( KFbxNode::eSOURCE_SET ); KFbxXMatrix fbx_to_mce_camera; fbx_to_mce_camera.SetR( post_rotation ); value *= fbx_to_mce_camera; } } } return value; }