Ejemplo n.º 1
0
const Matrix4 getConcatMatrix( IObject iObj, chrono_t curTime , bool interpolate)
{
    Imath::M44d xf;
    xf.makeIdentity();
    IObject parent = iObj.getParent();

    // Once the Archive's Top Object is reached, IObject::getParent() will
    // return an invalid IObject, and that will evaluate to False.
    while ( parent )
    {
        accumXform( xf, parent, curTime, interpolate );
        parent = parent.getParent();
    }

    Matrix4 ret_matrix = convert(xf);

    return ret_matrix;
}
Ejemplo n.º 2
0
Imath::M44d SceneNode::getGlobalTransDouble(double time)
{
   Imath::M44d ret;
   ret.makeIdentity();
   return ret;
}
void
testProcrustesImp ()
{
    // Test the empty case:
    Imath::M44d id = 
        procrustesRotationAndTranslation ((Imath::Vec3<T>*) 0, 
                                          (Imath::Vec3<T>*) 0,
                                          (T*) 0,
                                          0);
    assert (id == Imath::M44d());

    id = procrustesRotationAndTranslation ((Imath::Vec3<T>*) 0, 
                                           (Imath::Vec3<T>*) 0,
                                           0);
    assert (id == Imath::M44d());

    // First we'll test with a bunch of known translation/rotation matrices
    // to make sure we get back exactly the same points:
    Imath::M44d m;
    m.makeIdentity();
    testTranslationRotationMatrix<T> (m);

    m.translate (Imath::V3d(3.0, 5.0, -0.2));
    testTranslationRotationMatrix<T> (m);

    m.rotate (Imath::V3d(M_PI, 0, 0));
    testTranslationRotationMatrix<T> (m);
    
    m.rotate (Imath::V3d(0, M_PI/4.0, 0));
    testTranslationRotationMatrix<T> (m);

    m.rotate (Imath::V3d(0, 0, -3.0/4.0 * M_PI));
    testTranslationRotationMatrix<T> (m);

    m.makeIdentity();
    testWithTranslateRotateAndScale<T> (m);

    m.translate (Imath::V3d(0.4, 6.0, 10.0));
    testWithTranslateRotateAndScale<T> (m);

    m.rotate (Imath::V3d(M_PI, 0, 0));
    testWithTranslateRotateAndScale<T> (m);

    m.rotate (Imath::V3d(0, M_PI/4.0, 0));
    testWithTranslateRotateAndScale<T> (m);

    m.rotate (Imath::V3d(0, 0, -3.0/4.0 * M_PI));
    testWithTranslateRotateAndScale<T> (m);

    m.scale (Imath::V3d(2.0, 2.0, 2.0));
    testWithTranslateRotateAndScale<T> (m);

    m.scale (Imath::V3d(0.01, 0.01, 0.01));
    testWithTranslateRotateAndScale<T> (m);

    // Now we'll test with some random point sets and verify
    // the various Procrustes properties:
    std::vector<Imath::Vec3<T> > fromPoints;
    std::vector<Imath::Vec3<T> > toPoints;
    fromPoints.clear(); toPoints.clear();

    for (size_t i = 0; i < 4; ++i)
    {
        const T theta = T(2*i) / T(M_PI);
        fromPoints.push_back (Imath::Vec3<T>(cos(theta), sin(theta), 0));
        toPoints.push_back (Imath::Vec3<T>(cos(theta + M_PI/3.0), sin(theta + M_PI/3.0), 0));
    }
    verifyProcrustes (fromPoints, toPoints);

    Imath::Rand48 random (1209);
    for (size_t numPoints = 1; numPoints < 10; ++numPoints)
    {
        fromPoints.clear(); toPoints.clear();
        for (size_t i = 0; i < numPoints; ++i)
        {
            fromPoints.push_back (Imath::Vec3<T>(random.nextf(), random.nextf(), random.nextf()));
            toPoints.push_back (Imath::Vec3<T>(random.nextf(), random.nextf(), random.nextf()));
        }
    }
    verifyProcrustes (fromPoints, toPoints);

    // Test with some known matrices of varying degrees of quality:
    testProcrustesWithMatrix<T> (m);

    m.translate (Imath::Vec3<T>(3, 4, 1));
    testProcrustesWithMatrix<T> (m);

    m.translate (Imath::Vec3<T>(-10, 2, 1));
    testProcrustesWithMatrix<T> (m);

    Imath::Eulerd rot (M_PI/3.0, 3.0*M_PI/4.0, 0);
    m = m * rot.toMatrix44();
    testProcrustesWithMatrix<T> (m);

    m.scale (Imath::Vec3<T>(1.5, 6.4, 2.0));
    testProcrustesWithMatrix<T> (m);

    Imath::Eulerd rot2 (1.0, M_PI, M_PI/3.0);
    m = m * rot.toMatrix44();

    m.scale (Imath::Vec3<T>(-1, 1, 1));
    testProcrustesWithMatrix<T> (m);

    m.scale (Imath::Vec3<T>(1, 0.001, 1));
    testProcrustesWithMatrix<T> (m);

    m.scale (Imath::Vec3<T>(1, 1, 0));
    testProcrustesWithMatrix<T> (m);
}