/** * This method creates a VirtualRobot::OSGVisualizationNode from a given \p filename. * An instance of VirtualRobot::VisualizationNode is returned in case of an occured error. * * \param filename file to load the OSG3D visualization from. * \param boundingBox Use bounding box instead of full model. * \return instance of VirtualRobot::OSGVisualizationNode upon success and VirtualRobot::VisualizationNode on error. */ VisualizationNodePtr OSGVisualizationFactory::getVisualizationFromFile(const std::string& filename, bool boundingBox) { VisualizationNodePtr visualizationNode(new VisualizationNode); osg::Node* n = osgDB::readNodeFile(filename.c_str()); if (n) { n->ref(); if (boundingBox) { osg::Node* bboxVisu = CreateBoundingBox(n); bboxVisu->ref(); n->unref(); n = bboxVisu; } visualizationNode.reset(new OSGVisualizationNode(n)); visualizationNode->setFilename(filename, boundingBox); n->unref(); } else VR_WARNING << "Could not read file:" << filename << endl; return visualizationNode; }
void GameBase::UpdateBoundingBox() { int nVal = (int)g_ShowDimsTrack.GetFloat(); if (nVal < 4) { switch (GetType()) { case OT_WORLDMODEL : { if (nVal != 1) { RemoveBoundingBox(); return; } } break; case OT_MODEL : { if (nVal != 2) { RemoveBoundingBox(); return; } } break; case OT_NORMAL : { if (nVal != 3) { RemoveBoundingBox(); return; } } break; default : break; } } CreateBoundingBox(); if (m_hDimsBox) { LTVector vDims, vScale; g_pLTServer->GetObjectDims(m_hObject, &vDims); vScale = (vDims * 2.0); g_pLTServer->ScaleObject(m_hDimsBox, &vScale); } }
void Trigger::ToggleBoundingBoxes() { CServerDE* pServerDE = GetServerDE(); if (!pServerDE) return; if (m_hBoundingBox) { pServerDE->RemoveObject(m_hBoundingBox); m_hBoundingBox = DNULL; } else { CreateBoundingBox(); } }
void MeshRenderComponent::OnActivate() { Component::OnActivate(); MeshRes *meshRes = ResourceManager<MeshRes>::Instance()->GetResource(mMeshID.c_str()); if (!meshRes) LOG_WARNING() << "RenderComponent could not find the MeshRes for: " << mMeshID; MaterialRes *materialRes = ResourceManager<MaterialRes>::Instance()->GetResource(mMaterialID.c_str()); if (!materialRes) LOG_WARNING() << "RenderComponent could not find the MaterialRes for: " << mMaterialID; MeshRenderManager::Instance()->AttachMeshRenderComponent(this); CreateBoundingBox(); }