void Observer::onInit() { InternalMessage("Display","Display::Observer::onInit Entering") ; // positionned view must be initialised first Positionned* positionned(getView<Positionned>()) ; CHECK(positionned,"error") ; ::Ogre::SceneManager* manager = this->getViewPoint()->getManager() ; m_camera = manager->createCamera(Utility::getUniqueName()) ; Ogre::addCamera(m_camera) ; InternalMessage("Display","creating camera scene node with parent " + positionned->getNode()->getName()) ; m_node = static_cast< ::Ogre::SceneNode* >(positionned->getNode()->createChild()) ; m_node->attachObject(m_camera) ; // @todo configurate in files m_camera->setFOVy(::Ogre::Degree(70)) ; // near clip distance is 1 cm m_camera->setNearClipDistance(0.01/conversion_factor) ; getViewPoint()->setObserver(getObject()) ; InternalMessage("Display","Display::Observer::onInit Leaving") ; }
void Solid::onInit() { Kernel::Log::InternalMessage("Solid::onInit entering") ; m_geometry = new dGeom() ; m_geometry_placeable = new dGeomTransform() ; /// body attachment : need to get the physical object Model::PhysicalObject* body = getObject()->getParent<Model::PhysicalObject>() ; check(body,"Solid::onInit no body parent") ; m_geometry_placeable->setBody( body->getView<PhysicalObject>(getViewPoint())->getBody()->id()) ; m_geometry_placeable->setGeom(m_geometry->id()) ; /// geom placement is relative to body Ogre::Vector3 position = getObject()->getTrait<Model::Positionned>() ->getPosition(body->getObject()).Meter() ; m_geometry_placeable->setPosition(position.x, position.y, position.z) ; Kernel::Log::InternalMessage("Solid::onInit leaving") ; }
void TargetDisplayer::onInit() { m_implementation.reset( new HeadUpDisplay::TargetDisplayerViewPoint(getObject(), getViewPoint())) ; m_implementation->init() ; m_reticule_container = static_cast< ::Ogre::OverlayContainer* >( ::Ogre::OverlayManager::getSingleton().createOverlayElement( "Panel", Utility::getUniqueName())) ; getOverlay()->add2D(m_reticule_container) ; m_reticule_container->setPosition(0,0) ; m_reticule_container->setWidth(1) ; m_reticule_container->setHeight(1) ; m_reticule = ::Ogre::OverlayManager::getSingleton().createOverlayElement( "Panel", Utility::getUniqueName()) ; m_reticule->setMaterialName(getReticuleMaterial()) ; m_reticule->setHorizontalAlignment(::Ogre::GHA_CENTER) ; m_reticule->setVerticalAlignment(::Ogre::GVA_CENTER) ; m_reticule_container->_addChild(m_reticule) ; const float size = 0.05 ; m_reticule->setLeft(-size/2) ; m_reticule->setTop(-size/2) ; m_reticule->setDimensions(size,size) ; getOverlay()->show() ; }
void Positioned::onChangeParent(Kernel::Object* old_parent) { InternalMessage("Display","Display::Positioned::onChangeParent Entering") ; if (old_parent) { Positioned* parent = old_parent->getView<Positioned>(getViewPoint()) ; if (parent && parent->getNode()) { parent->getNode()->removeChild(m_node) ; } } if (getObject()->getParent()) { Positioned* parent = getView<Positioned>() ; if (parent && parent->getNode()) { parent->getNode()->addChild(m_node) ; } } else { /// error cannot create another root scene node ErrorMessage("cannot create another root node") ; } InternalMessage("Display","Display::Positioned::onChangeParent Leaving") ; }
void Observer::onClose() { Ogre::removeCamera(m_camera) ; InternalMessage("Display","Display::Observer::onClose Entering") ; this->getViewPoint()->getManager()->destroyCamera(m_camera) ; getViewPoint()->setObserver(NULL) ; InternalMessage("Display","Display::Observer::onClose Leaving") ; }
void Listener::onInit() { InternalMessage("Sound","OpenAL::Listener::onInit Entering") ; getViewPoint()->setListener(getObject()) ; this->updateListener() ; InternalMessage("Sound","OpenAL::Listener::onInit Leaving") ; }
void Positionned::onChangeParent(Kernel::Object* i_old_parent) { if (i_old_parent) { Positionned* parent = i_old_parent->getView<Positionned>(getViewPoint()) ; parent->getNode()->removeChild(m_node) ; } if (getObject()->getParent()) { Positionned* parent = getObject()->getParent()->getView<Positionned>(getViewPoint()) ; parent->getNode()->addChild(m_node) ; } else { /// error cannot create another root scene node ErrorMessage("cannot create another root node") ; } }
void Listener::onClose() { InternalMessage("Sound","OpenAL::Listener::onClose Entering") ; getViewPoint()->setListener(NULL) ; // Just one listener by context in openal , it's destroy with openal context InternalMessage("Sound","OpenAL::Listener::onClose Leaving") ; }
void AgentVehicle::onInit() { InternalMessage("AI","entering AgentVehicle::onInit") ; Ogre::Vector3 speed = getSpeed() ; m_vehicle.reset(new Vehicle(getPosition(), getOrientation(), speed, speed.length(), getSize())) ; getViewPoint()->setVehicle(m_vehicle.get()) ; InternalMessage("AI","leaving AgentVehicle::onInit") ; }
void TargetWithSelection::onClose() { InternalMessage("Display","Entering TargetWithSelection::onClose") ; Implementation::Target* target = getObject()->getTrait<Implementation::Target>() ; if (target) { m_target = target->getView<Target>(getViewPoint()) ; if (m_target) { m_target->setTargetIdentification("") ; } } InternalMessage("Display","Leaving TargetWithSelection::onClose") ; }
/*! @pre Parent Positionned View is init. */ void Positionned::onInit() { InternalMessage("Display","Entering Positionned::init") ; Model::Positionned* positionned_ancestor = getObject()->getAncestor<Model::Positionned>() ; if (positionned_ancestor) { Positionned* parent_node(positionned_ancestor->getView<Positionned>(getViewPoint())) ; m_node = static_cast<SceneNode*>(parent_node->getNode()->createChild()) ; InternalMessage("Display", "creating scene node " + m_node->getName() + " with parent " + parent_node->m_node->getName() + " with position " + ::Ogre::StringConverter::toString(m_node->getPosition())) ; m_node->setPosition(convert(getTrait()->getPosition())) ; InternalMessage("Display", "modification of scene node " + m_node->getName() + " with position " + ::Ogre::StringConverter::toString(m_node->getPosition())) ; } else { InternalMessage("Display","root node") ; m_node = this->getViewPoint()->getManager()->getRootSceneNode() ; getViewPoint()->setRootObject(getObject()) ; } InternalMessage("Display","Leaving Positionned::init") ; }
template <typename PointInT> void pcl16::NormalEstimationOMP<PointInT, Eigen::MatrixXf>::computeFeatureEigen (pcl16::PointCloud<Eigen::MatrixXf> &output) { float vpx, vpy, vpz; getViewPoint (vpx, vpy, vpz); output.is_dense = true; // Resize the output dataset output.points.resize (indices_->size (), 4); // GCC 4.2.x seems to segfault with "internal compiler error" on MacOS X here #if defined(_WIN32) || ((__GNUC__ > 4) && (__GNUC_MINOR__ > 2)) #pragma omp parallel for schedule (dynamic, threads_) #endif // Iterating over the entire index vector for (int idx = 0; idx < static_cast<int> (indices_->size ()); ++idx) { // Allocate enough space to hold the results // \note This resize is irrelevant for a radiusSearch (). std::vector<int> nn_indices (k_); std::vector<float> nn_dists (k_); if (!isFinite ((*input_)[(*indices_)[idx]]) || this->searchForNeighbors ((*indices_)[idx], search_parameter_, nn_indices, nn_dists) == 0) { output.points (idx, 0) = output.points (idx, 1) = output.points (idx, 2) = output.points (idx, 3) = std::numeric_limits<float>::quiet_NaN (); output.is_dense = false; continue; } // 16-bytes aligned placeholder for the XYZ centroid of a surface patch Eigen::Vector4f xyz_centroid; // Estimate the XYZ centroid compute3DCentroid (*surface_, nn_indices, xyz_centroid); // Placeholder for the 3x3 covariance matrix at each surface patch EIGEN_ALIGN16 Eigen::Matrix3f covariance_matrix; // Compute the 3x3 covariance matrix computeCovarianceMatrix (*surface_, nn_indices, xyz_centroid, covariance_matrix); // Get the plane normal and surface curvature solvePlaneParameters (covariance_matrix, output.points (idx, 0), output.points (idx, 1), output.points (idx, 2), output.points (idx, 3)); flipNormalTowardsViewpoint (input_->points[(*indices_)[idx]], vpx, vpy, vpz, output.points (idx, 0), output.points (idx, 1), output.points (idx, 2)); } }
Ogre::Vector3 DetectedVehicle::getPosition() const { Kernel::Object* agent = getViewPoint()->getAgent() ; Kernel::Object* ship = Model::getControledShip(agent) ; Model::Computer* computer = getObject()->getTrait<Model::DetectionData>() ->getComputer()->getTrait<Model::Computer>() ; Kernel::Object* physical_world = ship->getAncestor<Model::PhysicalWorld>() ->getObject() ; InternalMessage("AI",Ogre::StringConverter::toString(getObject()->getTrait<Model::Positionned>()->getPosition().Meter())) ; Model::Position position = computer->getDataPosition(getObject(),physical_world) ; return position.Meter() ; }
template <typename PointInT, typename PointOutT> void pcl16::NormalEstimationOMP<PointInT, PointOutT>::computeFeature (PointCloudOut &output) { float vpx, vpy, vpz; getViewPoint (vpx, vpy, vpz); output.is_dense = true; // Iterating over the entire index vector #pragma omp parallel for schedule (dynamic, threads_) for (int idx = 0; idx < static_cast<int> (indices_->size ()); ++idx) { // Allocate enough space to hold the results // \note This resize is irrelevant for a radiusSearch (). std::vector<int> nn_indices (k_); std::vector<float> nn_dists (k_); if (!isFinite ((*input_)[(*indices_)[idx]]) || this->searchForNeighbors ((*indices_)[idx], search_parameter_, nn_indices, nn_dists) == 0) { output.points[idx].normal[0] = output.points[idx].normal[1] = output.points[idx].normal[2] = output.points[idx].curvature = std::numeric_limits<float>::quiet_NaN (); output.is_dense = false; continue; } // 16-bytes aligned placeholder for the XYZ centroid of a surface patch Eigen::Vector4f xyz_centroid; // Estimate the XYZ centroid compute3DCentroid (*surface_, nn_indices, xyz_centroid); // Placeholder for the 3x3 covariance matrix at each surface patch EIGEN_ALIGN16 Eigen::Matrix3f covariance_matrix; // Compute the 3x3 covariance matrix computeCovarianceMatrix (*surface_, nn_indices, xyz_centroid, covariance_matrix); // Get the plane normal and surface curvature solvePlaneParameters (covariance_matrix, output.points[idx].normal[0], output.points[idx].normal[1], output.points[idx].normal[2], output.points[idx].curvature); flipNormalTowardsViewpoint (input_->points[(*indices_)[idx]], vpx, vpy, vpz, output.points[idx].normal[0], output.points[idx].normal[1], output.points[idx].normal[2]); } }
/*! @pre Parent Positionned View is init. */ void Oriented::onInit() { InternalMessage("Display","Entering Positionned::init") ; Model::Positionned* model_positionned = getObject()->getTrait<Model::Positionned>() ; if (model_positionned) { Positionned* positionned( model_positionned ->getView<Positionned>(getViewPoint())) ; if (positionned) { positionned->_init() ; m_node = positionned->getNode() ; InternalMessage("Display", "intitalising scene node " + m_node->getName() + " with orientation " + ::Ogre::StringConverter::toString(m_node->getOrientation())) ; m_node->setOrientation(getTrait()->getOrientation().getQuaternion()) ; InternalMessage("Display", "modification of scene node " + m_node->getName() + " with orientation " + ::Ogre::StringConverter::toString(m_node->getOrientation())) ; } } InternalMessage("Display","Leaving Positionned::init") ; }
void BackgroundSound::onUpdate() { this->updateSource(getViewPoint()); }
void IdealTarget::onUpdate() { InternalMessage("Display","IdealTarget::onUpdate calculating target position") ; ::Ogre::Camera* camera = getViewPoint()->getCamera() ; if (!camera) return ; Model::Computer* computer = getViewPoint()->getTargetingSystem()->getTrait<Model::TargetingSystem>() ->getComputer()->getTrait<Model::Computer>() ; // update target position Model::Position pos = computer->getDataPosition(getObject(),getViewPoint()->getWorldRoot()) ; ::Ogre::Vector3 position = convert(pos) ; InternalMessage("Display","Target::onUpdate object position=" + Kernel::toString(position.x) +"," + Kernel::toString(position.y) +"," + Kernel::toString(position.z) ) ; ::Ogre::Vector3 eye_position = camera->getViewMatrix(true) * position ; InternalMessage("Display","Target::updateHUD eye position=" + Kernel::toString(eye_position.x) +"," + Kernel::toString(eye_position.y) +"," + Kernel::toString(eye_position.z) ) ; if (eye_position.z < 0) { InternalMessage("Display","TargetView::updateHUD object is visible") ; ::Ogre::Vector3 screen_position = camera->getProjectionMatrix()*eye_position ; InternalMessage( "Display","TargetView::updateHUD setting position to x=" + Kernel::toString(screen_position.x) + " y=" + Kernel::toString(screen_position.y) + " z=" + Kernel::toString(screen_position.z) ) ; /*! it seems that x,y can get out of [-1,1] it means that it is out of the screen we can print it when x,y in -1/1 */ if (fabs(screen_position.x) <= 1 && fabs(screen_position.y) <= 1) { /* screen_position is in [-1,1] but actual screen values are between [-0.5,0.5] do not know why we need to invert y */ m_target_container->setPosition(screen_position.x/2,-screen_position.y/2) ; if (!m_target_is_shown) { m_target_container->show() ; m_target_is_shown = true ; } } else { if (m_target_is_shown) { m_target_container->hide() ; m_target_is_shown = false ; } } } else { if (m_target_is_shown) { m_target_container->hide() ; m_target_is_shown = false ; } } InternalMessage("Display","IdealTarget::onUpdate leaving") ; }
void DetectorObjectView::check() { InternalMessage("Model","Model::DetectorObjectView::check entering") ; Detector* detector = getViewPoint()->getObserver() ; if (!detector) return ; bool in_range = detector ? detector->canDetect(getObject()) : false ; if (!detector->getComputer()) return ; Computer* computer = detector->getComputer()->getTrait<Computer>() ; if (! computer) return ; if (!in_range && m_detection_information) { // destroy object computer->getMemoryModel()->destroyObject(m_detection_information) ; m_detection_information = NULL ; } else if (in_range) { InternalMessage( "Model", "Model::DetectorObjectView::check in range updating detection data") ; bool mobile = false ; if (! m_detection_information) { Solid* solid = getObject()->getTrait<Solid>() ; // create object m_detection_information = computer->getMemoryModel()->createObject() ; m_detection_information->addTrait(new DetectionData(detector->getComputer())) ; m_detection_information->addTrait(new Positionned()) ; m_detection_information->addTrait(new Solid(solid->getMesh())) ; m_detection_information->getTrait<DetectionData>()->m_detected = getObject() ; } // update object position Position position = getRelativePosition(getObject(), computer->getObject()) ; m_detection_information->getTrait<Positionned>()->setPosition(position) ; // update speed if exists Mobile* mobileTrait = getObject()->getTrait<Mobile>() ; if (mobileTrait) { Mobile* data = m_detection_information->getTrait<Mobile>() ; if (! data) { data = new Mobile() ; m_detection_information->addTrait(data) ; } data->setSpeed(mobileTrait->getSpeed()) ; data->setAngularSpeed(mobileTrait->getAngularSpeed()) ; } // update identification Transponder* identified = getObject()->getTrait<Transponder>() ; Transponder* identifedData = m_detection_information->getTrait<Transponder>() ; if (identified) { if (! identifedData) { // gained identification m_detection_information->addTrait(new Transponder(*identified)) ; } else if (identifedData->getCode() != identified->getCode()) { // changed identification identifedData->setCode(identified) ; } } else if (identifedData) { // lost identification m_detection_information->destroyTrait(identifedData) ; } // update Targetting std::set<TargetingSystem*> systems = getObject()->getChildren<TargetingSystem>() ; TargetingSystem* system_data = m_detection_information->getTrait<TargetingSystem>() ; if (systems.size() == 1) { TargetingSystem* system = *(systems.begin()) ; if (! system_data) { // gained identification m_detection_information->addTrait(new TargetingSystem()) ; m_detection_information->getTrait<TargetingSystem>()->m_target = system->getTarget() ; m_detection_information->getTrait<TargetingSystem>()->notify() ; } else if (system_data->getTarget() != system->getTarget()) { // changed selection system_data->m_target = system->getTarget() ; system_data->notify() ; } } else if (system_data) { // lost targeting system m_detection_information->destroyTrait(system_data) ; } } InternalMessage("Model","Model::DetectorObjectView::check leaving") ; }
void Engine::onUpdate() { this->updateSource(getViewPoint()); }
void Engine::onChangeParent(Kernel::Object* i_old_parent) { InformationMessage("Sound","call onChangeParent") ; this->changeParentSource(getViewPoint()) ; }
void Engine::onInit() { this->initSound(getViewPoint()); }
void DetectedVehicle::onClose() { getViewPoint()->removeVehicle(m_vehicle.get()) ; m_vehicle.reset(NULL) ; }
void AgentVehicle::onClose() { getViewPoint()->setVehicle(NULL) ; m_vehicle.reset(NULL) ; }
void TargetWithSelection::onInit() { InternalMessage("Display","Entering TargetWithSelection::onInit") ; m_target = getObject()->getTrait<Implementation::Target>()->getView<Target>(getViewPoint()) ; m_target->_init() ; onUpdate() ; InternalMessage("Display","Leaving TargetWithSelection::onInit") ; }
void BackgroundSound::onInit() { this->initSound(getViewPoint()); }