bool OGRE3DBody::advance(float, const NxOgre::Enums::Priority&) { mNode->setPosition(NxOgre::Vec3(getGlobalPose()).as<Ogre::Vector3>()); mNode->setOrientation(NxOgre::Quat(getGlobalPose()).as<Ogre::Quaternion>()); return true; }
bool OGRE3DKinematicBody::advance(float, const NxOgre::Enums::Priority&) { // "Rendering" in Ogre merely means just moving a scenenode to it's new position and orientation. Ogre::Matrix4 m4 = toMatrix44(getGlobalPose()); mNode->setPosition(m4.getTrans()); mNode->setOrientation(m4.extractQuaternion()); return true; }
void Perception::update(float dt) { if(active) { GameObject * owner = this->master; getManager()->addVision( definition->distance, definition->fov, getGlobalPose(), owner ); //((PerceptionManager&)definition->manager).updatePerception(this,dt); } }
Eigen::Vector3f RobotNodePrismatic::getJointTranslationDirection(const SceneObjectPtr coordSystem) const { ReadLockPtr lock = getRobot()->getReadLock(); Eigen::Vector4f result4f = Eigen::Vector4f::Zero(); result4f.segment(0, 3) = jointTranslationDirection; result4f = getGlobalPose() * result4f; if (coordSystem) { result4f = coordSystem->getGlobalPose().inverse() * result4f; } return result4f.segment(0, 3); }
/** * Returns this 2D pose relative to pose P. */ self getPoseRelativeTo(const shared_ptr< const self >& P) const { if(!P) return getGlobalPose(); if(isParentPose(P)) { if(Parent.lock() == P) return *this; else return Parent.lock()->getPoseRelativeTo(P) * (*this); } else if(P->isParentPose( rtti::rk_static_ptr_cast< const self >(mThis))) return ~(P->getPoseRelativeTo( rtti::rk_static_ptr_cast< const self >(mThis))); else if(Parent.expired()) return (~(P->getGlobalPose())) * (*this); else return Parent.lock()->getPoseRelativeTo(P) * (*this); };
VirtualRobot::CollisionModelPtr CollisionModel::clone(CollisionCheckerPtr colChecker, float scaling) { VisualizationNodePtr visuNew; if (visualization) { visuNew = visualization->clone(true, scaling); } std::string nameNew = name; int idNew = id; CollisionModelPtr p(new CollisionModel(visuNew, nameNew, colChecker, idNew)); p->setGlobalPose(getGlobalPose()); p->setUpdateVisualization(getUpdateVisualizationStatus()); return p; }
Obstacle* Obstacle::_clone( const std::string &name, CollisionCheckerPtr colChecker ) const { VisualizationNodePtr clonedVisualizationNode; if (visualizationModel) clonedVisualizationNode = visualizationModel->clone(); CollisionModelPtr clonedCollisionModel; if (collisionModel) clonedCollisionModel = collisionModel->clone(colChecker); Obstacle* result = new Obstacle(name, clonedVisualizationNode, clonedCollisionModel, physics, colChecker); if (!result) { VR_ERROR << "Cloning failed.." << endl; return result; } result->setGlobalPose(getGlobalPose()); return result; }
OGRE3DKinematicBody::OGRE3DKinematicBody(OGRE3DRigidBodyPrototype* prototype, OGRE3DRenderSystem* rendersystem) : KinematicActor(rendersystem->getScene()), // Take notice of the constructor we are using, it's designed for // classes that inherit from Actor. mNode(0), mEntity(0), mSceneManager(0), mRenderPriority(prototype->mRenderPriority) { // Implement the prototype (it's being casted back into a RigidBodyPrototype) so it's treated // as a normal RigidBody. create(prototype, rendersystem->getScene(), &mShapes); // Since NxOgre doesn't know or care about our Ogre stuff, we copy it over. This is the correct time to create // or turn on things related to the OGRE3DKinematicBody. mSceneManager = prototype->mSceneManager; if (prototype->mNode != NULL) { mNode = prototype->mNode; mSelfCreated = false; } else { // Matrix's are faster than vectors and quaternions. Ogre::Matrix4 m4 = toMatrix44(getGlobalPose()); mNode = mSceneManager->getRootSceneNode()->createChildSceneNode(m4.getTrans(), m4.extractQuaternion()); mSelfCreated = true; if (mEntity == NULL) { mEntity = mSceneManager->createEntity(mNode->getName() + "-Entity", prototype->mMeshName); mNode->attachObject(mEntity); } } // And let the time controller, that this is a timelistener that needs to be listened. NxOgre::TimeController::getSingleton()->addTimeListener(this, mRenderPriority); }
void StickyNoteActor::finishedEditing() { // update the file if (_stickyNoteText.isModified()) { writeStickyNote(getFullPath(), _stickyNoteText.toPlainText()); // notify the user with a little animation setFreshnessAlphaAnim(1.0f, 25); } // animate back and then finish up the visuals if (_tmpAnimationActor) { Mat34 startPose; Vec3 startDims; int numTempActorSteps = StickyNoteActorNumTempActorSteps; int numStickySteps = StickyNoteActorNumStickySteps; if (_tmpAnimationActor->isAnimating()) { animManager->removeAnimation(_tmpAnimationActor); startPose = _tmpAnimationActor->getGlobalPose(); startDims = _tmpAnimationActor->getDims(); numTempActorSteps = max(1, (int)((_tmpAnimationActor->getAlpha() / 1.0f) * numTempActorSteps)); numStickySteps = max(1, (int)(((1.0f - getAlpha()) / 1.0f) * numStickySteps)); } else { calculateDialogPoseDims(startPose, startDims); } _tmpAnimationActor->popActorType(Invisible); _tmpAnimationActor->setAlphaAnim(_tmpAnimationActor->getAlpha(), 0.0f, numTempActorSteps); _tmpAnimationActor->setSizeAnim(lerpRange(startDims, getDims(), numTempActorSteps, SoftEase)); _tmpAnimationActor->setPoseAnim(slerpPose(startPose, getGlobalPose(), numTempActorSteps, SoftEase), (FinishedCallBack) FinishEditStickyNoteAfterAnim, NULL); _tmpAnimationActor = NULL; setAlphaAnim(getAlpha(), 1.0f, numStickySteps); } }
VirtualRobot::VisualizationNodePtr CoinVisualizationNode::clone(bool deepCopy, float scaling) { THROW_VR_EXCEPTION_IF(scaling<=0,"Scaling must be >0"); SoSeparator* newModel = NULL; if (visualization) { newModel = new SoSeparator; newModel->ref(); if (scaling!=1.0) { SoScale *s = new SoScale; s->scaleFactor.setValue(scaling,scaling,scaling); newModel->addChild(s); } if (deepCopy) { newModel->addChild(visualization->copy(FALSE)); } else newModel->addChild(visualization); } VisualizationNodePtr p(new CoinVisualizationNode(newModel)); if (newModel) newModel->unrefNoDelete(); p->setUpdateVisualization(updateVisualization); p->setGlobalPose(getGlobalPose()); p->setFilename(filename,boundingBox); // clone attached visualizations std::map< std::string, VisualizationNodePtr >::const_iterator i = attachedVisualizations.begin(); while (i!=attachedVisualizations.end()) { VisualizationNodePtr attachedClone = i->second->clone(deepCopy,scaling); p->attachVisualization(i->first, attachedClone); i++; } return p; }
/** * Returns the free vector V (expressed in this coordinate system) expressed in the global coordinate system. */ vector_type rotateToGlobal(const vector_type& V) const { return getGlobalPose().Rotation * V; };
float Turret::getAngle(const Pose::pos &vec) const { Pose::pos v=getGlobalPose().projectPos(vec); return atan2(v[1],v[0])*180.0f/M_PI; }
Pose Turret::getPose()const { return getGlobalPose(); }
void StickyNoteActor::launchEditDialog(bool selectExistingText) { _selectExistingText = selectExistingText; // NOTE: for the future, we may want QuickLook-like behaviour where // we follow the sticky notes as the user clicks around on the screen. // If so, then we should keep a reference to the existing dialog some // where and pass it into this launch process? // if one does not exist, create a new sticky not dialog // and center it if (!_editDialog) _editDialog = new StickyNoteEditDialog(); else { // close the dialog and disconnect all signals _editDialog->accept(); _editDialog->disconnect(); } // setup all the connections connect(_editDialog, SIGNAL(finished(int)), this, SLOT(finishedEditing())); connect(_editDialog, SIGNAL(accepted()), this, SLOT(finishedEditing())); connect(_editDialog, SIGNAL(rejected()), this, SLOT(finishedEditing())); // move it to the appropriate place const int marginLeftRight = 20; const int marginTopBottom = -20; Bounds b = this->getScreenBoundingBox(); POINT windowPos = {0, 0}; ClientToScreen(winOS->GetWindowsHandle(), &windowPos); Vec3 screenMin = b.getMin() + Vec3(windowPos.x, windowPos.y, 0); Vec3 screenMax = b.getMax() + Vec3(windowPos.x, windowPos.y, 0); Vec3 screenDims = Vec3(winOS->GetWindowWidth(), winOS->GetWindowHeight(), 0); Vec3 tr(NxMath::max(screenMin.x, screenMax.x), NxMath::min(screenMin.y, screenMax.y), 0); Vec3 tl(NxMath::min(screenMin.x, screenMax.x), NxMath::min(screenMin.y, screenMax.y), 0); int yBound = NxMath::min(NxMath::max((int) tr.y + marginTopBottom, windowPos.y + abs(marginTopBottom)), windowPos.y + (int) screenDims.y - abs(marginTopBottom) - _editDialog->height()); if ((tr.x + marginLeftRight + _editDialog->width()) <= (windowPos.x + screenDims.x - marginLeftRight)) { // put this note to the right of this actor _editDialog->move(tr.x + marginLeftRight, yBound); } else if ((tl.x - marginLeftRight - _editDialog->width()) >= marginLeftRight) { // put this note to the left of this actor _editDialog->move((tl.x - marginLeftRight - _editDialog->width()), yBound); } Mat34 finalPose; Vec3 finalDims; calculateDialogPoseDims(finalPose, finalDims); const int StickyNoteActorNumTempActorSteps = 13; const int StickyNoteActorNumStickySteps = 8; // create a new proxy actor assert(!_tmpAnimationActor); _tmpAnimationActor = new Actor(); _tmpAnimationActor->pushActorType(Temporary); _tmpAnimationActor->setObjectToMimic(this); _tmpAnimationActor->setFrozen(false); _tmpAnimationActor->setGravity(false); _tmpAnimationActor->setCollisions(false); _tmpAnimationActor->setAlphaAnim(0.0f, 1.0f, StickyNoteActorNumTempActorSteps); _tmpAnimationActor->setSizeAnim(lerpRange(getDims(), finalDims, StickyNoteActorNumTempActorSteps, SoftEase)); _tmpAnimationActor->setPoseAnim(slerpPose(getGlobalPose(), finalPose, StickyNoteActorNumTempActorSteps, SoftEase), (FinishedCallBack) EditStickyNoteAfterAnim, NULL); setAlphaAnim(getAlpha(), 0.4f, StickyNoteActorNumStickySteps); }
void RobotNode::print( bool printChildren, bool printDecoration ) const { ReadLockPtr lock = getRobot()->getReadLock(); if (printDecoration) cout << "******** RobotNode ********" << endl; cout << "* Name: " << name << endl; cout << "* Parent: "; SceneObjectPtr p = this->getParent(); if (p) cout << p->getName() << endl; else cout << " -- " << endl; cout << "* Children: "; if (this->getChildren().size() == 0) cout << " -- " << endl; for (unsigned int i = 0; i < this->getChildren().size(); i++) cout << this->getChildren()[i]->getName() << ", "; cout << endl; physics.print(); cout << "* Limits: Lo:" << jointLimitLo << ", Hi:" << jointLimitHi << endl; std::cout << "* max velocity " << maxVelocity << " [m/s]" << std::endl; std::cout << "* max acceleration " << maxAcceleration << " [m/s^2]" << std::endl; std::cout << "* max torque " << maxTorque << " [Nm]" << std::endl; cout << "* jointValue: " << this->getJointValue() << ", jointValueOffset: " << jointValueOffset << endl; if (optionalDHParameter.isSet) { cout << "* DH parameters: "; cout << " a:" << optionalDHParameter.aMM() << ", d:" << optionalDHParameter.dMM() << ", alpha:" << optionalDHParameter.alphaRadian() << ", theta:" << optionalDHParameter.thetaRadian() << endl; } else cout << "* DH parameters: not specified." << endl; cout << "* visualization model: " <<endl; if (visualizationModel) visualizationModel->print(); else cout << " No visualization model" << endl; cout << "* collision model: " << endl; if (collisionModel) collisionModel->print(); else cout << " No collision model" << endl; if (initialized) cout << "* initialized: true" << endl; else cout << "* initialized: false" << endl; { // scope1 std::ostringstream sos; sos << std::setiosflags(std::ios::fixed); sos << "* localTransformation:" << endl << localTransformation << endl; sos << "* globalPose:" << endl << getGlobalPose() << endl; cout << sos.str(); } // scope1 if (printDecoration) cout << "******** End RobotNode ********" << endl; if (printChildren) { std::vector< SceneObjectPtr > children = this->getChildren(); for (unsigned int i = 0; i < children.size(); i++) children[i]->print(true, true); } }
/** * Returns the free vector V (expressed in the global coordinate system) expressed in this coordinate system. */ vector_type rotateFromGlobal(const vector_type& V) const { return V * getGlobalPose().Rotation; // getGlobalPose().Rotation.invert() * V; };
void FileSystemActor::onLaunch() { assert(!filePath.isNull()); if (!_onLaunchHandler.empty()) _onLaunchHandler(this); // override for widgets Widget * w = widgetManager->getActiveWidgetForFile(getFullPath()); if (w && w->isWidgetOverrideActor(this)) { w->launchWidgetOverride(this); return; } // Do a quick pass to determine what needs to be created or not bool isWatchingHighlighted = cam->isWatchedActorHighlighted(this); bool zoomIntoImage = isFileSystemType(Image) && !isWatchingHighlighted && texMgr->isTextureState(thumbnailID, TextureLoaded); bool launchImage = (isFileSystemType(Image) && isWatchingHighlighted) && !texMgr->isTextureState(thumbnailID, TextureLoaded); bool createTemporaryActor = !zoomIntoImage && !launchImage; bool createRandomAnimPath = createTemporaryActor; Actor * obj = NULL; if (createTemporaryActor) { obj = new Actor(); Vec3 startPosition; // Set up the state of the Actor obj->pushActorType(Temporary); obj->setDims(getDims()); obj->setGravity(false); obj->setCollisions(false); obj->setAlphaAnim(getAlpha(), 0.2f, 40); obj->setGlobalPose(getGlobalPose()); obj->setObjectToMimic(this); } // Special case for launching a pileized actor Vec3 startPosition; if (isPileized()) { startPosition = pileizedPile->getGlobalPosition(); }else{ startPosition = getGlobalPosition(); } // create random animation path from the icon up to the camera eye if (createRandomAnimPath) { // Set an animation that moves the icon into the camera CreateRandomAnimPath(obj, startPosition, cam->getEye(), 40); // Delete the object after the random animation is over. animManager->removeAnimation(obj); animManager->addAnimation(AnimationEntry(obj, (FinishedCallBack) DeleteActorAfterAnim)); } // handle the launch override if there is one if (!getLaunchOverride().isEmpty()) { fsManager->launchFileAsync(getLaunchOverride()); return; } // Execute this Icon if (!isFileSystemType(Virtual)) { // If this is a folder, then try and browse to it if (scnManager->isShellExtension && isFileSystemType(Folder)) { // try and send a custom message to the proxy window to move to the child incrementNumTimesLaunched(); animManager->finishAnimation(this); SaveSceneToFile(); winOS->ShellExtBrowseToChild(filePath); return; } // This is an image, so zoom to it if we are not already watching it else if (zoomIntoImage && isFileSystemType(Image) && texMgr->isTextureState(thumbnailID, TextureLoaded)) { Key_EnableSlideShow(); this->putToSleep(); // record this zoom interaction statsManager->getStats().bt.interaction.actors.highlightedImage++; return; } // Execute it as normal // QString lnkTarget, lnkArgs, lnkWorkingDir; bool fileLaunched = false; /* if (isFileSystemType(Link)) { fsManager->getShortcutTarget(getFullPath(), &lnkTarget, &lnkArgs, &lnkWorkingDir); fileLaunched = fsManager->launchFileAsync(lnkTarget, lnkArgs, lnkWorkingDir); } else */ fileLaunched = fsManager->launchFileAsync(filePath); if (fileLaunched) { // otherwise, just increment this file launch count and execute it // it is decided that images do not auto-grow (was a design decision) if (!launchImage) { incrementNumTimesLaunched(); } // record this launch statsManager->getStats().bt.interaction.actors.launchedFile++; } } else { incrementNumTimesLaunched(); fsManager->launchFile(filePath); } }
FileSystemPile *FileSystemActor::pileize() { StrList dirListing; QString dirPath; vector<Actor *> objListing; FileSystemActor *obj = NULL; FileSystemPile *p = NULL; // Don't allow Piles to be created recursively if (isParentType(BumpPile)) { MessageClearPolicy clearPolicy; clearPolicy.setTimeout(4); scnManager->messages()->addMessage(new Message("pileize_recPiles", QT_TR_NOOP("Sorry, Items within Piles cannot be viewed as Piles at this time.\nThis feature will be implemented in a later version of BumpTop"), Message::Ok, clearPolicy)); return NULL; } // If this item has been pileized, then just return its pile if (pileizedPile) { return pileizedPile; } if (isFileSystemType(Folder)) { // Get a Directory listing of this folder dirPath = getTargetPath(); dirListing = fsManager->getDirectoryContents(dirPath); // Check if this Folder has anything in it if (dirListing.empty()) { MessageClearPolicy clearPolicy; clearPolicy.setTimeout(4); scnManager->messages()->addMessage(new Message("pileize_emptyFolder", QT_TR_NOOP("This folder is empty, so it can't be expanded to a pile"), Message::Ok, clearPolicy)); return NULL; } // Create a new Pile p = new FileSystemPile(); if (p) { for (uint i = 0; i < dirListing.size(); i++) { obj = FileSystemActorFactory::createFileSystemActor(dirListing[i]); // Create new Actors that represent each item in that directory // NOTE: we need to set the initial size of the object, since we try and sync the post it // in the setFilePath call, which means that it will try and fill to the dims of the // object, which, in it's default size, is not visible text-wise. if (_prevPileizedActorDims.contains(dirListing[i].toLower())) obj->setDims(Vec3(_prevPileizedActorDims.value(dirListing[i].toLower()))); else obj->setDims(getDims()); obj->setGlobalPose(getGlobalPose()); obj->setFilePath(dirListing[i]); objListing.push_back(obj); } // Add items to this Pile for (uint i = 0; i < objListing.size(); i++) { p->addToPile(objListing[i]); } // Save and setup initial states p->setOwner(this); p->setText(getFullText()); p->stack(getGlobalPosition()); // set the icon to be this actor's if (isFileSystemType(Folder)) p->setTextIcon(getTextureID()); // Create custom Animations for (uint i = 0; i < objListing.size(); i++) { objListing[i]->setAlphaAnim(0.0f, 1.0f, 15); } // Make this actor Non-existent this->hideAndDisable(); // Finish up by setting the pile as the current selection pileizedPile = p; sel->remove((BumpObject *) this); sel->add((Pile *) p); textManager->invalidate(); // record this pilization statsManager->getStats().bt.interaction.piles.pilized++; return p; } } return NULL; }
/** * Returns the position vector V (expressed in the global coordinate system) expressed in this coordinate system. */ position_type transformFromGlobal(const position_type& V) const { return getGlobalPose().transformFromParent(V); };