// ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- void ChSingleIdler::AddVisualizationAssets(VisualizationType vis) { ChIdler::AddVisualizationAssets(vis); if (vis != VisualizationType::PRIMITIVES) return; double radius = GetWheelRadius(); double width = GetWheelWidth(); auto cyl = std::make_shared<ChCylinderShape>(); cyl->GetCylinderGeometry().p1 = ChVector<>(0, width / 2, 0); cyl->GetCylinderGeometry().p2 = ChVector<>(0, -width / 2, 0); cyl->GetCylinderGeometry().rad = radius; m_wheel->AddAsset(cyl); auto tex = std::make_shared<ChTexture>(); tex->SetTextureFilename(chrono::GetChronoDataFile("bluwhite.png")); m_wheel->AddAsset(tex); }
int CBSPMapData_LW::LoadSpecificMapDataFromFile( const char *pFilename ) { int i; bool bResult = false; CLightWaveSceneLoader lightwave_scene; // load the LightWave scene file lightwave_scene.LoadFromFile( pFilename ); // MessageBox(NULL, "LW scene file has been loaded", "progress report", MB_OK); //First, we have to get the name of the mapfile in this "*.lws" file //The name of the mapfile has to be "_MAP_*.lwo" (* is can be an arbitrary string) // find the object file that has the filename starting with "_MAP_" CLWS_ObjectLayer* pObjectLayer = NULL; // char* pLWOFileName; // string strBodyFilename; char acBodyFilename[512]; for( i=0; i<lightwave_scene.GetNumObjectLayers(); i++ ) { pObjectLayer = lightwave_scene.GetObjectLayer(i); if( !pObjectLayer ) MessageBox(NULL, "invalid object layer", "error", MB_OK|MB_ICONWARNING); // pLWOFileName = pObjectLayer->GetObjectFilename().c_str(); string& strLWOFilename = pObjectLayer->GetObjectFilename(); CFileNameOperation::GetBodyFilenameBySlash( acBodyFilename, strLWOFilename.c_str() ); //find lwo2 file that represents the map object. if( strncmp( acBodyFilename, "_MAP_", 5 ) == 0 ) { // load the object bResult = m_LWO2Object.LoadLWO2Object(acBodyFilename); break; } } // compute normals on each face(polygon) in the LightWave object // m_LWO2Object.ComputeFaceNormals(); string log_filename = "DebugInfoFile\\lwo2_loaded_data.txt"; m_LWO2Object.WriteDebug(log_filename.c_str()); list<LWO2_Layer>::iterator itrLayer; this->m_aPlane.reserve(DEFAULT_NUM_PLANES); this->m_aMainFace.reserve(DEFAULT_NUM_MAINFACES); this->m_aInteriorFace.reserve(DEFAULT_NUM_MAINFACES); // itrLayer = m_LWO2Object.m_layer.begin(); list<LWO2_Layer>& lstLayer = m_LWO2Object.GetLayer(); itrLayer = lstLayer.begin(); for(; itrLayer != lstLayer.end() ; itrLayer++) { if( itrLayer->GetName() == "LYR_Slag" ) continue; if( itrLayer->GetName() == "LYR_Main" ) SetFace(&m_aMainFace, itrLayer); if( itrLayer->GetName() == "LYR_Interior" ) SetFace(&m_aInteriorFace, itrLayer); if( itrLayer->GetName() == "LYR_Skybox" ) SetFace(&m_aSkyboxFace, itrLayer); if( itrLayer->GetName() == "LYR_EnvLight" ) { C3DMeshModelBuilder_LW mesh_builder( &m_LWO2Object ); mesh_builder.BuildMeshFromLayer( *itrLayer ); m_EnvLightMesh = mesh_builder.GetArchive(); } /* if( itrLayer->GetName() == "LYR_BoundingVolume" ) SetFace; if( itrLayer->GetName() == "LYR_NoClip" ) SetFace;*/ } // Sort textures and others SetTextureFilename(); // set texture indices SetSurface(); // create additional filenames to support fake bumpy textures SetFakeBumpTextures(); //convert lightwave fog into generic fog CLWS_Fog* pLWSFog = lightwave_scene.GetFog(); if( pLWSFog ) { m_pFog = new SFog; m_pFog->cFogType = (char)pLWSFog->iType; m_pFog->fMinDist = pLWSFog->fMinDist; m_pFog->fMaxDist = pLWSFog->fMaxDist; m_pFog->fMinAmount = pLWSFog->fMinAmount; m_pFog->fMaxAmount = pLWSFog->fMaxAmount; m_pFog->color.fRed = pLWSFog->afColor[0]; // red m_pFog->color.fGreen = pLWSFog->afColor[1]; // green m_pFog->color.fBlue = pLWSFog->afColor[2]; // blue } // convert lightwave lights into generic lights SetLight( lightwave_scene ); // for occlusion testing CreateTriangleMesh(); // SetUVsForLightmaps(); return 1; }