Пример #1
0
//-------------------------------------------------------------------------------------
void AxisLines::initAxis(Ogre::String boneName, Ogre::Entity* entity, Ogre::SceneManager* mSceneManager)
{

	if(isXVisible)	/* red */
	{
		xLine = new DynamicLines(Ogre::RenderOperation::OT_LINE_LIST);
		entity->attachObjectToBone(boneName, xLine);
		xLine->setMaterial(color1);
	}

	if(isYVisible) /* green */
	{
		yLine = new DynamicLines(Ogre::RenderOperation::OT_LINE_LIST);
		entity->attachObjectToBone(boneName, yLine);
		yLine->setMaterial(color2);
	}

	if(isZVisible) /* blue */
	{
		zLine = new DynamicLines(Ogre::RenderOperation::OT_LINE_LIST);
		entity->attachObjectToBone(boneName, zLine);
		zLine->setMaterial(color3);
	}

	Ogre::Bone* bone = entity->getSkeleton()->getBone(boneName);
	Ogre::Quaternion q = bone->getOrientation();
	this->updateLines(q.xAxis(), q.yAxis(), q.zAxis());
}
Пример #2
0
	bool Framework::frameRenderingQueued(const Ogre::FrameEvent& evt)
	{
		mTrayMgr->frameRenderingQueued(evt);

		if (!mTrayMgr->isDialogVisible())
		{
			mCameraMan->frameRenderingQueued(evt);   // if dialog isn't up, then update the camera

			if (mDetailsPanel->isVisible())   // if details panel is visible, then update its contents
			{
				mDetailsPanel->setParamValue(0, Ogre::StringConverter::toString(mCamera->getDerivedPosition().x));
				mDetailsPanel->setParamValue(1, Ogre::StringConverter::toString(mCamera->getDerivedPosition().y));
				mDetailsPanel->setParamValue(2, Ogre::StringConverter::toString(mCamera->getDerivedPosition().z));
				mDetailsPanel->setParamValue(4, Ogre::StringConverter::toString(mCamera->getDerivedOrientation().w));
				mDetailsPanel->setParamValue(5, Ogre::StringConverter::toString(mCamera->getDerivedOrientation().x));
				mDetailsPanel->setParamValue(6, Ogre::StringConverter::toString(mCamera->getDerivedOrientation().y));
				mDetailsPanel->setParamValue(7, Ogre::StringConverter::toString(mCamera->getDerivedOrientation().z));

#ifdef USE_RTSHADER_SYSTEM
				mDetailsPanel->setParamValue(14, Ogre::StringConverter::toString(mShaderGenerator->getVertexShaderCount()));
				mDetailsPanel->setParamValue(15, Ogre::StringConverter::toString(mShaderGenerator->getFragmentShaderCount()));		
#endif

				Ogre::Quaternion q = mCamera->getDerivedOrientation();
				mDetailsPanel->setParamValue(16,  Ogre::StringConverter::toString(q.xAxis() ) );
				mDetailsPanel->setParamValue(17,  Ogre::StringConverter::toString(q.yAxis() ));
				mDetailsPanel->setParamValue(18,  Ogre::StringConverter::toString(q.zAxis() ));															

			}	

		}

		return true;
	}
        void SoundListener::updateListener()
        {                           
          Ogre::Vector3 position = this->getPosition().Meter() ;
          alListener3f(AL_POSITION, (float)position.x, (float)position.y, (float)position.z);
          Ogre::Quaternion orientation = this->getOrientation().getQuaternion();

          ALfloat openal_orientation[6] ;
          openal_orientation[0] = orientation.zAxis().x ;
          openal_orientation[1] = orientation.zAxis().y ;
          openal_orientation[2] = orientation.zAxis().z ;
          openal_orientation[3] = orientation.yAxis().x ;
          openal_orientation[4] = orientation.yAxis().y ;
          openal_orientation[5] = orientation.yAxis().z ;
          
          alListenerfv(AL_ORIENTATION, openal_orientation) ; 
                      
          Ogre::Vector3 speed = this->getSpeed().MeterPerSecond();
          alListener3f(AL_VELOCITY, (float)speed.x, (float)speed.y, (float)speed.z) ;
          alListenerf(AL_GAIN,getGain()) ;
        }
