Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-09-15 09:57:48 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-09-15 09:57:48 +0400
commit7eb74100023c6d4423b3f678d82f978e7ce43def (patch)
tree0996edd46f5bd2edea5da4c8d430bd803db7f06d
parente2a0b302ffc7e70fc99b58eafb247adc95863128 (diff)
remove inventor and vrml1 support, we're better of having these legacy formats as addons.
-rw-r--r--source/blender/blenkernel/BKE_exotic.h4
-rw-r--r--source/blender/blenkernel/intern/exotic.c1683
2 files changed, 1 insertions, 1686 deletions
diff --git a/source/blender/blenkernel/BKE_exotic.h b/source/blender/blenkernel/BKE_exotic.h
index bd5af66c6a8..740a94b6169 100644
--- a/source/blender/blenkernel/BKE_exotic.h
+++ b/source/blender/blenkernel/BKE_exotic.h
@@ -34,9 +34,6 @@
struct Mesh;
struct Scene;
-void mcol_to_rgba(unsigned int col, float *r, float *g, float *b, float *a);
-unsigned int *mcol_to_vcol(struct Mesh *me); // used in py_main.c
-
/**
* Reads all 3D fileformats other than Blender fileformat
* @retval 0 The file could not be read.
@@ -46,7 +43,6 @@ unsigned int *mcol_to_vcol(struct Mesh *me); // used in py_main.c
int BKE_read_exotic(struct Scene *scene, char *name);
void write_dxf(struct Scene *scene, char *str);
-void write_vrml(struct Scene *scene, char *str);
void write_stl(struct Scene *scene, char *str);
#endif
diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c
index cdefbb54ecf..bd001649bf5 100644
--- a/source/blender/blenkernel/intern/exotic.c
+++ b/source/blender/blenkernel/intern/exotic.c
@@ -449,1328 +449,10 @@ static void read_stl_mesh_ascii(Scene *scene, char *str)
#undef STLREADLINE
#undef STLREADVERT
-/* ***************** INVENTOR ******************* */
-
-
-#define IV_MAXSTACK 3000000
-#define IV_MAXFIELD 10
-#define IV_MAXCOL 16
-
-static float *iv_data_stack;
-static float ivcolors[IV_MAXCOL][3];
-static Object *ivsurf;
-static ListBase ivbase;
-
-struct IvNode {
- struct IvNode *next, *prev;
- char *nodename;
- char *fieldname[IV_MAXFIELD];
- int datalen[IV_MAXFIELD];
- float *data[IV_MAXFIELD];
-};
-
-static int iv_curcol=0;
-
-static int iv_colornumber(struct IvNode *iv)
-{
- float *fp, fr = 0.0, fg = 0.0, fb = 0.0;
- int a;
- char *cp;
-
- /* search back to last material */
- while(iv) {
- if( strcmp(iv->nodename, "Material")==0) {
- fp= iv->data[0];
- if(fp==0) fp= iv->data[1];
- if(fp) {
- fr= fp[0];
- fg= fp[1];
- fb= fp[2];
- }
- break;
- }
- else if( strcmp(iv->nodename, "BaseColor")==0) {
- fp= iv->data[0];
- fr= fp[0];
- fg= fp[1];
- fb= fp[2];
- break;
- }
- else if( strcmp(iv->nodename, "PackedColor")==0) {
- cp= (char *)iv->data[0];
- fr= cp[3]/255.0f;
- fg= cp[2]/255.0f;
- fb= cp[1]/255.0f;
- break;
- }
- iv= iv->prev;
-
- }
- if(iv==0) return 0;
- if(iv->datalen[0]<3) return 0;
-
- for(a=0; a<iv_curcol; a++) {
-
- if(ivcolors[a][0]== fr)
- if(ivcolors[a][1]== fg)
- if(ivcolors[a][2]== fb) return a+1
- ;
- }
-
- if(a>=IV_MAXCOL) a= IV_MAXCOL-1;
- iv_curcol= a+1;
- ivcolors[a][0]= fr;
- ivcolors[a][1]= fg;
- ivcolors[a][2]= fb;
-
- return iv_curcol;
-}
-
-static int iv_finddata(struct IvNode *iv, char *field, int fieldnr)
-{
- /* search for "field", count data size and make datablock. return skipdata */
- float *fp;
- int len, stackcount, skipdata=0;
- char *cpa, terminator, str[64];
- intptr_t i;
-
- len= strlen(field);
-
- cpa= iv->nodename+1;
- while( *cpa != '}' ) {
-
- if( *cpa == *field ) {
- if( strncmp(cpa, field, len)==0 ) {
- iv->fieldname[fieldnr]= cpa;
-
- /* read until first character */
- cpa+= len;
- skipdata+= len;
- *cpa= 0;
- cpa++;
- skipdata++;
-
- while( *cpa==32 || *cpa==13 || *cpa==10 || *cpa==9) cpa++;
- if( *cpa=='[' ) {
- terminator= ']';
- cpa++;
- skipdata++;
- }
- else terminator= 13;
-
- stackcount= 0;
- fp= iv_data_stack;
-
- while( *cpa!=terminator && *cpa != '}' ) {
-
- /* in fact, isdigit should include the dot and minus */
- if( (isdigit(*cpa) || *cpa=='.' || *cpa=='-') && (isspace(cpa[-1]) || cpa[-1]==0 || cpa[-1]==',') ) {
- if(cpa[1]=='x') {
- memcpy(str, cpa, 16);
- str[16]= 0;
-
- sscanf(str, "%x", (int *)fp);
- }
- else {
- /* atof doesn't stop after the first float
- * in a long string at Windows... so we copy
- * the float to a new string then atof... */
- char *cpa_temp = strpbrk(cpa, ", \n");
- i = cpa_temp - cpa;
-
- if (i>63) *fp= 0.0;
- else {
- memcpy(str, cpa, i);
- str[i]=0;
-
- *fp= (float) atof(str);
- }
- }
-
- stackcount++;
- if(stackcount>=IV_MAXSTACK) {
- printf("stackoverflow in IV read\n");
- break;
- }
- fp++;
- }
- cpa++;
- skipdata++;
- }
-
- iv->datalen[fieldnr]= stackcount;
- if(stackcount) {
- iv->data[fieldnr]= MEM_mallocN(sizeof(float)*stackcount, "iv_finddata");
- memcpy(iv->data[fieldnr], iv_data_stack, sizeof(float)*stackcount);
- }
- else iv->data[fieldnr]= 0;
-
- return skipdata;
- }
- }
- cpa++;
- skipdata++;
- }
-
- return skipdata;
-}
-
-static void read_iv_index(float *data, float *baseadr, float *index, int nr, int coordtype)
-{
- /* write in data: baseadr with offset index (and number nr) */
- float *fp;
- int ofs;
-
- while(nr--) {
- ofs= (int) *index;
- fp= baseadr+coordtype*ofs;
- VECCOPY(data, fp);
- data+= 3;
- index++;
- }
-}
-
-
-
-static void read_inventor(Scene *scene, char *str, struct ListBase *listb)
-{
- struct IvNode *iv, *ivp, *ivn;
- char *maindata, *md, *cpa;
- float *index, *data, *fp;
- int file, filelen, count, lll, face, nr = 0;
- int skipdata, ok, a, b, tot, first, colnr, coordtype, polytype, *idata;
- struct DispList *dl;
- ReportList *reports= NULL; /* XXX */
-
- ivbase.first= ivbase.last= 0;
- iv_curcol= 0;
- ivsurf= 0;
-
- file= open(str, O_BINARY|O_RDONLY);
- if(file== -1) {
- BKE_reportf(reports, RPT_ERROR, "Can't read file: %s.", strerror(errno));
- return;
- }
-
- filelen= BLI_filesize(file);
- if(filelen < 1) {
- close(file);
- return;
- }
-
- maindata= MEM_mallocN(filelen, "leesInventor");
- if(read(file, maindata, filelen) < filelen) {
- BKE_reportf(reports, RPT_ERROR, "Failed reading file: premature end of file.");
- close(file);
- return;
- }
- close(file);
-
- iv_data_stack= MEM_mallocN(sizeof(float)*IV_MAXSTACK, "ivstack");
-
- /* preprocess: remove comments */
- md= maindata+20;
- count= 20;
- while(count<filelen) {
- if( *md=='#' ) { /* comment */
- while( *md!=13 && *md!=10) { /* enters */
- *md= 32;
- md++;
- count++;
- if(count>=filelen) break;
- }
- }
- md++;
- count++;
- }
-
-
- /* now time to collect: which are the nodes and fields? */
- md= maindata;
- count= 0;
- while(count<filelen) {
- if( *md=='{' ) { /* read back */
-
- cpa= md-1;
- while( *cpa==32 || *cpa==13 || *cpa==10 || *cpa==9) { /* remove spaces/enters/tab */
- *cpa= 0;
- cpa--;
- }
-
- while( *cpa>32 && *cpa<128) cpa--;
- cpa++;
- *md= 0;
-
- ok= 0;
- skipdata= 0;
- iv= MEM_callocN(sizeof(struct IvNode), "leesInventor");
- iv->nodename= cpa;
-
- if(strcmp(cpa, "Coordinate3")==0 || strcmp(cpa, "Coordinate4")==0) {
- skipdata= iv_finddata(iv, "point", 0);
- ok= 1;
- }
- else if(strcmp(cpa, "VertexProperty")==0) {
- skipdata= iv_finddata(iv, "vertex", 0);
- ok= 1;
- }
- else if(strcmp(cpa, "IndexedLineSet")==0) {
- skipdata= iv_finddata(iv, "coordIndex", 0);
- ok= 1;
- }
- else if(strcmp(cpa, "IndexedTriangleMesh")==0) {
- skipdata= iv_finddata(iv, "coordIndex", 0);
- ok= 1;
- }
- else if(strcmp(cpa, "IndexedFaceSet")==0) {
- skipdata= iv_finddata(iv, "coordIndex", 0);
- ok= 1;
- }
- else if(strcmp(cpa, "FaceSet")==0) {
- skipdata= iv_finddata(iv, "numVertices", 0);
- ok= 1;
- }
- else if(strcmp(cpa, "Material")==0) {
- iv_finddata(iv, "diffuseColor", 0);
- iv_finddata(iv, "ambientColor", 1);
- ok= 1;
- }
- else if(strcmp(cpa, "BaseColor")==0) {
- iv_finddata(iv, "rgb", 0);
- ok= 1;
- }
- else if(strcmp(cpa, "PackedColor")==0) {
- iv_finddata(iv, "rgba", 0);
- ok= 1;
- }
- else if(strcmp(cpa, "QuadMesh")==0) {
- iv_finddata(iv, "verticesPerColumn", 0);
- iv_finddata(iv, "verticesPerRow", 1);
-
- ok= 1;
- }
- else if(strcmp(cpa, "IndexedTriangleStripSet")==0) {
- skipdata= iv_finddata(iv, "coordIndex", 0);
- ok= 1;
- }
- else if(strcmp(cpa, "TriangleStripSet")==0) {
- skipdata= iv_finddata(iv, "numVertices", 0);
- ok= 1;
- }
- else if(strcmp(cpa, "IndexedNurbsSurface")==0 || strcmp(cpa, "NurbsSurface")==0) {
- iv_finddata(iv, "numUControlPoints", 0);
- iv_finddata(iv, "numVControlPoints", 1);
- iv_finddata(iv, "uKnotVector", 2);
- iv_finddata(iv, "vKnotVector", 3);
- ok= 1;
- }
- else {
- /* to the end */
- while( *md != '}') {
- md++;
- count++;
- if(count<filelen) break;
- }
- }
-
-
- if(ok) {
- BLI_addtail(&ivbase, iv);
- md+= skipdata;
- count+= skipdata;
- }
- else MEM_freeN(iv);
-
- }
- md++;
- count++;
- }
-
- /* join nodes */
- iv= ivbase.first;
-
- while(iv) {
- ivn= iv->next;
-
- if( strncmp(iv->nodename, "Indexed", 7)==0) {
- /* seek back: same name? */
-
- ivp= iv->prev;
- while(ivp) {
- if(strcmp(iv->nodename, ivp->nodename)==0) break;
-
- if(strcmp(ivp->nodename, "Coordinate3")==0 ||
- strcmp(ivp->nodename, "Coordinate4")==0 ||
- strcmp(ivp->nodename, "VertexProperty")==0) {
- ivp= 0;
- break;
- }
- ivp= ivp->prev;
- }
-
- if(ivp) {
- /* add iv to ivp */
-
- tot= iv->datalen[0] + ivp->datalen[0];
- if(tot) {
- data= MEM_mallocN(tot*sizeof(float), "samenvoeg iv");
- memcpy(data, ivp->data[0], sizeof(float)*ivp->datalen[0]);
- memcpy(data+ivp->datalen[0], iv->data[0], sizeof(float)*iv->datalen[0]);
-
- ivp->datalen[0]+= iv->datalen[0];
- MEM_freeN(ivp->data[0]);
- ivp->data[0]= data;
-
- BLI_remlink(&ivbase, iv);
- MEM_freeN(iv->data[0]);
- MEM_freeN(iv);
- }
- }
- }
-
- iv= ivn;
- }
-
-
- /* convert Nodes to DispLists */
- iv= ivbase.first;
- while(iv) {
-
- /* printf(" Node: %s\n", iv->nodename); */
- /* if(iv->fieldname[0]) printf(" Field: %s len %d\n", iv->fieldname[0], iv->datalen[0]); */
- coordtype= 3;
-
- if( strcmp(iv->nodename, "IndexedLineSet")==0 ) {
-
- colnr= iv_colornumber(iv);
-
- /* seek back to data */
- ivp= iv;
- while(ivp->prev) {
- ivp= ivp->prev;
- if( strcmp(ivp->nodename, "Coordinate3")==0 ) {
- coordtype= 3;
- break;
- }
- if( strcmp(ivp->nodename, "Coordinate4")==0 ) {
- coordtype= 4;
- break;
- }
- }
- if(ivp) {
-
- /* count the nr of lines */
- tot= 0;
- index= iv->data[0];
- lll = iv->datalen[0]-1;
- for(a=0; a<lll; a++) {
- if(index[0]!= -1 && index[1]!= -1) tot++;
- index++;
- }
-
- tot*= 2; /* nr of vertices */
- dl= MEM_callocN(sizeof(struct DispList)+tot*3*sizeof(float), "leesInventor1");
- BLI_addtail(listb, dl);
- dl->type= DL_SEGM;
- dl->nr= 2;
- dl->parts= tot/2;
- dl->col= colnr;
- data= (float *)(dl+1);
-
- index= iv->data[0];
- for(a=0; a<lll; a++) {
- if(index[0]!= -1 && index[1]!= -1) {
- read_iv_index(data, ivp->data[0], index, 2, coordtype);
- data+= 6;
- }
- index++;
- }
- }
- }
- else if( strcmp(iv->nodename, "FaceSet")==0 ) {
-
- colnr= iv_colornumber(iv);
-
- /* seek back to data */
- ivp= iv;
- while(ivp->prev) {
- ivp= ivp->prev;
- if( strcmp(ivp->nodename, "Coordinate3")==0 ) {
- coordtype= 3;
- break;
- }
- if( strcmp(ivp->nodename, "Coordinate4")==0 ) {
- coordtype= 4;
- break;
- }
- }
-
- if(ivp) {
- /* count triangles */
- tot= 0;
-
- index= iv->data[0];
- polytype= (int) index[0];
-
- for(a=0; a<iv->datalen[0]; a++) {
- if(index[0]== polytype) tot++; /* one kind? */
- index++;
- }
-
-
- tot*= polytype; /* nr of vertices */
- dl= MEM_callocN(sizeof(struct DispList)+tot*3*sizeof(float), "leesInventor4");
- BLI_addtail(listb, dl);
- dl->type= DL_POLY;
- dl->nr= polytype;
- dl->parts= tot/polytype;
- dl->col= colnr;
- data= (float *)(dl+1);
-
- index= ivp->data[0];
- first= 1;
- for(a=0; a<iv->datalen[0]; a++) {
-
- VECCOPY(data, index);
- data+= 3;
- index+= 3;
-
- VECCOPY(data, index);
- data+= 3;
- index+= 3;
-
- VECCOPY(data, index);
- data+= 3;
- index+= 3;
-
- if(polytype==4) {
- VECCOPY(data, index);
- data+= 3;
- index+= 3;
- }
- }
- }
- }
- else if( strcmp(iv->nodename, "TriangleStripSet")==0 ) {
-
- colnr= iv_colornumber(iv);
-
- /* seek back to data */
- ivp= iv;
- while(ivp->prev) {
- ivp= ivp->prev;
- if( strcmp(ivp->nodename, "Coordinate3")==0 ) {
- coordtype= 3;
- break;
- }
- if( strcmp(ivp->nodename, "Coordinate4")==0 ) {
- coordtype= 4;
- break;
- }
- }
-
- if(ivp) {
- /* count triangles */
- tot= 0;
- face= 0;
-
- index= iv->data[0]; /* strip size */
-
- for(a=0; a<iv->datalen[0]; a++) {
- tot+= (int) index[0];
- face+= ((int) index[0]) - 2;
- index++;
- }
-
- dl= MEM_callocN(sizeof(struct DispList), "leesInventor4");
- dl->verts= MEM_callocN( tot*3*sizeof(float), "dl verts");
- dl->index= MEM_callocN( face*3*sizeof(int), "dl index");
-
- dl->type= DL_INDEX3;
- dl->nr= tot;
- dl->parts= face;
-
- BLI_addtail(listb, dl);
- dl->col= colnr;
-
- index= iv->data[0]; /* strip size */
- fp= ivp->data[0]; /* vertices */
- data= dl->verts;
- idata= dl->index;
- first= 0;
-
- for(a=0; a<iv->datalen[0]; a++) {
-
- /* vertices */
- for(b=0; b<index[0]; b++) {
- VECCOPY(data, fp);
- data+= 3;
- fp+= coordtype;
- }
-
- /* indices */
- lll = index[0] - 2;
- for(b=0; b<lll; b++) {
- idata[0]= first;
- idata[1]= first+1;
- idata[2]= first+2;
- first++;
- idata+= 3;
- }
- first+= 2;
-
- index++;
- }
- }
- }
- else if( strcmp(iv->nodename, "IndexedFaceSet")==0 ) {
-
- colnr= iv_colornumber(iv);
-
- /* seek back to data */
- ivp= iv;
- while(ivp->prev) {
- ivp= ivp->prev;
- if( strcmp(ivp->nodename, "Coordinate3")==0 ) {
- coordtype= 3;
- break;
- }
- if( strcmp(ivp->nodename, "Coordinate4")==0 ) {
- coordtype= 4;
- break;
- }
- }
- if(ivp) {
-
- /* count triangles */
- face= 0;
- index= iv->data[0];
- lll = iv->datalen[0]-2;
- for(a=0; a<lll; a++) {
- if(index[0]!= -1 && index[1]!= -1 && index[2]!= -1) face++;
- index++;
- }
-
- /*number of vertices */
- tot= ivp->datalen[0]/coordtype;
-
- if(tot) {
- dl= MEM_callocN(sizeof(struct DispList), "leesInventor5");
- BLI_addtail(listb, dl);
- dl->type= DL_INDEX3;
- dl->nr= tot;
- dl->parts= face;
- dl->col= colnr;
-
- dl->verts= MEM_callocN( tot*3*sizeof(float), "dl verts");
- dl->index= MEM_callocN(sizeof(int)*3*face, "dl index");
-
- /* vertices */
- fp= ivp->data[0];
- data= dl->verts;
- for(b=tot; b>0; b--) {
- VECCOPY(data, fp);
- data+= 3;
- fp+= coordtype;
- }
-
- /* indices */
- index= iv->data[0];
- idata= dl->index;
- first= 1;
- lll=iv->datalen[0]-2;
- for(a=0; a<lll; a++) {
-
- if(index[0]!= -1 && index[1]!= -1 && index[2]!= -1) {
-
- /* this trick is to fill poly's with more than 3 vertices correctly */
- if(first) {
- nr= (int) index[0];
- first= 0;
- }
- idata[0]= nr;
- idata[1]= (int) index[1];
- idata[2]= (int) index[2];
- idata+= 3;
- }
- else first= 1;
-
- index++;
- }
- }
- }
- }
- else if( strcmp(iv->nodename, "IndexedTriangleMesh")==0 ||
- strcmp(iv->nodename, "IndexedTriangleStripSet")==0 ) {
-
- colnr= iv_colornumber(iv);
-
- /* seek back to data */
- ivp= iv;
- while(ivp->prev) {
- ivp= ivp->prev;
- if( strcmp(ivp->nodename, "Coordinate3")==0 ) {
- coordtype= 3;
- break;
- }
- if( strcmp(ivp->nodename, "Coordinate4")==0 ) {
- coordtype= 4;
- break;
- }
- }
- if(ivp) {
-
- /* count triangles */
- face= 0;
- index= iv->data[0];
- lll=iv->datalen[0]-2;
- for(a=0; a<lll; a++) {
- if(index[0]!= -1 && index[1]!= -1 && index[2]!= -1) face++;
- index++;
- }
-
- /* nr of vertices */
- tot= ivp->datalen[0]/coordtype;
-
- dl= MEM_callocN(sizeof(struct DispList), "leesInventor6");
- BLI_addtail(listb, dl);
- dl->type= DL_INDEX3;
- dl->nr= tot;
- dl->parts= face;
- dl->col= colnr;
-
- dl->verts= MEM_callocN( tot*3*sizeof(float), "dl verts");
- dl->index= MEM_callocN(sizeof(int)*3*face, "dl index");
-
- /* vertices */
- fp= ivp->data[0];
- data= dl->verts;
- for(b=tot; b>0; b--) {
- VECCOPY(data, fp);
- data+= 3;
- fp+= coordtype;
- }
-
- /* indices */
- index= iv->data[0];
- idata= dl->index;
-
- lll=iv->datalen[0]-2;
- for(a=lll; a>0; a--) {
-
- if(index[0]!= -1 && index[1]!= -1 && index[2]!= -1) {
- idata[0]= (int) index[0];
- idata[1]= (int) index[1];
- idata[2]= (int) index[2];
- idata+= 3;
- }
- index++;
- }
- }
- }
- else if( strcmp(iv->nodename, "QuadMesh")==0 ) {
-
- colnr= iv_colornumber(iv);
-
- /* seek back to data */
- ivp= iv;
- while(ivp->prev) {
- ivp= ivp->prev;
- if( strcmp(ivp->nodename, "Coordinate3")==0 ) {
- coordtype= 3;
- break;
- }
- if( strcmp(ivp->nodename, "VertexProperty")==0 ) {
- coordtype= 3;
- break;
- }
- if( strcmp(ivp->nodename, "Coordinate4")==0 ) {
- coordtype= 4;
- break;
- }
- }
-
- if(ivp) {
- tot= (int) (floor(*(iv->data[0])+0.5) * floor(*(iv->data[1])+0.5));
-
- if(tot>0) {
- dl= MEM_callocN(sizeof(struct DispList)+tot*3*sizeof(float), "leesInventor8");
- BLI_addtail(listb, dl);
- dl->type= DL_SURF;
- dl->parts= (int) floor(*(iv->data[0])+0.5);
- dl->nr= (int) floor(*(iv->data[1])+0.5);
- dl->col= colnr;
- data= (float *)(dl+1);
- memcpy(data, ivp->data[0], tot*3*sizeof(float));
- }
- }
- }
- else if(strcmp(iv->nodename, "IndexedNurbsSurface")==0 || strcmp(iv->nodename, "NurbsSurface")==0) {
-
- colnr= iv_colornumber(iv);
-
- /* sek back to data */
- ivp= iv;
- while(ivp->prev) {
- ivp= ivp->prev;
- if( strcmp(ivp->nodename, "Coordinate3")==0 ) {
- coordtype= 3;
- break;
- }
- if( strcmp(ivp->nodename, "Coordinate4")==0 ) {
- coordtype= 4;
- break;
- }
- }
- if(ivp) {
- a= (int) *(iv->data[0]);
- b= (int) *(iv->data[1]);
-
- tot= a*b;
-
- if( (a>=4 || b>=4) && tot>6) {
- Object *ob;
- Curve *cu;
- Nurb *nu;
- BPoint *bp;
-
- if(ivsurf==0) {
- ob= add_object(scene, OB_SURF);
- ivsurf= ob;
- }
- else ob= ivsurf;
- cu= ob->data;
- nu = (Nurb*) MEM_callocN(sizeof(Nurb),"addNurbprim") ;
- BLI_addtail(&cu->nurb, nu);
- nu->type= CU_NURBS;
-
- nu->pntsu= a;
- nu->pntsv= b;
- nu->resolu= 2*a;
- nu->resolv= 2*b;
-
- nu->flagu= 0;
- nu->flagv= 0;
-
- nu->bp = bp =
- (BPoint*)MEM_callocN(tot * sizeof(BPoint), "addNurbprim3");
- a= tot;
- data= ivp->data[0];
- while(a--) {
- VECCOPY(bp->vec, data);
- if(coordtype==4) {
- bp->vec[3]= data[3];
- mul_v3_fl(bp->vec, 1.0f/data[3]);
- }
- else bp->vec[3]= 1.0;
- data+= coordtype;
- bp++;
- }
-
- /* iv->datalen[2] / [3] is number of knots */
- nu->orderu= iv->datalen[2] - nu->pntsu;
- nu->orderv= iv->datalen[3] - nu->pntsv;
-
- nu->knotsu= MEM_mallocN( sizeof(float)*(iv->datalen[2]), "knots");
- memcpy(nu->knotsu, iv->data[2], sizeof(float)*(iv->datalen[2]));
- nu->knotsv= MEM_mallocN( sizeof(float)*(iv->datalen[3]), "knots");
- memcpy(nu->knotsv, iv->data[3], sizeof(float)*(iv->datalen[3]));
-
- switchdirectionNurb(nu);
-
- }
- else {
- dl= MEM_callocN(sizeof(struct DispList)+tot*3*sizeof(float), "leesInventor3");
- BLI_addtail(listb, dl);
- dl->type= DL_SURF;
- dl->nr= (int) *(iv->data[0]);
- dl->parts= (int) *(iv->data[1]);
- dl->col= colnr;
- data= (float *)(dl+1);
-
- a= tot;
- fp= ivp->data[0];
- while(a--) {
- VECCOPY(data, fp);
- fp+= coordtype;
- data+= 3;
- }
- }
- }
- }
- iv= iv->next;
- }
-
- /* free */
- iv= ivbase.first;
- while(iv) {
- for(a=0; a<IV_MAXFIELD; a++) {
- if(iv->data[a]) MEM_freeN(iv->data[a]);
- }
- iv= iv->next;
- }
-
- BLI_freelistN(&ivbase);
- MEM_freeN(maindata);
- MEM_freeN(iv_data_stack);
-
-}
-
/* ************************************************************ */
-static void displist_to_mesh(Scene *scene, DispList *dlfirst)
-{
- Object *ob;
- Mesh *me;
- Material *ma;
- DispList *dl;
- MVert *mvert;
- MFace *mface;
- float *data, vec[3], min[3], max[3];
- int a, b, startve, *idata, totedge=0, tottria=0, totquad=0, totvert=0, totface, totcol=0, colnr;
- int p1, p2, p3, p4;
- unsigned int maxvertidx;
-
- /* count first */
- INIT_MINMAX(min, max);
-
- dl= dlfirst;
- while(dl) {
-
- /* PATCH 1 (polyfill) can't be done, there's no listbase here. do that first! */
- /* PATCH 2 */
- if(dl->type==DL_SEGM && dl->nr>2) {
- data= (float *)(dl+1);
- if(data[0]==data[3*(dl->nr-1)]) {
- if(data[1]==data[3*(dl->nr-1)+1]) {
- if(data[2]==data[3*(dl->nr-1)+2]) {
- dl->type= DL_POLY;
- dl->nr--;
- }
- }
- }
- }
-
- /* colors */
- if(dl->col > totcol) totcol= dl->col;
-
- /* size and count */
- if(dl->type==DL_SURF) {
- a= dl->nr;
- b= dl->parts;
- if(dl->flag & DL_CYCL_U) a++;
- if(dl->flag & DL_CYCL_V) b++;
-
- totquad+= a*b;
-
- totvert+= dl->nr*dl->parts;
-
- data= (float *)(dl+1);
- for(a= dl->nr*dl->parts; a>0; a--) {
- DO_MINMAX(data, min, max);
- data+= 3;
- }
- }
- else if(dl->type==DL_POLY) {
- if(dl->nr==3 || dl->nr==4) {
- if(dl->nr==3) tottria+= dl->parts;
- else totquad+= dl->parts;
-
- totvert+= dl->nr*dl->parts;
-
- data= (float *)(dl+1);
- for(a= dl->nr*dl->parts; a>0; a--) {
- DO_MINMAX(data, min, max);
- data+= 3;
- }
- }
- else if(dl->nr>4) {
-
- tottria+= dl->nr*dl->parts;
- totvert+= dl->nr*dl->parts;
-
- data= (float *)(dl+1);
- for(a= dl->nr*dl->parts; a>0; a--) {
- DO_MINMAX(data, min, max);
- data+= 3;
- }
-
- }
- }
- else if(dl->type==DL_INDEX3) {
- tottria+= dl->parts;
- totvert+= dl->nr;
-
- data= dl->verts;
- for(a= dl->nr; a>0; a--) {
- DO_MINMAX(data, min, max);
- data+= 3;
- }
- }
- else if(dl->type==DL_SEGM) {
-
- tottria+= (dl->nr-1)*dl->parts;
- totvert+= dl->nr*dl->parts;
-
- data= (float *)(dl+1);
- for(a= dl->nr*dl->parts; a>0; a--) {
- DO_MINMAX(data, min, max);
- data+= 3;
- }
- }
-
- dl= dl->next;
- }
-
- if(totvert==0) {
- return;
- }
-
- vec[0]= (min[0]+max[0])/2;
- vec[1]= (min[1]+max[1])/2;
- vec[2]= (min[2]+max[2])/2;
-
- ob= add_object(scene, OB_MESH);
- VECCOPY(ob->loc, vec);
- where_is_object(scene, ob);
-
- me= ob->data;
-
- /* colors */
- if(totcol) {
- ob->mat= MEM_callocN(sizeof(void *)*totcol, "ob->mat");
- ob->matbits= MEM_callocN(sizeof(char)*totcol, "ob->matbits");
- me->mat= MEM_callocN(sizeof(void *)*totcol, "me->mat");
- me->totcol= totcol;
- ob->totcol= (unsigned char) me->totcol;
- ob->actcol= 1;
- }
-
- /* materials */
- for(a=0; a<totcol; a++) {
- ma= G.main->mat.first;
- while(ma) {
- if(ma->mtex[0]==0) {
- if(ivcolors[a][0]==ma->r && ivcolors[a][1]==ma->g && ivcolors[a][2]==ma->b) {
- me->mat[a]= ma;
- ma->id.us++;
- break;
- }
- }
- ma= ma->id.next;
- }
- if(ma==0) {
- ma= add_material("ext");
- me->mat[a]= ma;
- ma->r= ivcolors[a][0];
- ma->g= ivcolors[a][1];
- ma->b= ivcolors[a][2];
- automatname(ma);
- }
- }
-
- totface= totquad+tottria+totedge;
-
- printf("Import: %d vertices %d faces\n", totvert, totface);
-
- me->totvert= totvert;
- me->totface= totface;
- me->mvert= CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC,
- NULL, me->totvert);
- me->mface= CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC,
- NULL, me->totface);
- maxvertidx= totvert-1;
-
- mvert= me->mvert;
- mface= me->mface;
-
- startve= 0;
-
- dl= dlfirst;
- while(dl) {
-
- colnr= dl->col;
- if(colnr) colnr--;
-
- if(dl->type==DL_SURF) {
- data= (float *)(dl+1);
-
- for(a=dl->parts*dl->nr; a>0; a--) {
- mvert->co[0]= data[0] -vec[0];
- mvert->co[1]= data[1] -vec[1];
- mvert->co[2]= data[2] -vec[2];
-
- data+=3;
- mvert++;
- }
-
- for(a=0; a<dl->parts; a++) {
-
- if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4)==0)
- break;
-
- p1+= startve;
- p2+= startve;
- p3+= startve;
- p4+= startve;
-
- for(; b<dl->nr; b++) {
-
- mface->v1= p1;
- mface->v2= p2;
- mface->v3= p4;
- mface->v4= p3;
-
- mface->mat_nr= colnr;
- test_index_face(mface, NULL, 0, 4);
-
- mface++;
-
- p4= p3;
- p3++;
- p2= p1;
- p1++;
- }
- }
-
- startve += dl->parts*dl->nr;
-
- }
- else if(dl->type==DL_POLY) {
-
- if(dl->nr==3 || dl->nr==4) {
- data= (float *)(dl+1);
-
- for(a=dl->parts*dl->nr; a>0; a--) {
- mvert->co[0]= data[0] -vec[0];
- mvert->co[1]= data[1] -vec[1];
- mvert->co[2]= data[2] -vec[2];
- data+=3;
- mvert++;
- }
-
- for(a=0; a<dl->parts; a++) {
- if(dl->nr==3) {
- mface->v1= startve+a*dl->nr;
- mface->v2= startve+a*dl->nr+1;
- mface->v3= startve+a*dl->nr+2;
- mface->mat_nr= colnr;
- test_index_face(mface, NULL, 0, 3);
- mface++;
- }
- else {
- mface->v1= startve+a*dl->nr;
- mface->v2= startve+a*dl->nr+1;
- mface->v3= startve+a*dl->nr+2;
- mface->v4= startve+a*dl->nr+3;
- mface->mat_nr= colnr;
- test_index_face(mface, NULL, 0, 4);
- mface++;
- }
- }
- startve += dl->parts*dl->nr;
- }
- else if(dl->nr>4) {
- data= (float *)(dl+1);
-
- for(a=dl->parts*dl->nr; a>0; a--) {
- mvert->co[0]= data[0] -vec[0];
- mvert->co[1]= data[1] -vec[1];
- mvert->co[2]= data[2] -vec[2];
-
- data+=3;
- mvert++;
- }
-
- for(b=0; b<dl->parts; b++) {
- for(a=0; a<dl->nr; a++) {
- mface->v1= startve+a;
-
- if(a==dl->nr-1) mface->v2= startve;
- else mface->v2= startve+a+1;
-
- mface->mat_nr= colnr;
-
- mface++;
- }
- startve += dl->nr;
- }
- }
- }
- else if(dl->type==DL_INDEX3) {
- data= dl->verts;
-
- for(a=dl->nr; a>0; a--) {
- mvert->co[0]= data[0] -vec[0];
- mvert->co[1]= data[1] -vec[1];
- mvert->co[2]= data[2] -vec[2];
- data+=3;
- mvert++;
- }
-
- idata= dl->index;
- for(b=dl->parts; b>0; b--) {
- mface->v1= startve+idata[0];
- mface->v2= startve+idata[1];
- mface->v3= startve+idata[2];
- mface->mat_nr= colnr;
-
- if (mface->v1>maxvertidx) mface->v1= maxvertidx;
- if (mface->v2>maxvertidx) mface->v2= maxvertidx;
- if (mface->v3>maxvertidx) mface->v3= maxvertidx;
-
- test_index_face(mface, NULL, 0, 3);
- mface++;
- idata+= 3;
- }
- startve += dl->nr;
- }
- else if(dl->type==DL_SEGM) {
- data= (float *)(dl+1);
-
- for(a=dl->parts*dl->nr; a>0; a--) {
- mvert->co[0]= data[0] -vec[0];
- mvert->co[1]= data[1] -vec[1];
- mvert->co[2]= data[2] -vec[2];
- data+=3;
- mvert++;
- }
-
- for(b=0; b<dl->parts; b++) {
- for(a=0; a<dl->nr-1; a++) {
- mface->v1= startve+a;
- mface->v2= startve+a+1;
- mface->mat_nr= colnr;
- mface++;
- }
- startve += dl->nr;
- }
- }
- dl= dl->next;
- }
-
- mesh_add_normals_flags(me);
- make_edges(me, 0);
-}
-
-static void displist_to_objects(Scene *scene, ListBase *lbase)
-{
- DispList *dl, *first, *prev, *next;
- ListBase tempbase;
- int maxaantal, curcol, totvert=0, vert;
-
- /* irst this: is still active */
- if(ivsurf) {
- where_is_object(scene, ivsurf);
-// XXX docenter_new();
- }
-
- dl= lbase->first;
- while(dl) {
- next= dl->next;
-
- /* PATCH 1: polyfill */
- if(dl->type==DL_POLY && dl->nr>4) {
- /* solution: put them together in separate listbase */
- ;
- }
- /* PATCH 2: poly's of 2 points */
- if(dl->type==DL_POLY && dl->nr==2) dl->type= DL_SEGM;
-
- dl= next;
- }
-
- /* count vertices */
-
- dl= lbase->first;
- while(dl) {
-
- if(dl->type==DL_SURF) totvert+= dl->nr*dl->parts;
- else if(dl->type==DL_POLY) {
- if(dl->nr==3 || dl->nr==4) totvert+= dl->nr*dl->parts;
- else if(dl->nr>4) totvert+= dl->nr*dl->parts;
- }
- else if(dl->type==DL_INDEX3) totvert+= dl->nr;
- else if(dl->type==DL_SEGM) totvert+= dl->nr*dl->parts;
-
- dl= dl->next;
- }
-
- if(totvert==0) {
-
- if(ivsurf==0) {}; //XXX error("Found no data");
- if(lbase->first) BLI_freelistN(lbase);
-
- return;
- }
-
- maxaantal= 32000;
-
- if(totvert>maxaantal) {
-
- /* try to put colors together */
- curcol= 0;
- tempbase.first= tempbase.last= 0;
-
- while(lbase->first) {
- dl= lbase->first;
- while(dl) {
- next= dl->next;
- if(dl->col==curcol) {
- BLI_remlink(lbase, dl);
- BLI_addtail(&tempbase, dl);
- dl->col= 0;
- }
-
- dl= next;
- }
-
- /* in tempbase are all 'curcol' */
- totvert= 0;
- dl= first= tempbase.first;
- while(dl) {
- vert= 0;
-
- if(dl->type==DL_SURF) vert= dl->nr*dl->parts;
- else if(dl->type==DL_POLY) {
- if(dl->nr==3 || dl->nr==4) vert= dl->nr*dl->parts;
- else if(dl->nr>4) vert= dl->nr*dl->parts;
- }
- else if(dl->type==DL_INDEX3) totvert+= dl->nr;
- else if(dl->type==DL_SEGM) vert= dl->nr*dl->parts;
-
- totvert+= vert;
- if(totvert > maxaantal || dl->next==0) {
- if(dl->next==0) {
- displist_to_mesh(scene, first);
- }
- else if(dl->prev) {
- prev= dl->prev;
- prev->next= 0;
- displist_to_mesh(scene, first);
- prev->next= dl;
- first= dl;
- totvert= 0;
- }
- }
-
- dl= dl->next;
- }
-
- freedisplist(&tempbase);
-
- curcol++;
- }
- }
- else displist_to_mesh(scene, lbase->first);
-
- freedisplist(lbase);
-
-}
-
int BKE_read_exotic(Scene *scene, char *name)
{
- ListBase lbase={0, 0};
int len;
gzFile gzfile;
char str[32];
@@ -1793,21 +475,7 @@ int BKE_read_exotic(Scene *scene, char *name)
if ((*s0 != FORM) && (strncmp(str, "BLEN", 4) != 0) && !BLI_testextensie(name,".blend.gz")) {
//XXX waitcursor(1);
- if(strncmp(str, "#Inventor V1.0", 14)==0) {
- if( strncmp(str+15, "ascii", 5)==0) {
- read_inventor(scene, name, &lbase);
- displist_to_objects(scene, &lbase);
- retval = 1;
- } else {
- //XXX error("Can only read Inventor 1.0 ascii");
- }
- }
- else if((strncmp(str, "#VRML V1.0 asc", 14)==0)) {
- read_inventor(scene, name, &lbase);
- displist_to_objects(scene, &lbase);
- retval = 1;
- }
- else if(is_dxf(name)) {
+ if(is_dxf(name)) {
dxf_read(scene, name);
retval = 1;
}
@@ -1965,7 +633,6 @@ void write_stl(Scene *scene, char *str)
//XXX waitcursor(0);
}
-/* ******************************* WRITE VRML ***************************** */
static void replace_chars(char *str1, char *str2)
{
@@ -1978,354 +645,6 @@ static void replace_chars(char *str1, char *str2)
}
}
-
-static void write_material_vrml(FILE *fp, Material *ma)
-{
- char str[32];
-
- replace_chars(str, ma->id.name+2);
-
- fprintf(fp, "\tDEF %s\n", str);
- fprintf(fp, "\tMaterial {\n");
-
- fprintf(fp, "\t\tdiffuseColor %f %f %f\n", ma->r, ma->g, ma->b);
- fprintf(fp, "\t\tspecularColor %f %f %f\n", ma->specr, ma->specg, ma->specb);
- fprintf(fp, "\t\tshininess %f \n", ((float)ma->har)/100.0);
- fprintf(fp, "\t\ttransparency %f \n", 1.0-ma->alpha);
-
- fprintf(fp, "\t}\n");
-
-}
-
-unsigned int *mcol_to_vcol(Mesh *me)
-{
- MFace *mface;
- unsigned int *mcol, *mcoln, *mcolmain;
- int a;
-
- if(me->totface==0 || me->mcol==0) return 0;
-
- mcoln= mcolmain= MEM_mallocN(sizeof(int)*me->totvert, "mcoln");
- mcol = (unsigned int *)me->mcol;
- mface= me->mface;
-
- for(a=me->totface; a>0; a--, mface++) {
- mcoln[mface->v1]= mcol[0];
- mcoln[mface->v2]= mcol[1];
- mcoln[mface->v3]= mcol[2];
- if(mface->v4) mcoln[mface->v4]= mcol[3];
-
- mcol+= 4;
- }
-
- return mcolmain;
-}
-
-void mcol_to_rgba(unsigned int col, float *r, float *g, float *b, float *a)
-{
- char *cp;
-
- cp = (char *)&col;
-
- *r= cp[3];
- *r /= 255.0;
-
- *g= cp[2];
- *g /= 255.0;
-
- *b= cp[1];
- *b /= 255.0;
-
- *a= cp[0];
- *a /= 255.0;
-}
-
-static void write_mesh_vrml(FILE *fp, Mesh *me)
-{
- Material *ma;
- MVert *mvert;
- MFace *mface;
- MTFace *tface;
- Image *ima;
- int a, b, totcol, texind;
- char str[32];
-
- replace_chars(str, me->id.name+2);
-
- fprintf(fp, "\tDEF %s\n", str);
- fprintf(fp, "\tSeparator {\n");
-
- if(me->mtface) {
- ima= ((MTFace *)me->mtface)->tpage;
- if(ima) {
- fprintf(fp, "\t\tTexture2 {\n");
- fprintf(fp, "\t\t\tfilename %s\n", ima->name);
- fprintf(fp, "\t\t\twrapS REPEAT \n");
- fprintf(fp, "\t\t\twrapT REPEAT \n");
- fprintf(fp, "\t\t}\n");
- }
- }
-
- if(me->mcol) {
- unsigned int *mcol, *mcolmain;
- float r, g, b, cola;
-
- fprintf(fp, "\t\tMaterial {\n");
- fprintf(fp, "\t\t\tdiffuseColor [\n");
-
- a= me->totvert;
- mcol= mcolmain= mcol_to_vcol(me);
- if(mcol) {
- while(a--) {
- mcol_to_rgba(*mcol, &r, &g, &b, &cola);
- fprintf(fp, "\t\t\t\t %f %f %f,\n", r, g, b);
- mcol++;
- }
- MEM_freeN(mcolmain);
- }
- fprintf(fp, "\t\t\t]\n");
- fprintf(fp, "\t\t}\n");
-
- fprintf(fp, "\t\tMaterialBinding { value PER_VERTEX_INDEXED }\n");
- }
-
-
- fprintf(fp, "\t\tCoordinate3 {\n");
- fprintf(fp, "\t\t\tpoint [\n");
-
- a= me->totvert;
- mvert= me->mvert;
- while(a--) {
- fprintf(fp, "\t\t\t\t %f %f %f,\n", mvert->co[0], mvert->co[1], mvert->co[2]);
- mvert++;
- }
- fprintf(fp, "\t\t\t]\n");
- fprintf(fp, "\t\t}\n");
-
-
- totcol= me->totcol;
- if(totcol==0) totcol= 1;
- texind= 0; // index for uv coords
-
- for(b=0; b<totcol; b++) {
-
- if(me->mcol==0) {
- if(me->mat) {
- ma= me->mat[b];
- if(ma) {
- replace_chars(str, ma->id.name+2);
-
- fprintf(fp, "\t\tUSE %s\n\n", str);
- }
- }
- }
-
- if(me->mtface) {
- fprintf(fp, "\t\tTextureCoordinate2 {\n");
- fprintf(fp, "\t\t\tpoint [\n");
-
- a= me->totface;
- mface= me->mface;
- tface= me->mtface;
- while(a--) {
- if(mface->mat_nr==b) {
- fprintf(fp, "\t\t\t\t %f %f,\n", tface->uv[0][0], tface->uv[0][1]);
- fprintf(fp, "\t\t\t\t %f %f,\n", tface->uv[1][0], tface->uv[1][1]);
- fprintf(fp, "\t\t\t\t %f %f,\n", tface->uv[2][0], tface->uv[2][1]);
- if(mface->v4) fprintf(fp, "\t\t\t\t %f %f,\n", tface->uv[3][0], tface->uv[3][1]);
- }
- mface++;
- tface++;
- }
- fprintf(fp, "\t\t\t]\n");
- fprintf(fp, "\t\t}\n");
- }
-
- fprintf(fp, "\t\tIndexedFaceSet {\n");
- fprintf(fp, "\t\t\tcoordIndex [\n");
-
- a= me->totface;
- mface= me->mface;
- while(a--) {
- if(mface->mat_nr==b) {
- if(mface->v4) fprintf(fp, "\t\t\t\t %d, %d, %d, %d, -1,\n", mface->v1, mface->v2, mface->v3, mface->v4);
- else fprintf(fp, "\t\t\t\t %d, %d, %d, -1,\n", mface->v1, mface->v2, mface->v3);
- }
- mface++;
- }
- fprintf(fp, "\t\t\t]\n");
-
- if(me->mtface) {
- fprintf(fp, "\t\t\ttextureCoordIndex [\n");
-
- a= me->totface;
- mface= me->mface;
- while(a--) {
- if(mface->mat_nr==b) {
- if(mface->v4) {
- fprintf(fp, "\t\t\t\t %d, %d, %d, %d, -1,\n", texind, texind+1, texind+2, texind+3);
- texind+= 4;
- }
- else {
- fprintf(fp, "\t\t\t\t %d, %d, %d, -1,\n", texind, texind+1, texind+2);
- texind+= 3;
- }
- }
- mface++;
- }
- fprintf(fp, "\t\t\t]\n");
- }
- fprintf(fp, "\t\t}\n");
- }
-
- fprintf(fp, "\t}\n");
-}
-
-static void write_camera_vrml(FILE *fp, Object *ob)
-{
- Camera *cam;
-
- if(ob==0) return;
- invert_m4_m4(ob->imat, ob->obmat);
-
- fprintf(fp, "\tMatrixTransform {\n");
-
- fprintf(fp, "\tmatrix \n");
-
- fprintf(fp, "\t\t%f %f %f %f\n", ob->imat[0][0], ob->imat[0][1], ob->imat[0][2], ob->imat[0][3]);
- fprintf(fp, "\t\t%f %f %f %f\n", ob->imat[1][0], ob->imat[1][1], ob->imat[1][2], ob->imat[1][3]);
- fprintf(fp, "\t\t%f %f %f %f\n", ob->imat[2][0], ob->imat[2][1], ob->imat[2][2], ob->imat[2][3]);
- fprintf(fp, "\t\t%f %f %f %f\n", ob->imat[3][0], ob->imat[3][1], ob->imat[3][2], ob->imat[3][3]);
-
- fprintf(fp, "\t}\n");
-
- cam= ob->data;
-
- fprintf(fp, "\tPerspectiveCamera {\n");
- fprintf(fp, "\t\tfocalDistance %f\n", cam->lens/10.0);
-
- fprintf(fp, "\t}\n");
-
-}
-
-static void write_object_vrml(FILE *fp, Object *ob)
-{
- ID *id;
- char str[32];
-
- fprintf(fp, "\tSeparator {\n");
- fprintf(fp, "\t\tMatrixTransform {\n");
-
- fprintf(fp, "\t\tmatrix \n");
-
- fprintf(fp, "\t\t\t%f %f %f %f\n", ob->obmat[0][0], ob->obmat[0][1], ob->obmat[0][2], ob->obmat[0][3]);
- fprintf(fp, "\t\t\t%f %f %f %f\n", ob->obmat[1][0], ob->obmat[1][1], ob->obmat[1][2], ob->obmat[1][3]);
- fprintf(fp, "\t\t\t%f %f %f %f\n", ob->obmat[2][0], ob->obmat[2][1], ob->obmat[2][2], ob->obmat[2][3]);
- fprintf(fp, "\t\t\t%f %f %f %f\n", ob->obmat[3][0], ob->obmat[3][1], ob->obmat[3][2], ob->obmat[3][3]);
-
- fprintf(fp, "\t\t}\n");
-
- id= ob->data;
-
- replace_chars(str, id->name+2);
-
- fprintf(fp, "\t\tUSE %s\n", str);
- fprintf(fp, "\t}\n");
-}
-
-
-void write_vrml(Scene *scene, char *str)
-{
- Mesh *me;
- Material *ma;
- Base *base;
- FILE *fp;
-
- if(BLI_testextensie(str,".blend")) str[ strlen(str)-6]= 0;
- if(BLI_testextensie(str,".ble")) str[ strlen(str)-4]= 0;
- if(BLI_testextensie(str,".wrl")==0) strcat(str, ".wrl");
- //XXX saveover() if(saveover(str)==0) return;
-
- fp= fopen(str, "w");
-
- if(fp==NULL) {
- //XXX error("Can't write file");
- return;
- }
- strcpy(temp_dir, str);
-
- //XXX waitcursor(1);
-
- /* FIRST: write all the datablocks */
-
- fprintf(fp, "#VRML V1.0 ascii\n\n# Blender V%d\n\n# 'Switch' is used as a hack, to ensure it is not part of the drawing\n\n", BLENDER_VERSION);
- fprintf(fp, "Separator {\n");
- fprintf(fp, "Switch {\n");
-
- ma= G.main->mat.first;
- while(ma) {
- if(ma->id.us) {
- write_material_vrml(fp, ma);
- }
- ma= ma->id.next;
- }
-
- /* only write meshes we're using in this scene */
- flag_listbase_ids(&G.main->mesh, LIB_DOIT, 0);
-
- for(base= scene->base.first; base; base= base->next)
- if(base->object->type== OB_MESH)
- ((ID *)base->object->data)->flag |= LIB_DOIT;
-
- me= G.main->mesh.first;
- while(me) {
- if(me->id.flag & LIB_DOIT) { /* is the mesh used in this scene ? */
- write_mesh_vrml(fp, me);
- }
- me= me->id.next;
- }
-
- /* THEN:Hidden Objects */
- fprintf(fp, "\n\t# Hidden Objects, in invisible layers\n\n");
- base= scene->base.first;
- while(base) {
- if(base->object->type== OB_MESH) {
- if( (base->lay & scene->lay)==0 ) {
- write_object_vrml(fp, base->object);
- }
- }
- base= base->next;
- }
-
- fprintf(fp, "}\n");
- fprintf(fp, "\n# Visible Objects\n\n");
- fprintf(fp, "Separator {\n");
-
- /* The camera */
-
- write_camera_vrml(fp, scene->camera);
-
- /* THEN:The Objects */
-
- base= scene->base.first;
- while(base) {
- if(base->object->type== OB_MESH) {
- if(base->lay & scene->lay) {
- write_object_vrml(fp, base->object);
- }
- }
- base= base->next;
- }
-
- fprintf(fp, "}\n");
- fprintf(fp, "}\n");
-
- fclose(fp);
-
- //XXX waitcursor(0);
-}
-
-
/* ******************************* WRITE DXF ***************************** */
#define write_group(id,data) fprintf(fp, "%d\n%s\n", id, data)