~ubuntu-branches/ubuntu/quantal/libcm/quantal

« back to all changes in this revision

Viewing changes to src/drawable-node-deforms.c

  • Committer: Bazaar Package Importer
  • Author(s): Loic Minier, Josselin Mouette, Loic Minier
  • Date: 2008-05-26 14:43:19 UTC
  • mfrom: (3.1.4 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080526144319-ddwovigo7i925ewr
Tags: 0.1.1-4
[ Josselin Mouette ]
* Allow libgl-dev and libglu-dev as alternative dependencies for
  libcm-dev. Closes: #478887.

[ Loic Minier ]
* Don't copy config.guess/.sub after unpatch in clean; should avoid having
  them in the .diff.gz -- not needed as we always update them after patching
  anyway -- and should fix conversion to source format 3.0; closes: #482728.
* Stop shipping *.la files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <math.h>
2
 
#include "drawable-node.h"
3
 
 
4
 
void
5
 
cm_identity_deform (int u, int v,
6
 
                    int x, int y, int width, int height,
7
 
                    int *deformed_x, int *deformed_y,
8
 
                    void *p)
9
 
{
10
 
    *deformed_x = x + u;
11
 
    *deformed_y = y + v;
12
 
}
13
 
 
14
 
void
15
 
cm_user_geometry_deform (int u, int v,
16
 
                         int x, int y, int width, int height,
17
 
                         int *deformed_x, int *deformed_y,
18
 
                         void *p)
19
 
{
20
 
    CmDrawableNode *node = p;
21
 
    
22
 
    *deformed_x = node->user_x + node->user_width * u / width;
23
 
    *deformed_y = node->user_y + node->user_height * v / height;
24
 
}
25
 
 
26
 
void
27
 
cm_wavy_deform (int u, int v,
28
 
                int x, int y, int width, int height,
29
 
                int *deformed_x, int *deformed_y,
30
 
                void *p)
31
 
{
32
 
    *deformed_x = x + u + cos((x * 4 + u + y * 4 + v) / 64.0) * 8;
33
 
    *deformed_y = y + v + sin((x * 4 + u + y * 4 + v) / 64.0) * 8;
34
 
}
35
 
 
36
 
void
37
 
cm_patch_deform (int u_in, int v_in,
38
 
                 int x, int y, int w, int h,
39
 
                 int *deformed_x, int *deformed_y,
40
 
                 void *p)
41
 
{
42
 
    CmDrawableNode *node = p;
43
 
    double coeffs_u[4], coeffs_v[4];
44
 
    double patch_x, patch_y;
45
 
    double u, v;
46
 
    int i, j;
47
 
    
48
 
    u = (double) u_in / w;
49
 
    v = (double) v_in / h;
50
 
    
51
 
    coeffs_u[0] = (1 - u) * (1 - u) * (1 - u);
52
 
    coeffs_u[1] = 3 * u * (1 - u) * (1 - u);
53
 
    coeffs_u[2] = 3 * u * u * (1 - u);
54
 
    coeffs_u[3] = u * u * u;
55
 
    
56
 
    coeffs_v[0] = (1 - v) * (1 - v) * (1 - v);
57
 
    coeffs_v[1] = 3 * v * (1 - v) * (1 - v);
58
 
    coeffs_v[2] = 3 * v * v * (1 - v);
59
 
    coeffs_v[3] = v * v * v;
60
 
    
61
 
    patch_x = 0;
62
 
    patch_y = 0;
63
 
    
64
 
    for (i = 0; i < 4; i++)
65
 
    {
66
 
        for (j = 0; j < 4; j++)
67
 
        {
68
 
            patch_x += coeffs_u[i] * coeffs_v[j] * node->patch_points[j][i].x;
69
 
            patch_y += coeffs_u[i] * coeffs_v[j] * node->patch_points[j][i].y;
70
 
        }
71
 
    }
72
 
    
73
 
    *deformed_x = patch_x + 0.5;
74
 
    *deformed_y = patch_y + 0.5;
75
 
}