示例#1
0
	void PlayerShip::takeDamage(DamagePackage& pack, double time){
		float dam=0;
		//DamagePackage& pack = hitter->getDamagePackage();
		if (pack.getDamageCycle() == DAM_CYCLE_INSTANT){
			dam = pack.getTotalDamage();
		}else if (pack.getDamageCycle() == DAM_CYCLE_CONTINUOUS){
			dam = pack.getTotalDamage()*time;//Level::getSingleton()->getTimeDelta();
		}
		if (mShield > 0){
			mShield-=dam;
			if (mShield < 0){
				mHealth += mShield;
				mShield = 0;
			}
		}else{
			mHealth-=dam;
		}
		if (mHealth <= 0){
			setQueryFlags(SceneQueryFlag::SceneQueryFlag::IMMATERIAL);
			ceaseFire(0);
			ceaseFire(1);
			mDeathFX->setParent(mSceneNode);
			mDeathFX->build();
			mDeathFX->activate();
			mEntity->setVisible(false);
			//mLevelSegment->getActiveCamera()->shake(10000);
			mTimeToReset = 3;
			//throw("You are dead");
		}
	}
示例#2
0
SelectionBox::SelectionBox(const Ogre::String& name): Ogre::ManualObject(name)
{
	setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY); // when using this, ensure Depth Check is Off in the material
	setUseIdentityProjection(true);
	setUseIdentityView(true);
	setQueryFlags(0);
}
	//-------------------------------------------------------------------------
	void Sound::init()
	{
		mBstElemHandle = BST::NULL_HANDLE;
		m3D = false;
		mVolume = 1;
		mEnabled = true;
		mSoundMaxDistance = Math::POS_INFINITY;
		mSoundBoundingBox.setInfinite();
		mSoundBoundingBoxInLocalSpace = true;
		mInVolumeSmoothingTime = 0;
		mOutVolumeSmoothingTime = 0;
		mNumPlayed = 0;
		mPriority = Priority::LOWEST;
		mDestroyOnEnd = false;
		mLoopMode = SoundLoopMode::PLAY_ONCE;
		mMinDelay = 0;
		mMinDelayLengthMultiplier = 0;
		mMaxDelay = 0;
		mMaxDelayLengthMultiplier = 0;
		mSoundGroupEntry = nullptr;
		mSoundPlayInfo = nullptr;
		mSoundScene = nullptr;

		setCastShadows(false);
		setQueryFlags(0);
		setVisibilityFlags(0);
	}
示例#4
0
文件: Axis3d.cpp 项目: gitrider/wxsj2
   AxisRenderable::AxisRenderable(int lineCount,Ogre::Camera* camera,Ogre::Viewport* viewport) 
   {
        // Disable cast shadows by default
        mCastShadows = false;

      mPrevAxisGizmoSelAxis = -1;
      mCamera = camera;
      mViewport = viewport;

      m_max_line_count = m_line_count  = lineCount;
      m_line_count = 0;

      mLength = 200;
      mProjectDistance = mCamera->getFarClipDistance();
      m_local = false;
      m_locked_data = 0;
      //m_locked_buffer = 0;
      mRenderOp.vertexData = new Ogre::VertexData();
      m_radius = 0;

      mRenderOp.indexData = 0;
      mRenderOp.vertexData->vertexCount = m_line_count*2;
      mRenderOp.vertexData->vertexStart = 0;

      mRenderOp.operationType = Ogre::RenderOperation::OT_LINE_LIST; 
      mRenderOp.useIndexes = false; 

      Ogre::VertexDeclaration* decl = mRenderOp.vertexData->vertexDeclaration;
      Ogre::VertexBufferBinding* bind = mRenderOp.vertexData->vertexBufferBinding;

      decl->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
      decl->addElement(0, 3*sizeof(Ogre::Real), Ogre::VET_COLOUR, Ogre::VES_DIFFUSE);

      Ogre::HardwareVertexBufferSharedPtr vbuf = 
         Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
         decl->getVertexSize(0),
         2*m_max_line_count,
         Ogre::HardwareBuffer::HBU_WRITE_ONLY);

      bind->setBinding(0, vbuf);

      // Obtain the pure colour material
      Ogre::MaterialPtr pureColourMaterial = createPureColourMaterial(Ogre::ColourValue(1,1,0));

      Ogre::String realName = pureColourMaterial->getName() + "_NoDepthBuffer";
      Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName(realName);
      if (material.isNull())
      {
          // Clone to avoid confuse somewhere else that using the same material
          material = pureColourMaterial->clone(realName);
          material->setDepthCheckEnabled(false);
          material->setDepthWriteEnabled(false);
      }

      setMaterial(material->getName());

      mBox.setExtents(-10,-10,-10,10,10,10);
      setQueryFlags(0);
   }
