Exemple #1
0
Location MoveSpline::ComputePosition() const
{
    MANGOS_ASSERT(Initialized());

    float u = 1.f;
    int32 seg_time = spline.length(point_Idx,point_Idx+1);
    if (seg_time > 0)
        u = (time_passed - spline.length(point_Idx)) / (float)seg_time;
    Location c;
    spline.evaluate_percent(point_Idx, u, c);

    if (splineflags.falling)
        computeFallElevation(c.z);

    if (splineflags.done && splineflags.isFacing())
    {
        if (splineflags.final_angle)
            c.orientation = facing.angle;
        else if (splineflags.final_point)
            c.orientation = atan2(facing.f.y-c.y, facing.f.x-c.x);
        //nothing to do for MoveSplineFlag::Final_Target flag
    }
    else
    {
        Vector3 hermite;
        spline.evaluate_derivative(point_Idx,u,hermite);
        c.orientation = atan2(hermite.y, hermite.x);
    }
    return c;
}
    Position MoveSpline::ComputePosition() const
    {
        MANGOS_ASSERT(Initialized());

        float u = 1.f;
        int32 seg_time = spline.length(point_Idx, point_Idx + 1);
        if (seg_time > 0)
            u = (time_passed - spline.length(point_Idx)) / (float)seg_time;
        Position c;
        c.orientation = initialOrientation;
        spline.evaluate_percent(point_Idx, u, c);

        if (splineflags.animation)
            ;// MoveSplineFlag::Animation disables falling or parabolic movement
        else if (splineflags.parabolic)
            computeParabolicElevation(c.z);
        else if (splineflags.falling)
            computeFallElevation(c.z);

        if (splineflags.done && splineflags.isFacing())
        {
            if (splineflags.final_angle)
                c.orientation = facing.angle;
            else if (splineflags.final_point)
                c.orientation = atan2(facing.f.y - c.y, facing.f.x - c.x);
            // nothing to do for MoveSplineFlag::Final_Target flag
        }
        else
        {
            if (!splineflags.hasFlag(MoveSplineFlag::OrientationFixed | MoveSplineFlag::Falling))
            {
                Vector3 hermite;
                spline.evaluate_derivative(point_Idx, u, hermite);
                c.orientation = atan2(hermite.y, hermite.x);
            }

            if (splineflags.orientationInversed)
                c.orientation = -c.orientation;
        }

        c.orientation = G3D::wrap(c.orientation, 0.0f, float(G3D::twoPi()));
        return c;
    }
Exemple #3
0
Location MoveSpline::ComputePosition() const
{
    ASSERT(Initialized());

    float u = 1.f;
    int32 seg_time = spline.length(point_Idx, point_Idx+1);
    if (seg_time > 0)
        u = (time_passed - spline.length(point_Idx)) / (float)seg_time;
    Location c;
    c.orientation = initialOrientation;
    spline.evaluate_percent(point_Idx, u, c);

    if (splineflags.animation)
        ;// MoveSplineFlag::Animation disables falling or parabolic movement
    else if (splineflags.parabolic)
        computeParabolicElevation(c.z);
    else if (splineflags.falling)
        computeFallElevation(c.z);

    if (splineflags.done && facing.type != MONSTER_MOVE_NORMAL)
    {
        if (facing.type == MONSTER_MOVE_FACING_ANGLE)
            c.orientation = facing.angle;
        else if (facing.type == MONSTER_MOVE_FACING_SPOT)
            c.orientation = std::atan2(facing.f.y - c.y, facing.f.x - c.x);
        //nothing to do for MoveSplineFlag::Final_Target flag
    }
    else
    {
        if (!splineflags.hasFlag(MoveSplineFlag::OrientationFixed | MoveSplineFlag::Falling | MoveSplineFlag::Unknown0))
        {
            Vector3 hermite;
            spline.evaluate_derivative(point_Idx, u, hermite);
            c.orientation = std::atan2(hermite.y, hermite.x);
        }

        if (splineflags.orientationInversed)
            c.orientation = -c.orientation;
    }
    return c;
}