vtTransform *vtRoadMap3d::GenerateGeometry(bool do_texture, bool bHwy, bool bPaved, bool bDirt, bool progress_callback(int)) { VTLOG(" vtRoadMap3d::GenerateGeometry\n"); VTLOG(" Nodes %d, Links %d\n", NumNodes(), NumLinks()); _CreateMaterials(do_texture); m_pGroup = new vtGroup; m_pGroup->setName("Roads"); m_pTransform = new vtTransform; m_pTransform->addChild(m_pGroup); m_pTransform->SetTrans(FPoint3(0, m_fGroundOffset, 0)); // We wrap the roads' geometry with an array of simple LOD nodes int a, b; for (a = 0; a < ROAD_CLUSTER; a++) for (b = 0; b < ROAD_CLUSTER; b++) { m_pRoads[a][b] = NULL; } _GatherExtents(); #if 0 vtGeode *pGeode = CreateLineGridGeom(m_pMats, 0, m_extents.min, m_extents.max, ROAD_CLUSTER); m_pGroup->addChild(pGeode); #endif vtMesh *pMesh; int count = 0, total = NumLinks() + NumNodes(); for (LinkGeom *pL = GetFirstLink(); pL; pL = pL->GetNext()) { // Decide whether to construct this link bool include = false; if (bHwy && bPaved && bDirt) include = true; else { bool bIsDirt = (pL->m_Surface == SURFT_2TRACK || pL->m_Surface == SURFT_DIRT); if (bHwy && pL->m_iHwy != -1) include = true; if (bPaved && !bIsDirt) include = true; if (bDirt && bIsDirt) include = true; } if (include) pL->GenerateGeometry(this); count++; if (progress_callback != NULL) progress_callback(count * 100 / total); } count = 0; for (NodeGeom *pN = GetFirstNode(); pN; pN = pN->GetNext()) { // What material to use? We used to simply use "pavement", but that is // bad when they are e.g. trail or stone. Now, we will try to guess // what to use by looking at the links here. int node_vti = VTI_PAVEMENT; for (int i = 0; i < pN->NumLinks(); i++) { LinkGeom *pL = pN->GetLink(i); switch (pL->m_vti) { case VTI_RAIL: case VTI_4WD: case VTI_TRAIL: case VTI_GRAVEL: case VTI_STONE: node_vti = pL->m_vti; } } VirtualTexture &vt = m_vt[node_vti]; pMesh = pN->GenerateGeometry(vt); if (pMesh) AddMeshToGrid(pMesh, vt.m_idx); count++; if (progress_callback != NULL) progress_callback(count * 100 / total); } // return the top group, ready to be added to scene graph return m_pTransform; }
void ApplyNewSpringLength() { ResetSpringLength( (m_flRopeLength + m_flCurSlack + ROPESLACK_FUDGEFACTOR) / (NumNodes() - 1) ); }