示例#5
0
//-------------------------------------------------------------------------------------
SelectionBox::SelectionBox(const Ogre::String& name): Ogre::ManualObject(name)
{
    /** Constructor\n
     *  set projection and view identity matrix\n
     *  not query itself\n
	*/
	setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY);
	setUseIdentityProjection(true);
	setUseIdentityView(true);
	setQueryFlags(0);
}
示例#6
0
	SelectionBox::SelectionBox(const std::string& i_name, Ogre::SceneManager& i_manager)
		: ManualObject(i_name)
		, m_scene_manager(i_manager)
		{
		setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY); // when using this, ensure Depth Check is Off in the material
		setUseIdentityProjection(true);
		setUseIdentityView(true);
		setQueryFlags(0);

		m_scene_manager.getRootSceneNode()->attachObject(this);
		}
示例#7
0
	void PlayerShip::resetStats(){
		mShield = mPlayerDetails.mShield;
		mHealth = mPlayerDetails.mArmour;
		mScore = 0;
		currentWeapon = 0;
		mLockLevel = 0;
		mInvulnerabilityTimer = 0;
		mWanted.x = 0;
		mWanted.y = 0;
		mWanted.z = 0;
		mSpeed.x = 0;
		mSpeed.y = 0;
		mSpeed.z = 0;
		mWeaponsFree = true;
		mDeltaMovement = Vector2(0,0);
		setQueryFlags(SceneQueryFlag::SceneQueryFlag::PLAYER_SHIP);
	}
示例#8
0
  void Player::spawn( const Vector3& position, const Quaternion& orientation )
  {
    Character::spawn( position, orientation );

    mMesh = Procedural::CapsuleGenerator().setHeight( mHeight ).setRadius( mRadius ).realizeMesh( "playerStandCapsule" );

    mItem = Locator::getGraphics().getScene()->createItem( mMesh );
    mItem->setQueryFlags( SceneQueryFlag_Character );
    mItem->setDatablock( "Developer/Placeholder/Player" );
    mItem->setCastShadows( true );
    mNode->attachObject( mItem );

    auto skull = Locator::getGraphics().getScene()->createEntity( "skull_02.mesh" );
    auto snode = mNode->createChildSceneNode( Ogre::SCENE_DYNAMIC, Vector3( 0, 1.5f, 0 ) );
    skull->setQueryFlags( SceneQueryFlag_Camera );
    snode->attachObject( skull );
  }
	OctreeTriggerPlayer::OctreeTriggerPlayer(const String &name , OctreeTriggerWorld *world)
		: m_name(name)
		, m_world(world)
		, m_sceneMgr(0)
		, m_node(0)
		, m_radius(1)
		, m_query(0)
		, m_aabb(-0.5 , -0.5 , -0.5 , 0.5 , 0.5 , 0.5)
		, MovableObject(name)
	{
		m_sceneMgr = world->getSceneManager();
		m_node = m_sceneMgr->getRootSceneNode()->createChildSceneNode(name);
		m_node->attachObject(this);
		// 玩家不参加碰撞计算
		setQueryFlags(0);
		MovableObject::setUserAny(Any(static_cast<ITriggerEntity*>(this)));

		// 创建一个缺省的包围盒查询器
		m_query = m_sceneMgr->createAABBQuery(AxisAlignedBox());
	}
