Exemplo n.º 1
0
AE_INTERNAL ae_void_t __instance_setup_bezier_warp( aeMovieInstance * _instance )
{
    ae_uint32_t quality = 0;
    for( ; quality != AE_MOVIE_BEZIER_MAX_QUALITY; ++quality )
    {
        ae_uint32_t line_count = get_bezier_warp_line_count( quality );
        ae_uint32_t vertex_count = get_bezier_warp_vertex_count( quality );

        ae_vector2_t * bezier_warp_uvs = AE_NEWN( _instance, ae_vector2_t, vertex_count );

        ae_vector2_t * bezier_warp_uvs_iterator = bezier_warp_uvs;

        ae_float_t grid_invf = 1.f / (ae_float_t)(line_count - 1);

        ae_uint32_t v = 0;
        for( ; v != line_count; ++v )
        {
            ae_uint32_t u = 0;
            for( ; u != line_count; ++u )
            {
                ae_vector2_t * uv = bezier_warp_uvs_iterator++;
                (*uv)[0] = (ae_float_t)u * grid_invf;
                (*uv)[1] = (ae_float_t)v * grid_invf;
            }
        }

        _instance->bezier_warp_uvs[quality] = (const ae_vector2_t *)bezier_warp_uvs;

        ae_uint32_t index_count = (line_count - 1) * (line_count - 1) * 6;
        ae_uint16_t * bezier_warp_indices = AE_NEWN( _instance, ae_uint16_t, index_count );

        ae_uint16_t * bezier_warp_indices_iterator = bezier_warp_indices;

        ae_uint16_t uv_count = (ae_uint16_t)line_count;
        ae_uint16_t uv_count_one = uv_count - 1;

        ae_uint16_t v2 = 0;
        for( ; v2 != uv_count_one; ++v2 )
        {
            ae_uint16_t u2 = 0;
            for( ; u2 != uv_count_one; ++u2 )
            {
                *bezier_warp_indices_iterator++ = u2 + (v2 + 0U) * uv_count + 0U;
                *bezier_warp_indices_iterator++ = u2 + (v2 + 1U) * uv_count + 0U;
                *bezier_warp_indices_iterator++ = u2 + (v2 + 0U) * uv_count + 1U;
                *bezier_warp_indices_iterator++ = u2 + (v2 + 0U) * uv_count + 1U;
                *bezier_warp_indices_iterator++ = u2 + (v2 + 1U) * uv_count + 0U;
                *bezier_warp_indices_iterator++ = u2 + (v2 + 1U) * uv_count + 1U;
            }
        }

        _instance->bezier_warp_indices[quality] = (const ae_uint16_t *)bezier_warp_indices;
    }
}
Exemplo n.º 2
0
ae_result_t ae_magic_read_mesh( aeMovieStream * _stream, ae_mesh_t * _mesh )
{
    ae_uint32_t vertex_count = AE_READZ( _stream );

    if( vertex_count == 0 || vertex_count > AE_MOVIE_MAX_VERTICES )
    {
        _mesh->vertex_count = 0;
        _mesh->index_count = 0;

        _mesh->positions = AE_NULL;
        _mesh->uvs = AE_NULL;
        _mesh->indices = AE_NULL;

        return AE_RESULT_SUCCESSFUL;
    }

    ae_uint32_t indices_count = AE_READZ( _stream );

    _mesh->vertex_count = vertex_count;
    _mesh->index_count = indices_count;

    ae_vector2_t * positions = AE_NEWN( _stream->instance, ae_vector2_t, vertex_count );

    AE_RESULT_PANIC_MEMORY( positions );

    AE_READN( _stream, positions, vertex_count );
    _mesh->positions = (const ae_vector2_t *)positions;

    ae_vector2_t * uvs = AE_NEWN( _stream->instance, ae_vector2_t, vertex_count );

    AE_RESULT_PANIC_MEMORY( uvs );

    AE_READN( _stream, uvs, vertex_count );
    _mesh->uvs = (const ae_vector2_t *)uvs;

    ae_uint16_t * indices = AE_NEWN( _stream->instance, ae_uint16_t, indices_count );

    AE_RESULT_PANIC_MEMORY( indices );

    AE_READN( _stream, indices, indices_count );
    _mesh->indices = indices;

    return AE_RESULT_SUCCESSFUL;
}
Exemplo n.º 3
0
ae_result_t ae_magic_read_string( aeMovieStream * _stream, ae_string_t * _str )
{
    ae_uint32_t size = AE_READZ( _stream );

    ae_string_t buffer = AE_NEWN( _stream->instance, ae_char_t, size + 1U );

    AE_RESULT_PANIC_MEMORY( buffer );

    AE_READN( _stream, buffer, size );

    buffer[size] = '\0';

    *_str = buffer;

    return AE_RESULT_SUCCESSFUL;
}
Exemplo n.º 4
0
ae_result_t ae_magic_read_polygon( aeMovieStream * _stream, ae_polygon_t * _polygon )
{
    ae_uint32_t point_count = AE_READZ( _stream );

    _polygon->point_count = point_count;

    if( point_count == 0 )
    {
        _polygon->points = AE_NULL;

        return AE_RESULT_SUCCESSFUL;
    }

    ae_vector2_t * points = AE_NEWN( _stream->instance, ae_vector2_t, point_count );

    AE_RESULT_PANIC_MEMORY( points );

    AE_READN( _stream, points, point_count );

    _polygon->points = (const ae_vector2_t *)points;

    return AE_RESULT_SUCCESSFUL;
}