Exemplo n.º 1
0
void EC_WaterPlane::SetParent()
{
    if (!ViewEnabled())
        return;
    
    CreateWaterPlane();
    
    // Parent entity has set.
    // Has parent a placeable?
    EC_Placeable* placeable = dynamic_cast<EC_Placeable*>(FindPlaceable().get());
    if (placeable != 0)
    {
        // Are we currently attached?
        if (attached_ )
        {
            // Now there might be that we are attached to OgreRoot not to placeable node.
            DetachEntity();
            AttachEntity();
        }
    }

    connect(parentEntity,SIGNAL(ComponentAdded(IComponent*, AttributeChange::Type)),
        SLOT(ComponentAdded(IComponent*, AttributeChange::Type)));
    connect(parentEntity,SIGNAL(ComponentRemoved(IComponent*, AttributeChange::Type)),
        SLOT(ComponentRemoved(IComponent*, AttributeChange::Type)));
}
//------------------------------------------------------------------------
int CVehicleActionEntityAttachment::OnEvent(int eventType, SVehicleEventParams &eventParams)
{
	if(eventType == eVE_Hit || eventType == eVE_Destroyed)
	{
		DetachEntity();
	}

	return 0;
}
Exemplo n.º 3
0
void EC_WaterPlane::RemoveWaterPlane()
{
    // Remove waterplane
    if (world_.expired() || !entity_)
        return;

    DetachEntity();

    Ogre::SceneManager* sceneMgr = world_.lock()->GetSceneManager();
    sceneMgr->destroyEntity(entity_);
    entity_ = 0;
    
    Ogre::MeshManager::getSingleton().remove(Name().toStdString().c_str());
}
//-----------------------------------------------------------------------------
// Purpose: 
// Output : float
//-----------------------------------------------------------------------------
float CGrabController::ComputeError()
{
	if ( m_errorTime <= 0 )
		return 0;

	CBaseEntity *pAttached = GetAttached();
	if ( pAttached )
	{
		Vector pos;
		IPhysicsObject *pObj = pAttached->VPhysicsGetObject();
		
		if ( pObj )
		{	
			pObj->GetShadowPosition( &pos, NULL );

			float error = (m_shadow.targetPosition - pos).Length();
			if ( m_errorTime > 0 )
			{
				if ( m_errorTime > 1 )
				{
					m_errorTime = 1;
				}
				float speed = error / m_errorTime;
				if ( speed > m_shadow.maxSpeed )
				{
					error *= 0.5;
				}
				m_error = (1-m_errorTime) * m_error + error * m_errorTime;
			}
		}
		else
		{
			DevMsg( "Object attached to Physcannon has no physics object\n" );
			DetachEntity( false );
			return 9999; // force detach
		}
	}
	
	if ( pAttached->IsEFlagSet( EFL_IS_BEING_LIFTED_BY_BARNACLE ) )
	{
		m_error *= 3.0f;
	}

	m_errorTime = 0;

	return m_error;
}
Exemplo n.º 5
0
void EC_WaterPlane::ComponentRemoved(IComponent* component, AttributeChange::Type type)
{
    if (world_.expired())
        return;
    
    if (component->TypeName() == EC_Placeable::TypeNameStatic() )
    {
        DetachEntity();

        // Attach entity directly to Ogre root.
        Ogre::SceneManager* sceneMgr = world_.lock()->GetSceneManager();
        if (sceneMgr == 0)
            return;

        node_->attachObject(entity_);
        sceneMgr->getRootSceneNode()->addChild(node_);
        node_->setVisible(true);
        attachedToRoot_ = true;
        attached_ = true;
    }
}
Exemplo n.º 6
0
void EC_WaterPlane::ComponentAdded(IComponent* component, AttributeChange::Type type)
{
    if (component->TypeName() == EC_Placeable::TypeNameStatic())
    {
        DetachEntity();

        EC_Placeable* placeable = static_cast<EC_Placeable* >(component);
        if (placeable == 0)
            return;
        if (entity_ == 0)
            return;

        Ogre::SceneNode* node = placeable->GetSceneNode();
        
        node->addChild(node_);
        node_->attachObject(entity_);
        node_->setVisible(true);

        attached_ = true;
    }
}
void CGrabController::SetTargetPosition( const Vector &target, const QAngle &targetOrientation )
{
	m_shadow.targetPosition = target;
	m_shadow.targetRotation = targetOrientation;

	m_timeToArrive = gpGlobals->frametime;

	CBaseEntity *pAttached = GetAttached();
	if ( pAttached )
	{
		IPhysicsObject *pObj = pAttached->VPhysicsGetObject();
		
		if ( pObj != NULL )
		{
			pObj->Wake();
		}
		else
		{
			DetachEntity( false );
		}
	}
}
Exemplo n.º 8
0
	void SetTargetPosition( const Vector &target, const QAngle &targetOrientation )
	{
		m_shadow.targetPosition = target;
		m_shadow.targetRotation = targetOrientation;

		m_timeToArrive = gpGlobals->frametime;

		CBaseEntity *pAttached = m_attachedEntity;
		if ( pAttached )
		{
			IPhysicsObject *pObj = GetPhysObjFromPhysicsBone( pAttached, m_attachedPhysicsBone );
			
			if ( pObj != NULL )
			{
				pObj->Wake();
			}
			else
			{
				DetachEntity();
			}
		}
	}
CGrabController::~CGrabController( void )
{
	DetachEntity( false );
}
Exemplo n.º 10
0
CGravControllerPoint::~CGravControllerPoint( void )
{
	DetachEntity();
}