コード例 #1
0
ファイル: cube.c プロジェクト: Princever/MiniWorld
void make_player(
    float *data,
    float x, float y, float z, float rx, float ry)
{
    float ao[6][4] = {0};
    float light[6][4] = {
        {0.8, 0.8, 0.8, 0.8},
        {0.8, 0.8, 0.8, 0.8},
        {0.8, 0.8, 0.8, 0.8},
        {0.8, 0.8, 0.8, 0.8},
        {0.8, 0.8, 0.8, 0.8},
        {0.8, 0.8, 0.8, 0.8}
    };
    make_cube_faces(
        data, ao, light,
        1, 1, 1, 1, 1, 1,
        226, 224, 241, 209, 225, 227,
        0, 0, 0, 0.4);
    float ma[16];
    float mb[16];
    mat_identity(ma);
    mat_rotate(mb, 0, 1, 0, rx);
    mat_multiply(ma, mb, ma);
    mat_rotate(mb, cosf(rx), 0, sinf(rx), -ry);
    mat_multiply(ma, mb, ma);
    mat_apply(data, ma, 36, 3, 10);
    mat_translate(mb, x, y, z);
    mat_multiply(ma, mb, ma);
    mat_apply(data, ma, 36, 0, 10);
}
コード例 #2
0
ファイル: util.c プロジェクト: ahito89/Craft
void make_player(
    float *vertex, float *normal, float *texture,
    float x, float y, float z, float rx, float ry)
{
    make_cube_faces(
        vertex, normal, texture,
        1, 1, 1, 1, 1, 1,
        13, 13, 13 + 32, 13, 13, 13 + 16,
        0, 0, 0, 0.4);
    float a[16];
    float b[16];
    float vec[4] = {0};
    vec[3] = 1;
    mat_identity(a);
    mat_rotate(b, 0, 1, 0, rx);
    mat_multiply(a, b, a);
    mat_rotate(b, cosf(rx), 0, sinf(rx), -ry);
    mat_multiply(a, b, a);
    mat_translate(b, x, y, z);
    mat_multiply(a, b, a);
    for (int i = 0; i < 36; i++) {
        // vertex
        float *v = vertex + i * 3;
        vec[0] = *(v++); vec[1] = *(v++); vec[2] = *(v++);
        mat_vec_multiply(vec, a, vec);
        v = vertex + i * 3;
        *(v++) = vec[0]; *(v++) = vec[1]; *(v++) = vec[2];
        // normal
        float *d = normal + i * 3;
        vec[0] = *(d++); vec[1] = *(d++); vec[2] = *(d++);
        mat_vec_multiply(vec, a, vec);
        d = normal + i * 3;
        *(d++) = vec[0]; *(d++) = vec[1]; *(d++) = vec[2];
    }
}
コード例 #3
0
ファイル: cube.cpp プロジェクト: Henningstone/client
void make_rotated_cube(float *data, float ao[6][4], float light[6][4],
                       int left, int right, int top, int bottom, int front, int back,
                       float x, float y, float z, float n, float rx, float ry, float rz,
                       int w, const int blocks[256][6]) {
    int wleft = blocks[w][0];
    int wright = blocks[w][1];
    int wtop = blocks[w][2];
    int wbottom = blocks[w][3];
    int wfront = blocks[w][4];
    int wback = blocks[w][5];
    make_cube_faces(
        data, ao, light,
        left, right, top, bottom, front, back,
        wleft, wright, wtop, wbottom, wfront, wback,
        n);
    float ma[16];
    float mb[16];
    mat_identity(ma);
    /* Create rotation transformation */
    mat_rotate(mb, 0, 1, 0, ry);
    mat_multiply(ma, mb, ma);
    mat_rotate(mb, 1, 0, 0, rx);
    mat_multiply(ma, mb, ma);
    mat_rotate(mb, 0, 0, 1, rz);
    mat_multiply(ma, mb, ma);
    /* Apply to normals */
    mat_apply(data, ma, (left + right + top + bottom + front + back)*6, 3, 10);
    /* Create translation transformation */
    mat_translate(mb, x, y, z);
    /* Merge with rotation transformation */
    mat_multiply(ma, mb, ma);
    /* Apply to vertices */
    mat_apply(data, ma, (left + right + top + bottom + front + back)*6, 0, 10);
}
コード例 #4
0
ファイル: util.c プロジェクト: ahito89/Craft
void make_cube(
    float *vertex, float *normal, float *texture,
    int left, int right, int top, int bottom, int front, int back,
    float x, float y, float z, float n, int w)
{
    int wleft, wright, wtop, wbottom, wfront, wback;
    w--;
    wbottom = w;
    wleft = wright = wfront = wback = w + 16;
    wtop = w + 32;
    make_cube_faces(
        vertex, normal, texture,
        left, right, top, bottom, front, back,
        wleft, wright, wtop, wbottom, wfront, wback,
        x, y, z, n);
}
コード例 #5
0
ファイル: cube.c プロジェクト: Princever/MiniWorld
void make_cube(
    float *data, float ao[6][4], float light[6][4],
    int left, int right, int top, int bottom, int front, int back,
    float x, float y, float z, float n, int w)
{
    int wleft = blocks[w][0];
    int wright = blocks[w][1];
    int wtop = blocks[w][2];
    int wbottom = blocks[w][3];
    int wfront = blocks[w][4];
    int wback = blocks[w][5];
    make_cube_faces(
        data, ao, light,
        left, right, top, bottom, front, back,
        wleft, wright, wtop, wbottom, wfront, wback,
        x, y, z, n);
}
コード例 #6
0
ファイル: cube.c プロジェクト: naxIO/magebattle
void make_cube(
    float *data, float ao[6][4], float light[6][4],
    int left, int right, int top, int bottom, int front, int back,
    float x, float y, float z, float n, int w)
{
    struct item_list *it = get_item_by_id(ABS(w));
    if (it == NULL) {
        it = get_item_by_name("error");
    }
    int wleft = it->tile->left;
    int wright = it->tile->right;
    int wtop = it->tile->top;
    int wbottom = it->tile->bottom;
    int wfront = it->tile->front;
    int wback = it->tile->back;
    make_cube_faces(
        data, ao, light,
        left, right, top, bottom, front, back,
        wleft, wright, wtop, wbottom, wfront, wback,
        x, y, z, n);
}
コード例 #7
0
ファイル: cube.cpp プロジェクト: Henningstone/client
void make_cube(
    float *data, float ao[6][4], float light[6][4],
    int left, int right, int top, int bottom, int front, int back,
    float x, float y, float z, float n, int w, const int blocks[256][6])
{
    int wleft = blocks[w][0];
    int wright = blocks[w][1];
    int wtop = blocks[w][2];
    int wbottom = blocks[w][3];
    int wfront = blocks[w][4];
    int wback = blocks[w][5];
    make_cube_faces(
        data, ao, light,
        left, right, top, bottom, front, back,
        wleft, wright, wtop, wbottom, wfront, wback,
        n);
    float ma[16];
    float mb[16];
    mat_identity(ma);
    mat_translate(mb, x, y, z);
    mat_multiply(ma, mb, ma);
    mat_apply(data, ma, (left + right + top + bottom + front + back)*6, 0, 10);
}