コード例 #1
0
ファイル: tr_surface.c プロジェクト: coltongit/ioq3
/*
=============
RB_SurfaceMesh
=============
*/
static void RB_SurfaceMesh(mdvSurface_t *surface) {
	int				j;
	float			backlerp;
	mdvSt_t			*texCoords;
	int				Bob, Doug;
	int				numVerts;

	if (  backEnd.currentEntity->e.oldframe == backEnd.currentEntity->e.frame ) {
		backlerp = 0;
	} else  {
		backlerp = backEnd.currentEntity->e.backlerp;
	}

	RB_CheckVao(tess.vao);

	RB_CHECKOVERFLOW( surface->numVerts, surface->numIndexes );

	LerpMeshVertexes (surface, backlerp);

	Bob = tess.numIndexes;
	Doug = tess.numVertexes;
	for (j = 0 ; j < surface->numIndexes ; j++) {
		tess.indexes[Bob + j] = Doug + surface->indexes[j];
	}
	tess.numIndexes += surface->numIndexes;

	texCoords = surface->st;

	numVerts = surface->numVerts;
	for ( j = 0; j < numVerts; j++ ) {
		tess.texCoords[Doug + j][0] = texCoords[j].st[0];
		tess.texCoords[Doug + j][1] = texCoords[j].st[1];
		// FIXME: fill in lightmapST for completeness?
	}

	tess.numVertexes += surface->numVerts;

}
コード例 #2
0
ファイル: Model_md3.cpp プロジェクト: 4DA/doom3.gpl
/*
=============
idRenderModelMD3::InstantiateDynamicModel
=============
*/
idRenderModel *idRenderModelMD3::InstantiateDynamicModel( const struct renderEntity_s *ent, const struct viewDef_s *view, idRenderModel *cachedModel ) {
    int				i, j;
    float			backlerp;
    int *			triangles;
    float *			texCoords;
    int				indexes;
    int				numVerts;
    md3Surface_t *	surface;
    int				frame, oldframe;
    idRenderModelStatic	*staticModel;

    if ( cachedModel ) {
        delete cachedModel;
        cachedModel = NULL;
    }

    staticModel = new idRenderModelStatic;
    staticModel->bounds.Clear();

    surface = (md3Surface_t *) ((byte *)md3 + md3->ofsSurfaces);

    // TODO: these need set by an entity
    frame = ent->shaderParms[SHADERPARM_MD3_FRAME];			// probably want to keep frames < 1000 or so
    oldframe = ent->shaderParms[SHADERPARM_MD3_LASTFRAME];
    backlerp = ent->shaderParms[SHADERPARM_MD3_BACKLERP];

    for( i = 0; i < md3->numSurfaces; i++ ) {

        srfTriangles_t *tri = R_AllocStaticTriSurf();
        R_AllocStaticTriSurfVerts( tri, surface->numVerts );
        R_AllocStaticTriSurfIndexes( tri, surface->numTriangles * 3 );
        tri->bounds.Clear();

        modelSurface_t	surf;

        surf.geometry = tri;

        md3Shader_t* shaders = (md3Shader_t *) ((byte *)surface + surface->ofsShaders);
        surf.shader = shaders->shader;

        LerpMeshVertexes( tri, surface, backlerp, frame, oldframe );

        triangles = (int *) ((byte *)surface + surface->ofsTriangles);
        indexes = surface->numTriangles * 3;
        for (j = 0 ; j < indexes ; j++) {
            tri->indexes[j] = triangles[j];
        }
        tri->numIndexes += indexes;

        texCoords = (float *) ((byte *)surface + surface->ofsSt);

        numVerts = surface->numVerts;
        for ( j = 0; j < numVerts; j++ ) {
            idDrawVert *stri = &tri->verts[j];
            stri->st[0] = texCoords[j*2+0];
            stri->st[1] = texCoords[j*2+1];
        }

        R_BoundTriSurf( tri );

        staticModel->AddSurface( surf );
        staticModel->bounds.AddPoint( surf.geometry->bounds[0] );
        staticModel->bounds.AddPoint( surf.geometry->bounds[1] );

        // find the next surface
        surface = (md3Surface_t *)( (byte *)surface + surface->ofsEnd );
    }

    return staticModel;
}