bool S3D_FILENAME_RESOLVER::SetProjectDir( const wxString& aProjDir, bool* flgChanged ) { if( aProjDir.empty() ) return false; wxFileName projdir( aProjDir, wxT( "" ) ); projdir.Normalize(); if( false == projdir.DirExists() ) return false; m_curProjDir = projdir.GetPath(); if( flgChanged ) *flgChanged = false; if( m_Paths.empty() ) { S3D_ALIAS al; al.m_alias = _( "(DEFAULT)" ); al.m_pathvar = _( "${PROJDIR}" ); al.m_pathexp = m_curProjDir; al.m_description = _( "Current project directory" ); m_Paths.push_back( al ); m_NameMap.clear(); if( flgChanged ) *flgChanged = true; } else { if( m_Paths.front().m_pathexp.Cmp( m_curProjDir ) ) { m_Paths.front().m_pathexp = m_curProjDir; m_NameMap.clear(); if( flgChanged ) *flgChanged = true; } else { return true; } } #ifdef DEBUG do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] changed project dir to "; ostr << m_Paths.front().m_pathexp.ToUTF8(); wxLogTrace( MASK_3D_RESOLVER, "%s\n", ostr.str().c_str() ); } while( 0 ); #endif return true; }
void SoPerspectiveCameraManager::setZoomValueByDolly(float zoomvalue, SbBool COIN_UNUSED_ARG(limit)) { if (!this->havezoombydollylimits) { // without unitydistance, we don't know anything return; } SoPerspectiveCamera * camera = this->getCastCamera(); float focaldistance = camera->focalDistance.getValue(); SbVec3f projdir(0.0f, 0.0f, 0.0f); camera->orientation.getValue().multVec(SbVec3f(0.0f, 0.0f, -1.0f), projdir); SbVec3f focalpoint = camera->position.getValue() + projdir * focaldistance; float newdistance = this->unitydistance / zoomvalue; camera->position.setValue(focalpoint - projdir * newdistance); camera->focalDistance.setValue(newdistance); }
/* Performs a dolly and at the same time adjusts height to emulate how a perspective camera would zoom in */ void SoOrthoPerspectiveCameraManager::setZoomValueByDolly(float zoomvalue, SbBool limit) { if (!this->havezoombydollylimits) { // don't have the necessary information return; } static const float defaultangle = float(M_PI_4); static const float defaultheight = sin(defaultangle) / cos(defaultangle); // these are absolute, and wipes out existing non-dollied zoom. should fix float newdistance = 0.0f; if (zoomvalue < 0.0) { zoomvalue = 0.0; newdistance = 0.0; } else { newdistance = this->unitydistance / zoomvalue; if (limit) { if (newdistance < this->mindollydistance) { newdistance = this->mindollydistance; } else if (newdistance > this->maxdollydistance) { newdistance = this->maxdollydistance; } } if (newdistance < 0.0) { newdistance = 0.0; } } float newheight = newdistance * defaultheight; SoOrthographicCamera * camera = this->getCastCamera(); float focaldistance = camera->focalDistance.getValue(); SbVec3f projdir(0.0f, 0.0f, 0.0f); camera->orientation.getValue().multVec(SbVec3f(0.0f, 0.0f, -1.0f), projdir); SbVec3f focalpoint = camera->position.getValue() + projdir * focaldistance; camera->position.setValue(focalpoint - projdir * newdistance); camera->focalDistance.setValue(newdistance); camera->height.setValue(newheight); //printf("setting zoom:%g, distance:%g height=%g\n", zoomvalue, newdistance, newheight); }
void SoPerspectiveCameraManager::adjustZoomByDolly(float factor, SbBool limit) { SoPerspectiveCamera * camera = this->getCastCamera(); float focaldistance = camera->focalDistance.getValue(); float newdistance = focaldistance * (1.0f / factor); if (this->havezoombydollylimits && limit) { if (newdistance < this->mindollydistance) { newdistance = this->mindollydistance; } else if (newdistance > this->maxdollydistance) { newdistance = this->maxdollydistance; } } SbVec3f projdir(0.0f, 0.0f, 0.0f); camera->orientation.getValue().multVec(SbVec3f(0.0f, 0.0f, -1.0f), projdir); SbVec3f focalpoint = camera->position.getValue() + projdir * focaldistance; camera->position.setValue(focalpoint - projdir * newdistance); camera->focalDistance.setValue(newdistance); }