Пример #4
0
/*/////////////////////////////////////////////////////////////////*/
void OgreOggListener::setOrientation(const Ogre::Quaternion& q) {
  Ogre::Vector3 vDirection = q.zAxis();
  Ogre::Vector3 vUp = q.yAxis();

  mOrientation[0] = -vDirection.x;
  mOrientation[1] = -vDirection.y;
  mOrientation[2] = -vDirection.z;
  mOrientation[3] = vUp.x;
  mOrientation[4] = vUp.y;
  mOrientation[5] = vUp.z;
  alListenerfv(AL_ORIENTATION, mOrientation);
}
Пример #5
0
    void ProjectileManager::launchProjectile(Ptr actor, Ptr projectile, const Ogre::Vector3 &pos,
                                             const Ogre::Quaternion &orient, Ptr bow, float speed)
    {
        ProjectileState state;
        state.mActorId = actor.getClass().getCreatureStats(actor).getActorId();
        state.mBowId = bow.getCellRef().getRefId();
        state.mVelocity = orient.yAxis() * speed;
        state.mId = projectile.getCellRef().getRefId();

        MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), projectile.getCellRef().getRefId());
        MWWorld::Ptr ptr = ref.getPtr();

        state.mNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(pos, orient);
        createModel(state, ptr.getClass().getModel(ptr));

        mProjectiles.push_back(state);
    }
Пример #6
0
//-------------------------------------------------------------------------------------
void ControllableCharacter::transformBone(Ogre::String boneName, NuiManager::NuiJointIndex jointIdx)
{
    int state = 0;
    state = (int)controller->getJointStatus(jointIdx);

    if(state == 2)
    {
        Ogre::Bone* bone = skeleton->getBone(boneName);
        Ogre::Quaternion qI = bone->getInitialOrientation();
        Ogre::Quaternion newQ = jointCalc->getSkeletonJointOrientation(jointIdx);

        bone->resetOrientation();
        newQ = bone->convertWorldToLocalOrientation(newQ);
        bone->setOrientation(newQ * qI);

        Ogre::Quaternion resQ = bone->getOrientation();
        if(showBoneOrientationAxes) axisLines[jointIdx]->updateLines(resQ.xAxis(), resQ.yAxis(), resQ.zAxis());		// debug
    }
}
Пример #7
0
    void ProjectileManager::moveMagicBolts(float duration)
    {
        for (std::vector<MagicBoltState>::iterator it = mMagicBolts.begin(); it != mMagicBolts.end();)
        {
            Ogre::Quaternion orient = it->mNode->getOrientation();
            static float fTargetSpellMaxSpeed = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>()
                        .find("fTargetSpellMaxSpeed")->getFloat();
            float speed = fTargetSpellMaxSpeed * it->mSpeed;

            Ogre::Vector3 direction = orient.yAxis();
            direction.normalise();
            Ogre::Vector3 pos(it->mNode->getPosition());
            Ogre::Vector3 newPos = pos + direction * duration * speed;

            if (it->mSound.get())
                it->mSound->setPosition(newPos);

            it->mNode->setPosition(newPos);

            update(it->mObject, duration);

            // Check for impact
            // TODO: use a proper btRigidBody / btGhostObject?
            btVector3 from(pos.x, pos.y, pos.z);
            btVector3 to(newPos.x, newPos.y, newPos.z);

            std::vector<std::pair<float, std::string> > collisions = mPhysEngine.rayTest2(from, to, OEngine::Physic::CollisionType_Projectile);
            bool hit=false;

            for (std::vector<std::pair<float, std::string> >::iterator cIt = collisions.begin(); cIt != collisions.end() && !hit; ++cIt)
            {
                MWWorld::Ptr obstacle = MWBase::Environment::get().getWorld()->searchPtrViaHandle(cIt->second);

                MWWorld::Ptr caster = MWBase::Environment::get().getWorld()->searchPtrViaHandle(it->mCasterHandle);
                if (caster.isEmpty())
                    caster = MWBase::Environment::get().getWorld()->searchPtrViaActorId(it->mActorId);

                if (!obstacle.isEmpty() && obstacle == caster)
                    continue;

                if (caster.isEmpty())
                    caster = obstacle;

                if (obstacle.isEmpty())
                {
                    // Terrain
                }
                else
                {
                    MWMechanics::CastSpell cast(caster, obstacle);
                    cast.mHitPosition = pos;
                    cast.mId = it->mSpellId;
                    cast.mSourceName = it->mSourceName;
                    cast.mStack = it->mStack;
                    cast.inflict(obstacle, caster, it->mEffects, ESM::RT_Target, false, true);
                }

                hit = true;
            }

            // Explodes when hitting water
            if (MWBase::Environment::get().getWorld()->isUnderwater(MWBase::Environment::get().getWorld()->getPlayerPtr().getCell(), newPos))
                hit = true;

            if (hit)
            {
                MWWorld::Ptr caster = MWBase::Environment::get().getWorld()->searchPtrViaActorId(it->mActorId);
                MWBase::Environment::get().getWorld()->explodeSpell(pos, it->mEffects, caster, ESM::RT_Target, it->mSpellId, it->mSourceName);

                MWBase::Environment::get().getSoundManager()->stopSound(it->mSound);

                mSceneMgr->destroySceneNode(it->mNode);

                it = mMagicBolts.erase(it);
                continue;
            }
            else
                ++it;
        }
    }