예제 #1
0
Matrix3 plMaxNodeBase::GetWorldToParent(TimeValue t)
{
    // This may look back-ass-ward, but that's only because it
    // is. If we've got inheritance filtering on, then our localtoworld
    // is no longer parentl2w * l2p, because we'll be ignoring
    // some of our parent's transform. More precisely, we'll be
    // clobbering parts of the product of our parent's current transform
    // and our current local to parent. So we're going to calculate
    // a parent to world transform here that would get us to the
    // right point and orientation in space, even though it has
    // little or nothing to do with our parent's real transform.
    // Note that we only go through this charade if we've got
    // filtering of inheritance active for this node.
    plMaxNodeBase* parent = (plMaxNodeBase*)GetParentNode();
    if( !GetFilterInherit() )
        return parent->GetWorldToLocal(t);

    // l2w = l2p * parentL2W
    // l2w * parentW2L = l2p
    // parentW2L = w2l * l2p
    Point3 pos;
    float rot[4];
    ScaleValue scl;
    Interval posInv;
    Interval rotInv;
    Interval sclInv;

    Matrix3Indirect parentMatrix(parent->GetNodeTM(t));

    TMComponentsArg cmpts(&pos, &posInv, rot, &rotInv, &scl, &sclInv);
    GetTMController()->GetLocalTMComponents(t, cmpts, parentMatrix);

    Quat q;
    if( cmpts.rotRep == TMComponentsArg::RotationRep::kQuat )
        q = Quat(rot);
    else
        EulerToQuat(rot, q, cmpts.rotRep);

    Matrix3 l2p(true);
    l2p.PreTranslate(pos);
    PreRotateMatrix(l2p, q);
    l2p.PreScale(scl.s);
    PreRotateMatrix(l2p, scl.q);

    Matrix3 w2l = GetWorldToLocal(t);

    return w2l * l2p;
}
예제 #2
0
void plAnimPath::MakeDrawList(hsTArray<uint16_t>& idx, hsTArray<hsPoint3>& pos)
{
    hsMatrix44 resetL2W = GetLocalToWorld();
    hsMatrix44 resetW2L = GetWorldToLocal();

    hsMatrix44 ident;
    ident.Reset();
    SetTransform(ident, ident);

    float numSegs = fRadius; // crude estimate of arclength
    if (numSegs>100)
        numSegs=100;
    float animLen = GetLength();
    float timeInc = animLen/numSegs;
    float time=0;
    hsPoint3 p1, p2;

    SetCurTime(0, kCalcPosOnly);
    GetPosition(&p1);

    time += timeInc;
    bool quit=false;
    while(! quit && time < animLen+timeInc)
    {
        if (time > animLen)
        {
            time = animLen;
            quit=true;
        }

        SetCurTime(time, kCalcPosOnly);
        GetPosition(&p2);

        IMakeSegment(idx, pos, p1, p2);

        time += timeInc;

        p1 = p2;
    }

    SetTransform(resetL2W, resetW2L);
}
예제 #3
0
hsMatrix44 plMaxNodeBase::GetWorldToLocal44(TimeValue t)
{
    Matrix3 m3 = GetWorldToLocal(t);
    hsMatrix44 m44 = Matrix3ToMatrix44(m3);
    return m44;
}