//==== Get the sub surfaces from all geoms ====// vector< SubSurface* > SubSurfaceMgrSingleton::GetSubSurfs() { vector< SubSurface* > ret_vec; Vehicle* veh = VehicleMgr.GetVehicle(); if( !veh ) { return ret_vec; } vector<Geom*> geoms = veh->FindGeomVec( veh->GetGeomVec() ); for ( int i = 0 ; i < ( int )geoms.size() ; i++ ) { const vector< SubSurface* > SubSurfVec = geoms[i]->GetSubSurfVec(); for ( int j = 0 ; j < ( int )SubSurfVec.size() ; j++ ) { ret_vec.push_back( SubSurfVec[j] ); } } return ret_vec; }
//==== Get All FeaStructures ====// vector < FeaStructure* > StructureMgrSingleton::GetAllFeaStructs() { vector < FeaStructure* > feastructvec; Vehicle* veh = VehicleMgr.GetVehicle(); if ( veh ) { vector< Geom* > geom_vec = veh->FindGeomVec( veh->GetGeomVec( false ) ); for ( unsigned int i = 0; i < geom_vec.size(); i++ ) { vector < FeaStructure* > geomstructvec = geom_vec[i]->GetFeaStructVec(); for ( unsigned int j = 0; j < geomstructvec.size(); j++ ) { feastructvec.push_back( geomstructvec[j] ); } } } return feastructvec; }
void SVGOptionsScreen::GetScale( int write_set ) { bool foundgeom = false; Vehicle *veh = VehicleMgr.GetVehicle(); vector< Geom* > geom_vec = veh->FindGeomVec( veh->GetGeomVec( false ) ); BndBox svgbox; for ( int i = 0 ; i < ( int )geom_vec.size() ; i++ ) { if ( geom_vec[i]->GetSetFlag( write_set ) ) { svgbox.Update( geom_vec[i]->GetBndBox() ); foundgeom = true; } } if ( !foundgeom ) { veh->m_Scale.Set( 0 ); // Set to 0 if no geoms are in the set return; } double length = svgbox.DiagDist(); double convert_scale; if ( length >= 1.0 ) { convert_scale = floor2scale( length, pow( 10.0, mag( length ) ) ); } else { convert_scale = floor2scale( length, pow( 10.0, mag( length ) - 1 ) ); } veh->m_Scale.Set( convert_scale ); }
bool ManageTextureScreen::Update() { assert( m_ScreenMgr ); Vehicle* veh = m_ScreenMgr->GetVehiclePtr(); vector< Geom* > select_vec = veh->GetActiveGeomPtrVec(); if ( select_vec.size() != 1 ) { Hide(); return false; } // Redo list on each update. m_TextureMgrUI->compChoice->clear(); m_CompDropDownList.clear(); std::vector<Geom *> geomVec = veh->FindGeomVec( veh->GetGeomVec() ); for( int i = 0; i < ( int )geomVec.size(); i++ ) { CompDropDownItem item; item.GeomName = geomVec[i]->GetName(); item.GeomID = geomVec[i]->GetID(); // Hack to add duplicate names char str[256]; sprintf( str, "%d", i ); item.GUIIndex = m_TextureMgrUI->compChoice->add( str ); m_CompDropDownList.push_back( item ); } // Fill Hacked char array with correct names. for( int i = 0; i < ( int )m_CompDropDownList.size(); i++ ) { m_TextureMgrUI->compChoice->replace( m_CompDropDownList[i].GUIIndex, m_CompDropDownList[i].GeomName.c_str() ); } // Set compChoice to current selected and update texture dropdown list. for( int i = 0; i < ( int )m_CompDropDownList.size(); i++ ) { if( m_CompDropDownList[i].GeomID == select_vec[0]->GetID() ) { m_TextureMgrUI->compChoice->value( m_CompDropDownList[i].GUIIndex ); // Update Texture Dropdown List. // // Redo texture list on each update. m_TextureMgrUI->textureChoice->clear(); m_TexDropDownList.clear(); // Clear preview window. VSPGraphic::Viewport * viewport = m_GlWin->getGraphicEngine()->getDisplay()->getViewport(); assert( viewport ); viewport->getBackground()->removeImage(); // Load Textures... TextureMgr * texMgr = select_vec[0]->m_GuiDraw.getTextureMgr(); std::vector<Texture*> texInfos = texMgr->FindTextureVec( texMgr->GetTextureVec() ); for( int j = 0; j < ( int )texInfos.size(); j++ ) { TexDropDownItem item; item.TexInfo = texInfos[j]; // Hack to add duplicate names char str[256]; sprintf( str, "%d", j ); item.GUIIndex = m_TextureMgrUI->textureChoice->add( str ); m_TexDropDownList.push_back( item ); } // Fill Hacked char array with correct names. for( int j = 0; j < ( int )m_TexDropDownList.size(); j++ ) { m_TextureMgrUI->textureChoice->replace( m_TexDropDownList[j].GUIIndex, m_TexDropDownList[j].TexInfo->GetName().c_str() ); } if( !m_TexDropDownList.empty() ) { if( m_SelectedTexItem ) { m_TextureMgrUI->textureChoice->value( m_SelectedTexItem->GUIIndex ); } else { // On refresh list, if nothing is selected, pick last item on list. m_TextureMgrUI->textureChoice->value( m_TexDropDownList[m_TexDropDownList.size() - 1].GUIIndex ); } UpdateCurrentSelected(); assert( m_SelectedTexItem ); viewport->getBackground()->attachImage( VSPGraphic::GlobalTextureRepo()-> get2DTexture( m_SelectedTexItem->TexInfo->m_FileName.c_str() ) ); } else { ResetCurrentSelected(); // Force redraw empty list. m_TextureMgrUI->textureChoice->redraw(); } // Update Sliders and Buttons. if( m_SelectedTexItem ) { Texture * info = select_vec[0]->m_GuiDraw.getTextureMgr()->FindTexture( m_SelectedTexItem->TexInfo->GetID() ); m_TextureMgrUI->textureNameInput->value( info->GetName().c_str() ); m_UScaleSlider.Update( info->m_UScale.GetID() ); m_WScaleSlider.Update( info->m_WScale.GetID() ); m_UPosSlider.Update( info->m_U.GetID() ); m_WPosSlider.Update( info->m_W.GetID() ); m_TransparencySlider.Update( info->m_Transparency.GetID() ); m_FlipUButton.Update( info->m_FlipU.GetID() ); m_FlipWButton.Update( info->m_FlipW.GetID() ); } break; } } m_GlWin->redraw(); return true; }