コード例 #1
0
ファイル: mesh.c プロジェクト: stetre/moonassimp
int freemesh(lua_State *L, mesh_t *mesh)
    {
    unsigned int i;
    if(mesh->mFaces != NULL && mesh->mNumFaces > 0)
        {
        for(i = 0; i < mesh->mNumFaces; i++)
            freeface(L, &(mesh->mFaces[i]));
        TRACE_DELETE_N(i, "faces");
        }
    if(mesh->mBones != NULL && mesh->mNumBones > 0)
        {
        for(i = 0; i < mesh->mNumBones; i++)
            freebone(L, mesh->mBones[i]);
        TRACE_DELETE_N(i, "bones");
        }
    if(mesh->mAnimMeshes != NULL && mesh->mNumAnimMeshes > 0)
        {
        for(i = 0; i < mesh->mNumAnimMeshes; i++)
            freeanimmesh(L, mesh->mAnimMeshes[i]);
        TRACE_DELETE_N(i, "animmeshes");
        }
    TRACE_DELETE(mesh, "mesh");
    freeuserdata(L, mesh);
    return 0;
    }
コード例 #2
0
ファイル: main.c プロジェクト: 00001/plan9port
void
delface(int j)
{
	Rectangle r0, r1, r;
	int nx, ny, x, y;

	if(j < first)
		first--;
	else if(j < last){
		nx = nacross;
		ny = (nfaces+(nx-1)) / nx;
		x = (j-first)%nx;
		for(y=(j-first)/nx; y<ny; y++){
			if(x != nx-1){
				/* move them along */
				r0 = facerect(y*nx+x);
				r1 = facerect(y*nx+x+1);
				r = r0;
				r.max.x = r.min.x + (nx - x - 1)*(Facesize+Facesep);
				draw(screen, r, screen, nil, r1.min);
			}
			if(y != ny-1){
				/* copy one up from row below */
				r = facerect((y+1)*nx);
				draw(screen, facerect(y*nx+nx-1), screen, nil, r.min);
			}
			x = 0;
		}
		if(last < nfaces)	/* first off-screen becomes visible */
			drawface(faces[last], last-1);
		else{
			/* clear final spot */
			r = facerect(last-first-1);
			draw(screen, r, bgrnd, nil, r.min);
		}
	}
	freeface(faces[j]);
	memmove(faces+j, faces+j+1, (nfaces-(j+1))*sizeof(Face*));
	nfaces--;
	setlast();
	drawarrows();
}
コード例 #3
0
void
flush_cache(void)			/* put out cached faces */
{
	int	VFSEPPOS = strchr(vlist[0],'\n') - vlist[0];
	int	donorms = 0;
	register struct face	*f;
	register int	i;

	if (nverts == 0)
		return;
					/* put out coordinates */
	printf("%sCoordinate3 {\n", tabs);
	indent(1);
	vlist[0][VFSEPPOS] = '\0';
	printf("%spoint [ %s", tabs, vlist[0]);
	for (i = 1; i < nverts; i++) {
		vlist[i][VFSEPPOS] = '\0';
		printf(",\n%s        %s", tabs, vlist[i]);
		if (strcmp(VFSEPPOS+1+vlist[i], VZVECT))
			donorms++;
	}
	indent(0);
	printf(" ]\n%s}\n", tabs);
	if (donorms) {			/* put out normals */
		printf("%sNormal {\n", tabs);
		indent(1);
		printf("%svector [ %s", tabs, VFSEPPOS+1+vlist[0]);
		for (i = 1; i < nverts; i++)
			printf(",\n%s         %s", tabs, VFSEPPOS+1+vlist[i]);
		indent(0);
		printf(" ]\n%s}\n", tabs);
	}
					/* put out faces */
	printf("%sIndexedFaceSet {\n", tabs);
	indent(1);
	f = flist;			/* coordinate indices */
	printf("%scoordIndex [ %d", tabs, f->vl[0]);
	for (i = 1; i < f->nv; i++)
		printf(", %d", f->vl[i]);
	for (f = f->next; f != NULL; f = f->next) {
		printf(", -1,\n%s             %d", tabs, f->vl[0]);
		for (i = 1; i < f->nv; i++)
			printf(", %d", f->vl[i]);
	}
	printf(" ]\n");
	if (donorms) {
		f = flist;			/* normal indices */
		printf("%snormalIndex [ %d", tabs, f->vl[0]);
		for (i = 1; i < f->nv; i++)
			printf(", %d", f->vl[i]);
		for (f = f->next; f != NULL; f = f->next) {
			printf(", -1,\n%s              %d", tabs, f->vl[0]);
			for (i = 1; i < f->nv; i++)
				printf(", %d", f->vl[i]);
		}
		printf(" ]\n");
	}
	indent(0);			/* close IndexedFaceSet */
	printf("%s}\n", tabs);
	indent(0);			/* close face group */
	printf("%s}\n", tabs);
	while ((f = flist) != NULL) {	/* free face list */
		flist = f->next;
		freeface(f);
	}
	lu_done(&vert_tab);		/* clear lookup table */
	nverts = 0;
}