void GameState::setUpQuaternion() { //设置跑道标准开始方向 Ogre::SceneNode* sn = mSceneMgr->getRootSceneNode()->createChildSceneNode(); Ogre::Vector3 dir = mSceneMgr->getSceneNode("R1PS")->_getDerivedPosition() - mSceneMgr->getSceneNode("R1P1")->_getDerivedPosition(); sn->setDirection(dir); mStdQuaternion = sn->getOrientation(); }
Ring::Ring(Ogre::String name, RingFlier* flier):flier(flier) { check=true; ringName=name; position.x=(rand()%5000); position.z=(rand()%5000); position.y=(rand()%700)+flier->getTerrainHeightAt(position.x,position.z)+100.0f; Ogre::SceneNode* sn = flier->getSceneManager()->getRootSceneNode()->createChildSceneNode("sn"+name); Ogre::Entity* ring = flier->getSceneManager()->createEntity(name,"Torus.mesh"); sn->attachObject(ring); sn->scale(Ogre::Vector3(015.10f,015.10f,015.10f)); sn->setPosition(position); sn->setVisible(true); sn->setOrientation(Ogre::Quaternion(Ogre::Radian(30.0f), Ogre::Vector3::UNIT_Z)); sn->setDirection(rand()%10,rand()%10,rand()%10,Ogre::Node::TransformSpace::TS_LOCAL,Ogre::Vector3::NEGATIVE_UNIT_Z); Ogre::ParticleSystem* pSysRing = flier->getSceneManager()->createParticleSystem(ringName+'p',"PEExamples/ringShimmer"); flier->getSceneManager()->getSceneNode("sn"+ringName)->attachObject(pSysRing); }
bool PlaypenApp::appFrameStarted(opal::real dt) { // Do per-frame application-specific things here. // Handle speech input. bool keepLooping = true; bool makeObject = false; std::string material; ObjectType type; std::string outputString; while (voce::getRecognizerQueueSize() > 0) { std::string s = voce::popRecognizedString(); //// Check if the string contains 'quit'. //if (std::string::npos != s.rfind("quit")) //{ // keepLooping = false; //} // Check if we should reset. if (std::string::npos != s.rfind("reset")) { // Make sure the PhysicalCamera isn't grabbing anything. mPhysicalCamera->release(); destroyAllPhysicalEntities(); setupInitialPhysicalEntities(); voce::synthesize("reset"); return true; } // Check for material color. if (std::string::npos != s.rfind("yellow")) { outputString += "yellow"; material = "Plastic/Yellow"; } else if (std::string::npos != s.rfind("red")) { outputString += "red"; material = "Plastic/Red"; } else if (std::string::npos != s.rfind("blue")) { outputString += "blue"; material = "Plastic/Blue"; } else if (std::string::npos != s.rfind("green")) { outputString += "green"; material = "Plastic/Green"; } else if (std::string::npos != s.rfind("purple")) { outputString += "purple"; material = "Plastic/Purple"; } else if (std::string::npos != s.rfind("orange")) { outputString += "orange"; material = "Plastic/Orange"; } else { // Default to dark gray. material = "Plastic/DarkGray"; } // Check for object type. if (std::string::npos != s.rfind("box")) { outputString += " box"; type = OBJECT_TYPE_BOX; makeObject = true; } else if (std::string::npos != s.rfind("sphere")) { outputString += " sphere"; type = OBJECT_TYPE_SPHERE; makeObject = true; } else if (std::string::npos != s.rfind("wall")) { outputString += " wall"; type = OBJECT_TYPE_WALL; makeObject = true; } else if (std::string::npos != s.rfind("tower")) { outputString += " tower"; type = OBJECT_TYPE_TOWER; makeObject = true; } else if (std::string::npos != s.rfind("character")) { outputString += " character"; type = OBJECT_TYPE_RAGDOLL; makeObject = true; } if (makeObject) { voce::synthesize(outputString); createObject(material, type); } } // Update the grasping spring line. if (mPhysicalCamera->isGrasping()) { Ogre::Entity* pickingSphere = mSceneMgr->getEntity("pickingSphere"); if (!pickingSphere->isVisible()) { pickingSphere->setVisible(true); } Ogre::Entity* springLine = mSceneMgr->getEntity("springLine"); if (!springLine->isVisible()) { springLine->setVisible(true); } opal::Point3r desiredPos = mPhysicalCamera->getGraspGlobalPos(); Ogre::Vector3 point0(desiredPos[0], desiredPos[1], desiredPos[2]); opal::Point3r attachPos = mPhysicalCamera->getAttachGlobalPos(); Ogre::Vector3 point1(attachPos[0], attachPos[1], attachPos[2]); pickingSphere->getParentSceneNode()->setPosition(point1); Ogre::Vector3 lineVec = point0 - point1; if (!lineVec.isZeroLength()) { Ogre::SceneNode* springLineNode = springLine->getParentSceneNode(); springLineNode->setPosition(0.5 * (point0 + point1)); springLineNode->setDirection(lineVec); springLineNode->setScale(0.1, 0.1, lineVec.length()); } else { springLine->setVisible(false); } } else { Ogre::Entity* pickingSphere = mSceneMgr->getEntity("pickingSphere"); if (pickingSphere->isVisible()) { pickingSphere->setVisible(false); } Ogre::Entity* springLine = mSceneMgr->getEntity("springLine"); if (springLine->isVisible()) { springLine->setVisible(false); } } // Return true to continue looping. return keepLooping; }
//----------------------------------------------------------------------- // void LightRenderer::_updateRenderQueue(Ogre::RenderQueue* queue, ParticlePool* pool) // { // ParticleRenderer::_updateRenderQueue(queue, pool); // } //----------------------------------------------------------------------- void LightRenderer::_processParticle(ParticleTechnique* particleTechnique, Particle* particle, Real timeElapsed, bool firstParticle) { if (!mVisible) return; VisualParticle* visualParticle = static_cast<VisualParticle*>(particle); LightRendererVisualData* visualData = static_cast<LightRendererVisualData*>(particle->visualData); // Check whether the particle has visual data if (!visualData && !mVisualData.empty()) { visualParticle->visualData = mVisualData.back(); mVisualData.pop_back(); } visualData = static_cast<LightRendererVisualData*>(particle->visualData); if (!visualData) return; // Update the node Ogre::SceneNode* node = visualData->node; if (!node) return; node->_setDerivedPosition(visualParticle->position); node->setDirection(visualParticle->direction, Ogre::Node::TS_WORLD); // Needed for direction of spotlight Ogre::Light* light = visualData->light; if (!light) return; // Update the light: The light gets the diffuse colour from the particle, so Colour Affectors etc. can be used. light->setDiffuseColour(visualParticle->colour.r, visualParticle->colour.g, visualParticle->colour.b); // Update the counters (if needed) if (mFlashFrequency > 0.0f) { visualData->flashFrequencyCount += timeElapsed; if (visualData->flashFrequencyCount > mFlashFrequency) { visualData->flashFrequencyCount -= mFlashFrequency; // Update the light if (mFlashRandom) { if (Math::UnitRandom() > 0.5f) { light->setVisible(!light->isVisible()); } } else { light->setVisible(true); visualData->flashLengthCount = 0.0f; } } if (!mFlashRandom && light->isVisible()) { visualData->flashLengthCount += timeElapsed; if (visualData->flashLengthCount > mFlashLength) { light->setVisible(false); visualData->flashLengthCount -= mFlashLength; } } } else { light->setVisible(true); } }
bool PlaypenApp::appFrameStarted(opal::real dt) { // Do per-frame application-specific things here. // Update the grasping spring line. if (mPhysicalCamera->isGrasping()) { Ogre::Entity* pickingSphere = mSceneMgr->getEntity("pickingSphere"); if (!pickingSphere->isVisible()) { pickingSphere->setVisible(true); } Ogre::Entity* springLine = mSceneMgr->getEntity("springLine"); if (!springLine->isVisible()) { springLine->setVisible(true); } opal::Point3r desiredPos = mPhysicalCamera->getGraspGlobalPos(); Ogre::Vector3 point0(desiredPos[0], desiredPos[1], desiredPos[2]); opal::Point3r attachPos = mPhysicalCamera->getAttachGlobalPos(); Ogre::Vector3 point1(attachPos[0], attachPos[1], attachPos[2]); pickingSphere->getParentSceneNode()->setPosition(point1); Ogre::Vector3 lineVec = point0 - point1; if (!lineVec.isZeroLength()) { Ogre::SceneNode* springLineNode = springLine->getParentSceneNode(); springLineNode->setPosition(0.5 * (point0 + point1)); springLineNode->setDirection(lineVec, Ogre::Node::TS_WORLD); springLineNode->setScale(0.1, 0.1, lineVec.length()); } else { springLine->setVisible(false); } } else { Ogre::Entity* pickingSphere = mSceneMgr->getEntity("pickingSphere"); if (pickingSphere->isVisible()) { pickingSphere->setVisible(false); } Ogre::Entity* springLine = mSceneMgr->getEntity("springLine"); if (springLine->isVisible()) { springLine->setVisible(false); } } // Return true to continue looping. return true; }