Exemple #1
0
 void TrfmTranslateZ::computeTransform(){
     mTransform.setZero();
     mTransform(0, 0) = 1.0; 
     mTransform(1, 1) = 1.0; 
     mTransform(2, 2) = 1.0; 
     mTransform(3, 3) = 1.0; 
     mTransform(A_Z, 3) = mDofs[0]->getValue(); 
 }
Exemple #2
0
 void TrfmTranslate::computeTransform(){
     mTransform.setZero();
     mTransform(0, 0) = 1.0; 
     mTransform(1, 1) = 1.0; 
     mTransform(2, 2) = 1.0; 
     mTransform(3, 3) = 1.0; 
     for(unsigned int i=0; i<mDofs.size(); i++){
         mTransform(i, 3) = mDofs[i]->getValue();
     }
 }
Exemple #3
0
    void TrfmRotateQuat::computeTransform(){
        // Quaternion constructor takes (w, x, y, z)
        Quaterniond q(mDofs[0]->getValue(), mDofs[1]->getValue(),mDofs[2]->getValue(),mDofs[3]->getValue());
        q.normalize();

        mTransform.setZero();
        Matrix3d rot = q.matrix();
        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                mTransform(i, j) = rot(i, j);
            }
        }
        mTransform(3, 3) = 1.0;
    }
    void TrfmRotateExpMap::computeTransform(){
        Vector3d q(mDofs[0]->getValue(), mDofs[1]->getValue(), mDofs[2]->getValue());

        Matrix3d rot = utils::rotation::expMapRot(q);
        mTransform.setZero();
        mTransform.topLeftCorner(3,3) = rot;
        mTransform(3, 3) = 1.0;
    }
    PointMatcher<float>::TransformationParameters Transform::pmTransform() const {
        PointMatcher<float>::TransformationParameters pmTransform =
                PointMatcher<float>::TransformationParameters::Identity(4, 4);

        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                pmTransform(i, j) = mTransform(i, j);
            }
        }

        return pmTransform;
    }
    /// \brief
    ///  Calculates the absolute bounding box for this instance
    ///
    /// \param destBBox
    ///  Destination box
    ///
    inline void GetBoundingBox(hkvAlignedBBox &destBBox) const
    {
        m_spModel->EnsureLoaded();
        VASSERT(m_spModel->m_LocalBBox.isValid());
        destBBox.setInvalid();

        //destBBox.Inflate(m_spModel->m_LocalBBox,m_Orientation,m_vPosition);
        {
            hkvAlignedBBox temp = m_spModel->m_LocalBBox;
            hkvMat4 mTransform (m_Orientation, m_vPosition);
            temp.transformFromOrigin (mTransform);
            destBBox.expandToInclude (temp);
        }

    }
    inline void GetRenderBoundingBox(hkvAlignedBBox &destBBox, const hkvVec3& vOffset) const
    {
        VASSERT(m_spModel->m_LocalBBox.isValid());
        destBBox.setInvalid();

        //destBBox.Inflate(m_spModel->m_LocalBBox,m_Orientation,m_vPosition);
        {
            hkvAlignedBBox temp = m_spModel->m_LocalBBox;
            hkvMat4 mTransform (m_Orientation, m_vPosition);
            temp.transformFromOrigin (mTransform);
            destBBox.expandToInclude (temp);
        }

        destBBox.m_vMin += vOffset;
        destBBox.m_vMax += vOffset;
    }
Exemple #8
0
 void TrfmRotateEulerX::computeTransform(){
     mTransform.setZero();
     double cosq = cos(mDofs[0]->getValue());
     double sinq = sin(mDofs[0]->getValue());
     mTransform(A_X, A_X) = 1.0; 
     mTransform(A_Y, A_Y) = cosq; 
     mTransform(A_Y, A_Z) = -sinq; 
     mTransform(A_Z, A_Y) = sinq; 
     mTransform(A_Z, A_Z) = cosq; 
     mTransform(3, 3) = 1.0; 
 }
Exemple #9
0
//-------------------------------------------------------------------------------
// @ Player::Update()
//-------------------------------------------------------------------------------
// Main update loop
//-------------------------------------------------------------------------------
void
Player::Update( float dt )
{
    // get change in transform for this frame
    IvMatrix44 scale, rotate, xlate, unxform, rexform;
    scale.Identity();
    rotate.Identity();
    float s = 1.0f;
    float r = 0.0f;
    float x = 0.0f, y = 0.0f, z = 0.0f; 
    
    // set up scaling
    if (IvGame::mGame->mEventHandler->IsKeyDown(';'))
    {
        s -= 0.25f*dt;
    }
    if (IvGame::mGame->mEventHandler->IsKeyDown('p'))
    {
        s += 0.25f*dt;
    }
    scale.Scaling(IvVector3(s, s, s));
    
    // set up rotate
    if (IvGame::mGame->mEventHandler->IsKeyDown('o'))
    {
        r -= kPI*0.25f*dt;
    }
    if (IvGame::mGame->mEventHandler->IsKeyDown('u'))
    {
        r += kPI*0.25f*dt;
    }
    rotate.RotationZ( r );
    
    // set up translation
    if (IvGame::mGame->mEventHandler->IsKeyDown('k'))
    {
        x -= 3.0f*dt;
    }
    if (IvGame::mGame->mEventHandler->IsKeyDown('i'))
    {
        x += 3.0f*dt;
    }
    if (IvGame::mGame->mEventHandler->IsKeyDown('l'))
    {
        y -= 3.0f*dt;
    }
    if (IvGame::mGame->mEventHandler->IsKeyDown('j'))
    {
        y += 3.0f*dt;
    }
    xlate.Translation( IvVector3(x, y, z) );
    
    // clear transform
    if (IvGame::mGame->mEventHandler->IsKeyDown(' '))
    {
        mTransform.Identity();
    }

    // append transforms for this frame to current transform
    // note order: 
    // since scale is uniform in this example, we can apply first in transform chain
    // then we apply old transform
    // then translate center to origin, rotate around origin,
    // then retranslate to old position
    // then finally, apply new translation
    IvVector3 originalXlate( mTransform(0,3), mTransform(1,3), mTransform(2,3) );
    unxform.Translation( -originalXlate );
    rexform.Translation( originalXlate );
    mTransform = xlate*rexform*rotate*unxform*mTransform*scale;
    
    // alternatively, we can save some processing by clearing mTransform's translation
    // and adding originalXlate to the new translation.  The result would be
    // mTransform = xlate*rotate*mTransform*scale;
    
}   // End of Player::Update()