示例#10
0
    void
        TerrainGridRenderable::initTerrainGrid(int vertexCount)
    {
        m_locked_data = 0;

        mRenderOp.vertexData = new Ogre::VertexData();
        mRenderOp.indexData = 0;

        mRenderOp.vertexData->vertexCount = mVertexCount;
        mRenderOp.vertexData->vertexStart = 0;

        mRenderOp.operationType = Ogre::RenderOperation::OT_LINE_LIST; 
        mRenderOp.useIndexes = false; 

        Ogre::VertexDeclaration* decl = mRenderOp.vertexData->vertexDeclaration;
        Ogre::VertexBufferBinding* bind = mRenderOp.vertexData->vertexBufferBinding;

        decl->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
        decl->addElement(0, 3*sizeof(Ogre::Real), Ogre::VET_COLOUR, Ogre::VES_DIFFUSE);

        Ogre::HardwareVertexBufferSharedPtr vbuf = 
            Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
            decl->getVertexSize(0),
            vertexCount,
            Ogre::HardwareBuffer::HBU_WRITE_ONLY);

        bind->setBinding(0, vbuf);

        // set basic white material
        this->setMaterial("BaseWhiteNoLighting");
        mBox.setExtents(-10,-10,-10,10,10,10);

        lock();
        drawGridLines();
        unlock();
        
	//	getMaterial()->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
        setQueryFlags(0);
    }
示例#11
0
    SelectionBox::SelectionBox(const Ogre::String name, Engine *engine):
        Ogre::ManualObject(name),
        mEngine(engine),
        mLeft(.0f), mTop(.0f), mRight(.0f), mBottom(.0f),
        mVolQuery(nullptr)
    {
        /*The first function sets the render queue for the object to be the Overlay queue.
         The next two functions set the projection and view matrices to be the identity. Projection and
         view matrices are used by many rendering systems (such as OpenGL and DirectX) to define where
         objects go in the world. Since Ogre abstracts this away for us, we won't go into detail about
         what these matrices actually are or what they do. Instead what you need to know is that if you
         set the projection and view matrix to be the identity, as we have here, we will basically create a
         2D object. When defining this object, the coordinate system changes a bit. We no longer deal with
         the Z axis (if you are asked for the Z axis, set the value to -1). Instead we have a new coordinate
         system with X and Y running from -1 to 1 inclusive. Lastly, we will set the query flags for the object
         to be 0, which will prevent the selection rectangle from being included in the query results.*/
        setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY); // when using this, ensure Depth Check is Off in the material
        setUseIdentityProjection(true);
        setUseIdentityView(true);
        setQueryFlags(0);

        {
            Ogre::MaterialPtr const whiteNoLignthing = Ogre::MaterialManager::getSingleton().getByName("BaseWhiteNoLighting");
            Ogre::String const resName = "DynamicLines_BaseWhiteNoLighting_"+mEngine->level()->name();
            mMaterial = Ogre::MaterialManager::getSingleton().getByName(resName);
            if(mMaterial.isNull())
            {
                mMaterial = whiteNoLignthing->clone(resName, true, mEngine->level()->name());
                mMaterial->load();
            }
            mMaterial->setDepthCheckEnabled(false);
        }

        if(nullptr != mEngine->level())
        {
            mEngine->level()->levelRoot()->createChildSceneNode()->attachObject(this);
            mVolQuery = mEngine->level()->sceneManager()->createPlaneBoundedVolumeQuery(Ogre::PlaneBoundedVolumeList());
        }
    }