//################################################################################################## // // Custom Visualization Core library // Copyright (C) 2011-2012 Ceetron AS // // This library is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This library is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. // // See the GNU General Public License at <> // for more details. // //################################################################################################## #include "cvfBase.h" #include "cvfScene.h" #include "cvfModel.h" #include "cvfPartRenderHintCollection.h" namespace cvf { //================================================================================================== /// /// \class cvf::Scene /// \ingroup Viewing /// /// /// //================================================================================================== //-------------------------------------------------------------------------------------------------- /// Compute the visible parts of all models in the scene //-------------------------------------------------------------------------------------------------- void Scene::findVisibleParts(PartRenderHintCollection* visibleParts, const Camera& camera, const CullSettings& cullSettings, unsigned int enableMask) { visibleParts->setCountZero(); uint i; for (i = 0; i < modelCount(); i++) { Model* model = m_models[i].p(); if (model) { if ((enableMask & model->partEnableMask()) != 0) { model->findVisibleParts(visibleParts, camera, cullSettings, enableMask); } } } } //-------------------------------------------------------------------------------------------------- /// Get all pars in all models in the scene //-------------------------------------------------------------------------------------------------- void Scene::allParts(Collection* partCollection) { uint numModels = modelCount(); uint i; for (i = 0; i < numModels; i++) { Model* model = m_models.at(i); CVF_ASSERT(model); model->allParts(partCollection); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void Scene::addModel(Model* model) { CVF_ASSERT(model); m_models.push_back(model); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- uint Scene::modelCount() const { return static_cast(m_models.size()); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- Model* Scene::model(uint index) { return m_models[index].p(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- const Model* Scene::model(uint index) const { return m_models[index].p(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void Scene::removeAllModels() { m_models.clear(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void Scene::removeModel(const Model* model) { CVF_ASSERT(model); m_models.erase(model); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void Scene::updateBoundingBoxesRecursive() { size_t numModels = m_models.size(); size_t i; for (i = 0; i < numModels; i++) { Model* model = m_models.at(i); CVF_ASSERT(model); model->updateBoundingBoxesRecursive(); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- BoundingBox Scene::boundingBox() const { BoundingBox bb; size_t numModels = m_models.size(); size_t i; for (i = 0; i < numModels; i++) { const Model* model = m_models.at(i); CVF_ASSERT(model); bb.add(model->boundingBox()); } return bb; } } // namespace cvf