Ejemplo n.º 1
0
void ceNode::FinishTransformationPrivate()
{
  if (_parent)
    {
      _globalMatrix  = _parent->_globalMatrix * _localMatrix;
    }
  else
    {
      _globalMatrix = _localMatrix;
    }

  if (_inversionDirty)
    {
      _localMatrixInverted = _localMatrix.FastInverted();
      _globalMatrixInverted = _globalMatrix.FastInverted();
      _inversionDirty = false;
    }

  // if this is an entity or something else that has data attached, this should get propagated
  UpdateTransformation();

  for (int i=_children.size()-1; i>=0; --i)
    {
      ceNode* child = _children[i];
      child->FinishTransformationPrivate();
    }

  UpdateBoundingBox();

}
Ejemplo n.º 2
0
void KG3DTransformation::UpdateByMatrix(const D3DXMATRIX& mat) 
{
    AffineParts affineParts;
    
    ReSet();
    MatrixDecomposeAffine(mat, affineParts);
    
    m_ScalingRotation.x = affineParts.u.x;
    m_ScalingRotation.y = affineParts.u.y;
    m_ScalingRotation.z = affineParts.u.z;
    m_ScalingRotation.w = affineParts.u.w;

    m_Scaling.x = affineParts.k.x;
    m_Scaling.y = affineParts.k.y;
    m_Scaling.z = affineParts.k.z;

    m_Rotation.x = affineParts.q.x;
    m_Rotation.y = affineParts.q.y;
    m_Rotation.z = affineParts.q.z;
    m_Rotation.w = affineParts.q.w;
    ASSERT_FLOAT_IS_VALIED(m_Rotation.x);

    m_Translation.x = affineParts.t.x;
    m_Translation.y = affineParts.t.y;
    m_Translation.z = affineParts.t.z;

	m_bSleep = FALSE;

    UpdateTransformation();
}
Ejemplo n.º 3
0
void KG3DTransformation::SetRotation(const D3DXQUATERNION* pValue)
{
	m_Rotation = *pValue;
    ASSERT_FLOAT_IS_VALIED(m_Rotation.x);

	m_bSleep = FALSE;
	UpdateTransformation();
}
Ejemplo n.º 4
0
void KG3DTransformation::NormalizeRotation()
{
    D3DXQuaternionNormalize(&m_Rotation, &m_Rotation);
    ASSERT_FLOAT_IS_VALIED(m_Rotation.x);

    D3DXQuaternionNormalize(&m_ScalingRotation, &m_ScalingRotation);
    UpdateTransformation();
}
Ejemplo n.º 5
0
Matrix4 Camera::GetViewProjection() const
{
	if (mIsDirty || LocalTransform.IsDirty())
	{
		UpdateTransformation();
		mViewProj = mProjection * WorldTransform;
		mIsDirty = false;
	}
	return mViewProj;
}
Ejemplo n.º 6
0
void KG3DTransformation::Interpolation(KG3DTransformation &NextTrans, float fFactor)
{
    m_ScalingCenter += (NextTrans.m_ScalingCenter - m_ScalingCenter) * fFactor;
    m_Scaling += (NextTrans.m_Scaling - m_Scaling) * fFactor;
    m_RotationCenter += (NextTrans.m_RotationCenter - m_RotationCenter) * fFactor;
    m_Translation += (NextTrans.m_Translation - m_Translation) * fFactor;
    D3DXQuaternionSlerp(&m_ScalingRotation, &m_ScalingRotation, &NextTrans.m_ScalingRotation, fFactor);
    D3DXQuaternionSlerp(&m_Rotation, &m_Rotation, &NextTrans.m_Rotation, fFactor);
    ASSERT_FLOAT_IS_VALIED(m_Rotation.x);

    UpdateTransformation();
}
Ejemplo n.º 7
0
void
UiWidget::Update()
{
    if(m_Visible != true)
    {
        return;
    }

    if(m_AnimationCurrent != nullptr)
    {
        float delta_time = Timer::getSingleton().GetGameTimeDelta();
        float time = m_AnimationCurrent->GetTime();

        // if animation ended
        if(time + delta_time >= m_AnimationEndTime)
        {
            if(time != m_AnimationEndTime)
            {
                m_AnimationCurrent->AddTime(m_AnimationEndTime - time);
            }

            for(unsigned int i = 0; i < m_AnimationSync.size(); ++i)
            {
                ScriptManager::getSingleton().ContinueScriptExecution(m_AnimationSync[i]);
            }
            m_AnimationSync.clear();

            if(m_AnimationState == UiAnimation::DEFAULT && m_AnimationDefault != "")
            {
                // in case of cycled default we need to sync with end
                time = time + delta_time - m_AnimationCurrent->GetLength();
                PlayAnimation(m_AnimationDefault, UiAnimation::DEFAULT, time, -1);
            }
            else
            {
                m_AnimationCurrent = NULL;
            }
        }
        else
        {
            m_AnimationCurrent->AddTime(delta_time);
        }
    }
    else if( m_AnimationCurrent == NULL && m_AnimationState == UiAnimation::DEFAULT && m_AnimationDefault != "" )
    {
        PlayAnimation( m_AnimationDefault, UiAnimation::DEFAULT, 0, -1 );
    }



    if( m_UpdateTransformation == true )
    {
        UpdateTransformation();
    }



    for( unsigned int i = 0; i < m_Children.size(); ++i )
    {
        m_Children[ i ]->Update();
    }


    // debug output
    if(cv_debug_ui.GetI() >= 1)
    {
        float local_x1 = -m_FinalOrigin.x;
        float local_y1 = -m_FinalOrigin.y;
        float local_x2 = m_FinalSize.x + local_x1;
        float local_y2 = m_FinalSize.y + local_y1;
        float x = m_FinalTranslate.x;
        float y = m_FinalTranslate.y;

        DEBUG_DRAW.SetScreenSpace(true);

        DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 0, 0, 1));

        int x1, y1, x2, y2, x3, y3, x4, y4;

        if(m_FinalRotation != 0)
        {
            float cos = Ogre::Math::Cos(Ogre::Radian(Ogre::Degree(m_FinalRotation)));
            float sin = Ogre::Math::Sin(Ogre::Radian(Ogre::Degree(m_FinalRotation)));

            x1 = static_cast<int>(local_x1 * cos - local_y1 * sin + x);
            y1 = static_cast<int>(local_x1 * sin + local_y1 * cos + y);
            x2 = static_cast<int>(local_x2 * cos - local_y1 * sin + x);
            y2 = static_cast<int>(local_x2 * sin + local_y1 * cos + y);
            x3 = static_cast<int>(local_x2 * cos - local_y2 * sin + x);
            y3 = static_cast<int>(local_x2 * sin + local_y2 * cos + y);
            x4 = static_cast<int>(local_x1 * cos - local_y2 * sin + x);
            y4 = static_cast<int>(local_x1 * sin + local_y2 * cos + y);
        }
        else
        {
            x1 = static_cast<int>(local_x1 + x);
            y1 = static_cast<int>(local_y1 + y);
            x2 = static_cast<int>(local_x2 + x);
            y2 = static_cast<int>(local_y1 + y);
            x3 = static_cast<int>(local_x2 + x);
            y3 = static_cast<int>(local_y2 + y);
            x4 = static_cast<int>(local_x1 + x);
            y4 = static_cast<int>(local_y2 + y);
        }

        // slightly modify to let show things that are on board of screen
        DEBUG_DRAW.Line(static_cast<float>(x1), static_cast<float>(y1 + 1), static_cast<float>(x2), static_cast<float>(y2 + 1));
        DEBUG_DRAW.Line(static_cast<float>(x2 - 1), static_cast<float>(y2), static_cast<float>(x3 - 1), static_cast<float>(y3));
        DEBUG_DRAW.Line(static_cast<float>(x3), static_cast<float>(y3), static_cast<float>(x4), static_cast<float>(y4));
        DEBUG_DRAW.Line(static_cast<float>(x4), static_cast<float>(y4), static_cast<float>(x1), static_cast<float>(y1));

        // draw translation
        DEBUG_DRAW.SetColour(Ogre::ColourValue(0, 1, 0, 1));
        Ogre::Vector2 area_origin = (m_Parent != nullptr) ? m_Parent->GetFinalOrigin() : Ogre::Vector2::ZERO;
        Ogre::Vector2 area_translate = (m_Parent != nullptr) ? m_Parent->GetFinalTranslate() : Ogre::Vector2::ZERO;
        Ogre::Vector2 pos = area_translate - area_origin;
        DEBUG_DRAW.Line(pos.x, pos.y, x, y);
        DEBUG_DRAW.Quad(x - 2, y - 2, x + 2, y - 2, x + 2, y + 2, x - 2, y + 2);

        if(cv_debug_ui.GetI() >= 2)
        {
            DEBUG_DRAW.SetColour(Ogre::ColourValue::White);
            DEBUG_DRAW.SetTextAlignment(DEBUG_DRAW.LEFT);
            DEBUG_DRAW.Text(static_cast<float>(x1 + 3), static_cast<float>(y1), m_PathName);
            DEBUG_DRAW.Text(static_cast<float>(x1 + 3), static_cast<float>(y1 + 12), GetCurrentAnimationName());
        }

        // draw origin
        DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 0, 0, 1));
        DEBUG_DRAW.Line(x, y, static_cast<float>(x1), static_cast<float>(y1 + 1));
    }
}
Ejemplo n.º 8
0
void KG3DTransformation::SetRotationCenter(const D3DXVECTOR3* pValue)
{
	m_RotationCenter = *pValue;
	m_bSleep = FALSE;
	UpdateTransformation();
}
Ejemplo n.º 9
0
void  KG3DTransformation::SetTranslation(const D3DXVECTOR3* pValue)
{
	m_Translation = *pValue;
	m_bSleep = FALSE;
	UpdateTransformation();
}
Ejemplo n.º 10
0
void KG3DTransformation::SetScalingRotation(const D3DXQUATERNION* pValue)
{
	m_ScalingRotation= *pValue;
	m_bSleep = FALSE;
	UpdateTransformation();
}
Ejemplo n.º 11
0
void KG3DTransformation::SetScaling(const D3DXVECTOR3* pValue)
{
	m_Scaling = *pValue;
	m_bSleep = FALSE;
	UpdateTransformation();
}