コード例 #1
0
ファイル: object.c プロジェクト: johnh530/electro
static void read_face_vertices(vector_t vv, const char *line)
{
    const char *c = line;
    int dc;
    int vj, vc = vecnum(_vv);
    int uj, uc = vecnum(_uv);
    int nj, nc = vecnum(_nv);
    int i;

    /* Scan down the face string recording index set specifications. */

    while ((dc = read_face_indices(c, &vj, &uj, &nj)))
        if ((i = vecadd(vv)) >= 0)
        {
            struct object_vert *v = (struct object_vert *) vecget(vv, i);

            /* Convert a face index to a vector index. */

            int ui = (uj > 0) ? uj - 1 : uj + uc;
            int ni = (nj > 0) ? nj - 1 : nj + nc;
            int vi = (vj > 0) ? vj - 1 : vj + vc;

            /* Locate the indexed values in the vector caches. */

            struct vec2 *up = (0 <= ui && ui < uc) ? vecget(_uv, ui) : NULL;
            struct vec3 *np = (0 <= ni && ni < nc) ? vecget(_nv, ni) : NULL;
            struct vec3 *vp = (0 <= vi && vi < vc) ? vecget(_vv, vi) : NULL;

            /* Initialize the new vertex, defaulting on bad input. */

            v->u[0] = up ? up->u : 0.0f;
            v->u[1] = up ? up->v : 0.0f;

            v->n[0] = np ? np->x : 0.0f;
            v->n[1] = np ? np->y : 0.0f;
            v->n[2] = np ? np->z : 1.0f;

            v->v[0] = vp ? vp->x : 0.0f;
            v->v[1] = vp ? vp->y : 0.0f;
            v->v[2] = vp ? vp->z : 0.0f;

            /* Note bad indices. */

            if (uj && !up) uerr++;
            if (nj && !np) nerr++;
            if (vj && !vp) verr++;

            c += dc;
        }
}
コード例 #2
0
ファイル: quake3_bsp_map.cpp プロジェクト: Kazade/kazengine
file_load_status quake3_bsp_map::load(istream& stream) {

    if (!stream.good()) {
        m_last_error = "The stream was invalid";
        return FILE_NOT_FOUND;
    }

    if (!load_and_check_header(stream)) {
        m_last_error = "Map contains an invalid header string";
        return FILE_LOAD_FAILED;
    }

    read_lumps(stream);
    read_entities(stream);
    read_vertices(stream);
    read_faces(stream);
    read_face_indices(stream);
    read_textures(stream);
    read_lightmaps(stream);
    read_bsp_nodes(stream);
    read_bsp_leaves(stream);
    read_bsp_leaf_faces(stream);
    read_bsp_leaf_brushes(stream);
    read_models(stream);
    read_planes(stream);
    read_brushes(stream);
    read_brushsides(stream);
    read_effects(stream);
    read_lightvols(stream);
    read_visibility_data(stream);

    do_post_load();

    print_statistics();

    return FILE_LOAD_SUCCESS;
}