forked from bartvdbraak/blender
removed videoscape support, a format from 1988 that nobody uses anymore.
This commit is contained in:
parent
56b9617ce0
commit
0745133528
@ -87,7 +87,7 @@ if __name__ == '__main__':
|
||||
main()
|
||||
'''
|
||||
|
||||
new_text = Text.New('mesh_template.py')
|
||||
new_text = bpy.texts.new('mesh_template.py')
|
||||
new_text.write(script_data)
|
||||
new_text.makeCurrent()
|
||||
bpy.texts.active = new_text
|
||||
Window.RedrawAll()
|
@ -28,7 +28,7 @@
|
||||
* Contributor(s): none yet.
|
||||
*
|
||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||
* dxf/vrml/videoscape external file io function prototypes
|
||||
* dxf/vrml/stl external file io function prototypes
|
||||
*/
|
||||
|
||||
#ifndef BKE_EXOTIC_H
|
||||
@ -49,7 +49,6 @@ int BKE_read_exotic(char *name);
|
||||
|
||||
void write_dxf(char *str);
|
||||
void write_vrml(char *str);
|
||||
void write_videoscape(char *str);
|
||||
void write_stl(char *str);
|
||||
|
||||
#endif
|
||||
|
@ -32,45 +32,6 @@
|
||||
* Copyright (C) 2004 by Etheract Software Labs
|
||||
*
|
||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||
*
|
||||
* eigen videoscape formaat:
|
||||
*
|
||||
*
|
||||
* lamp:
|
||||
* 3DG2
|
||||
aantal_lampen
|
||||
|
||||
type
|
||||
spsi spbl
|
||||
r, g, b, energy
|
||||
locx, locy, locz
|
||||
vecx, vecy, vecz
|
||||
|
||||
|
||||
curve / nurbs:
|
||||
3DG3
|
||||
5 of 11 (curve of surf)
|
||||
aantal_nurbs
|
||||
extr1 extr2
|
||||
|
||||
mat[0][0] mat[0][1] mat[0][2] mat[0][3]
|
||||
mat[1][0] mat[1][1] mat[1][2] mat[1][3]
|
||||
...
|
||||
|
||||
type
|
||||
pntsu, pntsv
|
||||
resolu, resolv
|
||||
orderu, orderv
|
||||
flagu, flagv
|
||||
|
||||
(als type==nurb) x y z w
|
||||
x y z w
|
||||
...
|
||||
(als type==bez) xyz xyz xyz h1 h2 h3
|
||||
xyz xyz xyz h1 h2 h3
|
||||
...
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@ -484,569 +445,6 @@ static void read_stl_mesh_ascii(char *str)
|
||||
#undef STLREADLINE
|
||||
#undef STLREADVERT
|
||||
|
||||
static void read_videoscape_mesh(char *str)
|
||||
{
|
||||
Object *ob;
|
||||
Mesh *me;
|
||||
MVert *mvert;
|
||||
MFace *mface;
|
||||
Material *ma;
|
||||
FILE *fp;
|
||||
float *vertdata, *vd, min[3], max[3], cent[3], ftemp;
|
||||
unsigned int color[32], col;
|
||||
int totcol, a, b, verts, tottria=0, totquad=0, totedge=0, poly, nr0, nr, first;
|
||||
int end;
|
||||
char s[50];
|
||||
|
||||
fp= fopen(str, "rb");
|
||||
if(fp==NULL) {
|
||||
error("Can't read file");
|
||||
return;
|
||||
}
|
||||
|
||||
fscanf(fp, "%40s", s);
|
||||
|
||||
fscanf(fp, "%d\n", &verts);
|
||||
if(verts<=0) {
|
||||
fclose(fp);
|
||||
error("Read error");
|
||||
return;
|
||||
}
|
||||
|
||||
if(verts>MESH_MAX_VERTS) {
|
||||
error("too many vertices");
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
INIT_MINMAX(min, max);
|
||||
vd= vertdata= MEM_mallocN(sizeof(float)*3*verts, "videoscapelezer");
|
||||
|
||||
for(a=0; a<verts; a++) {
|
||||
fscanf(fp, "%f %f %f", vd, vd+1, vd+2);
|
||||
DO_MINMAX(vd, min, max);
|
||||
vd+=3;
|
||||
}
|
||||
|
||||
/* count faces and colors */
|
||||
for(a=0; a<32; a++) color[a]= 0;
|
||||
totcol= 0;
|
||||
end= 1;
|
||||
while(end>0) {
|
||||
end= fscanf(fp,"%d", &poly);
|
||||
if(end<=0) break;
|
||||
|
||||
if(poly==3) tottria++;
|
||||
else if(poly==4) totquad++;
|
||||
else totedge+= poly;
|
||||
|
||||
for(a=0;a<poly;a++) {
|
||||
end= fscanf(fp,"%d", &nr);
|
||||
if(end<=0) break;
|
||||
}
|
||||
if(end<=0) break;
|
||||
|
||||
end= fscanf(fp,"%i\n", &col);
|
||||
col &= 0xF0F0F0;
|
||||
for(a=0; a<totcol; a++) {
|
||||
if(color[a]==col) break;
|
||||
}
|
||||
if(a>=totcol && totcol<32) {
|
||||
color[totcol]= col;
|
||||
totcol++;
|
||||
}
|
||||
}
|
||||
|
||||
/* new object */
|
||||
ob= add_object(OB_MESH);
|
||||
me= ob->data;
|
||||
me->totvert= verts;
|
||||
me->totface= totedge+tottria+totquad;
|
||||
|
||||
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);
|
||||
|
||||
/* colors */
|
||||
if(totcol) {
|
||||
ob->mat= MEM_callocN(sizeof(void *)*totcol, "ob->mat");
|
||||
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) {
|
||||
col= rgb_to_cpack(ma->r, ma->g, ma->b);
|
||||
if(color[a]==col) {
|
||||
me->mat[a]= ma;
|
||||
ma->id.us++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ma= ma->id.next;
|
||||
}
|
||||
if(ma==0) {
|
||||
ma= add_material("ext");
|
||||
me->mat[a]= ma;
|
||||
cpack_to_rgb(color[a], cent, cent+1, cent+2);
|
||||
ma->r= cent[0];
|
||||
ma->g= cent[1];
|
||||
ma->b= cent[2];
|
||||
automatname(ma);
|
||||
}
|
||||
}
|
||||
|
||||
/* verts */
|
||||
|
||||
cent[0]= (min[0]+max[0])/2.0f;
|
||||
cent[1]= (min[1]+max[1])/2.0f;
|
||||
cent[2]= (min[2]+max[2])/2.0f;
|
||||
VECCOPY(ob->loc, cent);
|
||||
|
||||
a= me->totvert;
|
||||
vd= vertdata;
|
||||
mvert= me->mvert;
|
||||
while(a--) {
|
||||
VecSubf(mvert->co, vd, cent);
|
||||
mvert++;
|
||||
vd+= 3;
|
||||
}
|
||||
|
||||
/* faces */
|
||||
if(me->totface) {
|
||||
rewind(fp);
|
||||
|
||||
fscanf(fp, "%40s", s);
|
||||
fscanf(fp, "%d\n", &verts);
|
||||
/* fake read */
|
||||
for(a=0;a<verts;a++) {
|
||||
fscanf(fp, "%f %f %f", &ftemp, &ftemp, &ftemp);
|
||||
}
|
||||
|
||||
a= me->totface;
|
||||
mface= me->mface;
|
||||
while(a--) {
|
||||
end= fscanf(fp,"%d", &poly);
|
||||
if(end<=0) break;
|
||||
|
||||
if(poly==3 || poly==4) {
|
||||
fscanf(fp,"%d", &nr);
|
||||
mface->v1= MIN2(nr, me->totvert-1);
|
||||
fscanf(fp,"%d", &nr);
|
||||
mface->v2= MIN2(nr, me->totvert-1);
|
||||
fscanf(fp,"%d", &nr);
|
||||
mface->v3= MIN2(nr, me->totvert-1);
|
||||
if(poly==4) {
|
||||
if( fscanf(fp,"%d", &nr) <=0 ) break;
|
||||
mface->v4= MIN2(nr, me->totvert-1);
|
||||
}
|
||||
|
||||
test_index_face(mface, NULL, 0, poly);
|
||||
|
||||
mface++;
|
||||
}
|
||||
else {
|
||||
if( fscanf(fp,"%d", &nr0) <=0) break;
|
||||
first= nr0;
|
||||
for(b=1; b<poly; b++) {
|
||||
end= fscanf(fp,"%d", &nr);
|
||||
if(end<=0) break;
|
||||
nr= MIN2(nr, me->totvert-1);
|
||||
mface->v1= nr;
|
||||
mface->v2= nr0;
|
||||
nr0= nr;
|
||||
mface++;
|
||||
a--;
|
||||
}
|
||||
mface->v1= first;
|
||||
mface->v2= nr;
|
||||
mface++;
|
||||
if(end<=0) break;
|
||||
}
|
||||
end= fscanf(fp,"%i", &col);
|
||||
col &= 0xF0F0F0;
|
||||
if(end<=0) break;
|
||||
|
||||
for(b=0; b<totcol; b++) {
|
||||
if(color[b]==col) {
|
||||
(mface-1)->mat_nr= b;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
MEM_freeN(vertdata);
|
||||
|
||||
mesh_add_normals_flags(me);
|
||||
make_edges(me, 0);
|
||||
|
||||
waitcursor(1);
|
||||
}
|
||||
|
||||
static void read_radiogour(char *str)
|
||||
{
|
||||
Object *ob;
|
||||
Mesh *me;
|
||||
MVert *mvert;
|
||||
MFace *mface;
|
||||
FILE *fp;
|
||||
float *vertdata, *vd, min[3], max[3], cent[3], ftemp;
|
||||
unsigned int *colv, *colf, *colvertdata;
|
||||
int itemp, a, b, verts, tottria=0, totquad=0, totedge=0, poly, nr0, nr, first;
|
||||
int end;
|
||||
char s[50];
|
||||
|
||||
fp= fopen(str, "rb");
|
||||
if(fp==NULL) {
|
||||
error("Can't read file");
|
||||
return;
|
||||
}
|
||||
|
||||
fscanf(fp, "%40s", s);
|
||||
|
||||
fscanf(fp, "%d\n", &verts);
|
||||
if(verts<=0) {
|
||||
fclose(fp);
|
||||
error("Read error");
|
||||
return;
|
||||
}
|
||||
|
||||
if(verts>MESH_MAX_VERTS) {
|
||||
error("too many vertices");
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
INIT_MINMAX(min, max);
|
||||
vd= vertdata= MEM_mallocN(sizeof(float)*3*verts, "videoscapelezer");
|
||||
colv= colvertdata= MEM_mallocN(verts*sizeof(float), "coldata");
|
||||
|
||||
for(a=0; a<verts; a++) {
|
||||
fscanf(fp, "%f %f %f %i", vd, vd+1, vd+2, colv);
|
||||
DO_MINMAX(vd, min, max);
|
||||
vd+=3;
|
||||
colv++;
|
||||
}
|
||||
|
||||
/* count faces */
|
||||
end= 1;
|
||||
while(end>0) {
|
||||
end= fscanf(fp,"%d", &poly);
|
||||
if(end<=0) break;
|
||||
|
||||
if(poly==3) tottria++;
|
||||
else if(poly==4) totquad++;
|
||||
else totedge+= poly;
|
||||
|
||||
for(a=0;a<poly;a++) {
|
||||
end= fscanf(fp,"%d", &nr);
|
||||
if(end<=0) break;
|
||||
}
|
||||
if(end<=0) break;
|
||||
|
||||
}
|
||||
|
||||
if(totedge+tottria+totquad>MESH_MAX_VERTS) {
|
||||
printf(" var1: %d, var2: %d, var3: %d \n", totedge, tottria, totquad);
|
||||
error("too many faces");
|
||||
MEM_freeN(vertdata);
|
||||
MEM_freeN(colvertdata);
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
/* new object */
|
||||
ob= add_object(OB_MESH);
|
||||
me= ob->data;
|
||||
me->totvert= verts;
|
||||
me->totface= totedge+tottria+totquad;
|
||||
me->flag= 0;
|
||||
|
||||
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);
|
||||
|
||||
/* verts */
|
||||
|
||||
cent[0]= (min[0]+max[0])/2.0f;
|
||||
cent[1]= (min[1]+max[1])/2.0f;
|
||||
cent[2]= (min[2]+max[2])/2.0f;
|
||||
VECCOPY(ob->loc, cent);
|
||||
|
||||
a= me->totvert;
|
||||
vd= vertdata;
|
||||
mvert= me->mvert;
|
||||
while(a--) {
|
||||
VecSubf(mvert->co, vd, cent);
|
||||
mvert++;
|
||||
vd+= 3;
|
||||
}
|
||||
|
||||
/* faces */
|
||||
if(me->totface) {
|
||||
rewind(fp);
|
||||
|
||||
fscanf(fp, "%40s", s);
|
||||
fscanf(fp, "%d\n", &verts);
|
||||
for(a=0;a<verts;a++) {
|
||||
fscanf(fp, "%f %f %f %i", &ftemp, &ftemp, &ftemp, &itemp);
|
||||
}
|
||||
|
||||
a= me->totface;
|
||||
mface= me->mface;
|
||||
while(a--) {
|
||||
end= fscanf(fp,"%d", &poly);
|
||||
if(end<=0) break;
|
||||
|
||||
if(poly==3 || poly==4) {
|
||||
fscanf(fp,"%d", &nr);
|
||||
mface->v1= MIN2(nr, me->totvert-1);
|
||||
fscanf(fp,"%d", &nr);
|
||||
mface->v2= MIN2(nr, me->totvert-1);
|
||||
fscanf(fp,"%d", &nr);
|
||||
mface->v3= MIN2(nr, me->totvert-1);
|
||||
if(poly==4) {
|
||||
if( fscanf(fp,"%d", &nr) <=0 ) break;
|
||||
mface->v4= MIN2(nr, me->totvert-1);
|
||||
}
|
||||
|
||||
test_index_face(mface, NULL, 0, poly);
|
||||
|
||||
mface++;
|
||||
}
|
||||
else {
|
||||
if( fscanf(fp,"%d", &nr0) <=0) break;
|
||||
first= nr0;
|
||||
for(b=1; b<poly; b++) {
|
||||
end= fscanf(fp,"%d", &nr);
|
||||
if(end<=0) break;
|
||||
nr= MIN2(nr, me->totvert-1);
|
||||
mface->v1= nr;
|
||||
mface->v2= nr0;
|
||||
nr0= nr;
|
||||
mface++;
|
||||
a--;
|
||||
}
|
||||
mface->v1= first;
|
||||
mface->v2= nr;
|
||||
mface->flag= ME_SMOOTH;
|
||||
|
||||
mface++;
|
||||
if(end<=0) break;
|
||||
}
|
||||
}
|
||||
|
||||
/* mcol is 4 colors per face */
|
||||
me->mcol= MEM_mallocN(4*sizeof(int)*me->totface, "mcol");
|
||||
colf= (unsigned int *)me->mcol;
|
||||
|
||||
a= me->totface;
|
||||
mface= me->mface;
|
||||
while(a--) {
|
||||
|
||||
colf[0]= colvertdata[mface->v1];
|
||||
colf[1]= colvertdata[mface->v2];
|
||||
colf[2]= colvertdata[mface->v3];
|
||||
colf[3]= colvertdata[mface->v4];
|
||||
|
||||
colf+= 4;
|
||||
mface++;
|
||||
}
|
||||
|
||||
MEM_freeN(colvertdata);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
MEM_freeN(vertdata);
|
||||
|
||||
mesh_add_normals_flags(me);
|
||||
make_edges(me, 0);
|
||||
|
||||
waitcursor(1);
|
||||
}
|
||||
|
||||
|
||||
static void read_videoscape_lamp(char *str)
|
||||
{
|
||||
Object *ob;
|
||||
Lamp *la;
|
||||
FILE *fp;
|
||||
float vec[3], *q1;
|
||||
int tot, val;
|
||||
char s[50];
|
||||
|
||||
fp= fopen(str, "rb");
|
||||
if(fp==NULL) {
|
||||
error("Can't read file");
|
||||
return;
|
||||
}
|
||||
|
||||
fscanf(fp, "%40s", s);
|
||||
fscanf(fp, "%d\n", &tot);
|
||||
|
||||
while(tot--) {
|
||||
ob= add_object(OB_LAMP);
|
||||
la= ob->data;
|
||||
|
||||
fscanf(fp, "%d\n", &val);
|
||||
la->type= val;
|
||||
if(la->type==1) la->type= LA_SPOT;
|
||||
else if(la->type==2) la->type= LA_SUN;
|
||||
|
||||
fscanf(fp, "%f %f\n", &la->spotsize, &la->spotblend);
|
||||
|
||||
fscanf(fp, "%f %f %f %f\n", &la->r, &la->g, &la->b, &la->energy);
|
||||
|
||||
fscanf(fp, "%f %f %f\n", ob->loc, ob->loc+1, ob->loc+2);
|
||||
val= fscanf(fp, "%f %f %f\n", vec, vec+1, vec+2);
|
||||
q1= vectoquat(vec, 5, 2);
|
||||
QuatToEul(q1, ob->rot);
|
||||
|
||||
if(val<=0) break;
|
||||
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
static void read_videoscape_nurbs(char *str)
|
||||
{
|
||||
Object *ob;
|
||||
Curve *cu;
|
||||
Nurb *nu;
|
||||
BezTriple *bezt;
|
||||
BPoint *bp;
|
||||
FILE *fp;
|
||||
float tmat[4][4], omat[3][3], imat[3][3], mat[3][3];
|
||||
int a, tot, type, val;
|
||||
char s[50];
|
||||
|
||||
fp= fopen(str, "rb");
|
||||
if(fp==NULL) {
|
||||
error("Can't read file");
|
||||
return;
|
||||
}
|
||||
|
||||
fscanf(fp, "%40s", s);
|
||||
fscanf(fp, "%d\n", &type);
|
||||
|
||||
if(type==5) ob= add_object(OB_SURF);
|
||||
else ob= add_object(OB_CURVE);
|
||||
cu= ob->data;
|
||||
|
||||
fscanf(fp, "%d\n", &tot);
|
||||
fscanf(fp, "%d %d\n", &type, &val);
|
||||
|
||||
cu->ext1= 0.002f*type;
|
||||
cu->ext2= 0.002f*val;
|
||||
|
||||
for(a=0; a<4; a++) fscanf(fp, "%e %e %e %e\n", tmat[a], tmat[a]+1, tmat[a]+2, tmat[a]+3);
|
||||
|
||||
VECCOPY(ob->loc, tmat[3]);
|
||||
|
||||
Mat3CpyMat4(omat, tmat);
|
||||
Mat3ToEul(omat, ob->rot);
|
||||
EulToMat3(ob->rot, mat);
|
||||
Mat3Inv(imat, mat);
|
||||
Mat3MulMat3((float ( * )[3])tmat, imat, omat);
|
||||
|
||||
while(tot--) {
|
||||
nu= (Nurb*)MEM_callocN(sizeof(Nurb),"nu from exotic");
|
||||
BLI_addtail(&cu->nurb, nu);
|
||||
|
||||
fscanf(fp, "%d\n", &type);
|
||||
nu->type= type;
|
||||
|
||||
fscanf(fp, "%d %d\n", &type, &val);
|
||||
nu->pntsu= type; nu->pntsv= val;
|
||||
fscanf(fp, "%d %d\n", &type, &val);
|
||||
nu->resolu= type; nu->resolv= val;
|
||||
fscanf(fp, "%d %d\n", &type, &val);
|
||||
nu->orderu= type; nu->orderv= val;
|
||||
fscanf(fp, "%d %d\n", &type, &val);
|
||||
nu->flagu= type; nu->flagv= val;
|
||||
|
||||
if( (nu->type & 7)==CU_BEZIER) {
|
||||
a= nu->pntsu;
|
||||
nu->bezt= bezt= MEM_callocN(a*sizeof(BezTriple), "bezt from exotic");
|
||||
while(a--) {
|
||||
fscanf(fp, "%f %f %f ", bezt->vec[0], bezt->vec[0]+1, bezt->vec[0]+2);
|
||||
Mat4MulVecfl(tmat, bezt->vec[0]);
|
||||
fscanf(fp, "%f %f %f ", bezt->vec[1], bezt->vec[1]+1, bezt->vec[1]+2);
|
||||
Mat4MulVecfl(tmat, bezt->vec[1]);
|
||||
fscanf(fp, "%f %f %f ", bezt->vec[2], bezt->vec[2]+1, bezt->vec[2]+2);
|
||||
Mat4MulVecfl(tmat, bezt->vec[2]);
|
||||
fscanf(fp, "%d %d\n", &type, &val);
|
||||
bezt->h1= type;
|
||||
bezt->h2= val;
|
||||
bezt++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
a= nu->pntsu*nu->pntsv;
|
||||
if(a) {
|
||||
nu->bp= bp= MEM_callocN(a*sizeof(BPoint), "bp from exotic");
|
||||
while(a--) {
|
||||
fscanf(fp, "%f %f %f %f\n", bp->vec, bp->vec+1, bp->vec+2, bp->vec+3);
|
||||
Mat4MulVecfl(tmat, bp->vec);
|
||||
bp++;
|
||||
}
|
||||
|
||||
val= KNOTSU(nu);
|
||||
nu->knotsu= MEM_mallocN(sizeof(float)*val, "knots");
|
||||
for(a=0; a<val; a++) fscanf(fp, "%f\n", nu->knotsu+a);
|
||||
|
||||
if(nu->pntsv>1) {
|
||||
val= KNOTSV(nu);
|
||||
nu->knotsv= MEM_mallocN(sizeof(float)*val, "knots");
|
||||
for(a=0; a<val; a++) fscanf(fp, "%f\n", nu->knotsv+a);
|
||||
}
|
||||
}
|
||||
else {
|
||||
BLI_remlink(&cu->nurb, nu);
|
||||
MEM_freeN(nu);
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
static void read_videoscape(char *str)
|
||||
{
|
||||
int file, type;
|
||||
unsigned int val;
|
||||
unsigned short numlen;
|
||||
char name[FILE_MAXDIR+FILE_MAXFILE], head[FILE_MAXDIR+FILE_MAXFILE], tail[FILE_MAXFILE];
|
||||
|
||||
strcpy(name, str);
|
||||
|
||||
while( TRUE ) {
|
||||
file= open(name, O_BINARY|O_RDONLY);
|
||||
if(file<=0) break;
|
||||
else {
|
||||
read(file, &type, 4);
|
||||
close(file);
|
||||
|
||||
if(type==DDG1) read_videoscape_mesh(name);
|
||||
else if(type==DDG2) read_videoscape_lamp(name);
|
||||
else if(type==DDG3) read_videoscape_nurbs(name);
|
||||
}
|
||||
|
||||
val = BLI_stringdec(name, head, tail, &numlen);
|
||||
BLI_stringenc(name, head, tail, numlen, val + 1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ***************** INVENTOR ******************* */
|
||||
|
||||
|
||||
@ -2384,23 +1782,7 @@ int BKE_read_exotic(char *name)
|
||||
|
||||
waitcursor(1);
|
||||
|
||||
if(*s0==GOUR) {
|
||||
if(G.obedit) {
|
||||
error("Unable to perform function in EditMode");
|
||||
} else {
|
||||
read_radiogour(name);
|
||||
retval = 1;
|
||||
}
|
||||
}
|
||||
else if ELEM4(*s0, DDG1, DDG2, DDG3, DDG4) {
|
||||
if(G.obedit) {
|
||||
error("Unable to perform function in EditMode");
|
||||
} else {
|
||||
read_videoscape(name);
|
||||
retval = 1;
|
||||
}
|
||||
}
|
||||
else if(strncmp(str, "#Inventor V1.0", 14)==0) {
|
||||
if(strncmp(str, "#Inventor V1.0", 14)==0) {
|
||||
if( strncmp(str+15, "ascii", 5)==0) {
|
||||
read_inventor(name, &lbase);
|
||||
displist_to_objects(&lbase);
|
||||
@ -2446,7 +1828,7 @@ int BKE_read_exotic(char *name)
|
||||
/* ************************ WRITE ************************** */
|
||||
|
||||
|
||||
char videosc_dir[160]= {0, 0};
|
||||
char temp_dir[160]= {0, 0};
|
||||
|
||||
static void write_vert_stl(Object *ob, MVert *verts, int index, FILE *fpSTL)
|
||||
{
|
||||
@ -2528,7 +1910,7 @@ void write_stl(char *str)
|
||||
if (!during_script()) error("Can't write file");
|
||||
return;
|
||||
}
|
||||
strcpy(videosc_dir, str);
|
||||
strcpy(temp_dir, str);
|
||||
|
||||
waitcursor(1);
|
||||
|
||||
@ -2570,163 +1952,6 @@ void write_stl(char *str)
|
||||
waitcursor(0);
|
||||
}
|
||||
|
||||
static void write_videoscape_mesh(Object *ob, char *str)
|
||||
{
|
||||
EditMesh *em = G.editMesh;
|
||||
Mesh *me;
|
||||
Material *ma;
|
||||
MFace *mface;
|
||||
FILE *fp;
|
||||
EditVert *eve;
|
||||
EditFace *evl;
|
||||
unsigned int kleur[32];
|
||||
float co[3];
|
||||
int a;
|
||||
long tot;
|
||||
char *cp;
|
||||
|
||||
if(ob && ob->type==OB_MESH);
|
||||
else {
|
||||
return;
|
||||
}
|
||||
|
||||
kleur[0]= 0x00C0C0C0;
|
||||
|
||||
cp= (char *)kleur;
|
||||
for(a=0; a<ob->totcol; a++, cp+=4) {
|
||||
|
||||
ma= give_current_material(ob, a+1);
|
||||
if(ma) {
|
||||
cp[0]= (unsigned char) (255.0*ma->emit);
|
||||
cp[1]= (unsigned char) (255.0*ma->b);
|
||||
cp[2]= (unsigned char) (255.0*ma->g);
|
||||
cp[3]= (unsigned char) (255.0*ma->r);
|
||||
if(G.order==L_ENDIAN) SWITCH_INT(kleur[a]);
|
||||
}
|
||||
else kleur[a]= 0x00C0C0C0;
|
||||
|
||||
if(a>30) break;
|
||||
}
|
||||
|
||||
fp= fopen(str, "wb");
|
||||
if(fp==NULL) return;
|
||||
|
||||
fprintf(fp,"3DG1\n");
|
||||
|
||||
if(G.obedit) {
|
||||
|
||||
fprintf(fp, "%d\n", G.totvert);
|
||||
|
||||
tot= 0;
|
||||
eve= em->verts.first;
|
||||
while(eve) {
|
||||
VECCOPY(co, eve->co);
|
||||
Mat4MulVecfl(ob->obmat, co);
|
||||
fprintf(fp, "%f %f %f\n", co[0], co[1], co[2] );
|
||||
eve->tmp.l = tot;
|
||||
tot++;
|
||||
eve= eve->next;
|
||||
}
|
||||
evl= em->faces.first;
|
||||
while(evl) {
|
||||
|
||||
if(evl->v4==0) {
|
||||
fprintf(fp, "3 %ld %ld %ld 0x%x\n",
|
||||
evl->v1->tmp.l,
|
||||
evl->v2->tmp.l,
|
||||
evl->v3->tmp.l,
|
||||
kleur[evl->mat_nr]);
|
||||
}
|
||||
else {
|
||||
fprintf(fp, "4 %ld %ld %ld %ld 0x%x\n",
|
||||
evl->v1->tmp.l,
|
||||
evl->v2->tmp.l,
|
||||
evl->v3->tmp.l,
|
||||
evl->v4->tmp.l,
|
||||
kleur[evl->mat_nr]);
|
||||
}
|
||||
evl= evl->next;
|
||||
}
|
||||
}
|
||||
else {
|
||||
DerivedMesh *dm = mesh_get_derived_deform(ob, CD_MASK_BAREMESH);
|
||||
|
||||
me= ob->data;
|
||||
|
||||
fprintf(fp, "%d\n", me->totvert);
|
||||
|
||||
mface= me->mface;
|
||||
for(a=0; a<me->totvert; a++) {
|
||||
dm->getVertCo(dm, a, co);
|
||||
Mat4MulVecfl(ob->obmat, co);
|
||||
fprintf(fp, "%f %f %f\n", co[0], co[1], co[2] );
|
||||
}
|
||||
for(a=0; a<me->totface; a++, mface++) {
|
||||
if(mface->v4==0) {
|
||||
fprintf(fp, "3 %d %d %d 0x%x\n", mface->v1, mface->v2, mface->v3, kleur[mface->mat_nr]);
|
||||
}
|
||||
else {
|
||||
fprintf(fp, "4 %d %d %d %d 0x%x\n", mface->v1, mface->v2, mface->v3, mface->v4, kleur[mface->mat_nr]);
|
||||
}
|
||||
}
|
||||
|
||||
dm->release(dm);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void write_videoscape(char *str)
|
||||
{
|
||||
Base *base;
|
||||
int file, val, lampdone=0;
|
||||
unsigned short numlen;
|
||||
char head[FILE_MAXFILE], tail[FILE_MAXFILE];
|
||||
|
||||
if(BLI_testextensie(str,".trace")) str[ strlen(str)-6]= 0;
|
||||
if(BLI_testextensie(str,".blend")) str[ strlen(str)-6]= 0;
|
||||
if(BLI_testextensie(str,".ble")) str[ strlen(str)-4]= 0;
|
||||
if(BLI_testextensie(str,".obj")==0) strcat(str, ".obj");
|
||||
|
||||
file= open(str,O_BINARY|O_RDONLY);
|
||||
close(file);
|
||||
if(file>-1) if(!during_script() && saveover(str)==0) return;
|
||||
|
||||
strcpy(videosc_dir, str);
|
||||
|
||||
base= G.scene->base.first;
|
||||
while(base) {
|
||||
if((base->flag & SELECT) && (base->lay & G.scene->lay)) {
|
||||
if(base->object->type==OB_MESH) {
|
||||
write_videoscape_mesh(base->object, str);
|
||||
val = BLI_stringdec(str, head, tail, &numlen);
|
||||
BLI_stringenc(str, head, tail, numlen, val + 1);
|
||||
}
|
||||
else if(base->object->type==OB_CURVE || base->object->type==OB_SURF) {
|
||||
/* write_videoscape_nurbs(base->object, str); */
|
||||
/* val = stringdec(str, head, tail, &numlen); */
|
||||
/* stringenc(str, head, tail, numlen, val + 1); */
|
||||
}
|
||||
else if(lampdone==0 && base->object->type==OB_LAMP) {
|
||||
/* lampdone= 1; */
|
||||
/* write_videoscape_lamps(str); */
|
||||
/* val = stringdec(str, head, tail, &numlen); */
|
||||
/* stringenc(str, head, tail, numlen, val + 1); */
|
||||
}
|
||||
}
|
||||
base= base->next;
|
||||
}
|
||||
|
||||
|
||||
/* remove when higher numbers exist */
|
||||
while(remove(str)==0) {
|
||||
|
||||
val = BLI_stringdec(str, head, tail, &numlen);
|
||||
BLI_stringenc(str, head, tail, numlen, val + 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* ******************************* WRITE VRML ***************************** */
|
||||
|
||||
@ -3016,7 +2241,7 @@ void write_vrml(char *str)
|
||||
error("Can't write file");
|
||||
return;
|
||||
}
|
||||
strcpy(videosc_dir, str);
|
||||
strcpy(temp_dir, str);
|
||||
|
||||
waitcursor(1);
|
||||
|
||||
@ -3324,7 +2549,7 @@ void write_dxf(char *str)
|
||||
error("Can't write file");
|
||||
return;
|
||||
}
|
||||
strcpy(videosc_dir, str);
|
||||
strcpy(temp_dir, str);
|
||||
|
||||
waitcursor(1);
|
||||
|
||||
|
@ -60,7 +60,6 @@ void update_for_newframe_muted(void);
|
||||
void update_for_newframe_nodraw(int nosound);
|
||||
void free_matcopybuf(void);
|
||||
void clear_matcopybuf(void);
|
||||
void write_videoscape_fs(void);
|
||||
void write_vrml_fs(void);
|
||||
void write_dxf_fs(void);
|
||||
void write_stl_fs(void);
|
||||
|
@ -701,8 +701,6 @@ static PyObject *Blender_Save( PyObject * self, PyObject * args )
|
||||
write_stl( fname );
|
||||
else if( BLI_testextensie( fname, ".wrl" ) )
|
||||
write_vrml( fname );
|
||||
else if( BLI_testextensie( fname, ".obj" ) )
|
||||
write_videoscape( fname );
|
||||
else {
|
||||
disable_where_script( 0 );
|
||||
return EXPP_ReturnPyObjError( PyExc_AttributeError,
|
||||
|
@ -352,7 +352,7 @@ void rad_collect_meshes()
|
||||
if (!during_script()) error("No vertices");
|
||||
return;
|
||||
}
|
||||
vnc= RG.verts= MEM_callocN(RG.totvert*sizeof(VeNoCo), "readvideoscape1");
|
||||
vnc= RG.verts= MEM_callocN(RG.totvert*sizeof(VeNoCo), "radioverts");
|
||||
|
||||
RG.min[0]= RG.min[1]= RG.min[2]= 1.0e20f;
|
||||
RG.max[0]= RG.max[1]= RG.max[2]= -1.0e20f;
|
||||
|
@ -198,19 +198,7 @@ int progress_bar(float done, char *busy_info)
|
||||
}
|
||||
/* -- End of progress bar definitions ------- */
|
||||
|
||||
extern char videosc_dir[]; /* exotic.c */
|
||||
|
||||
void write_videoscape_fs()
|
||||
{
|
||||
if(G.obedit) {
|
||||
error("Can't save Videoscape. Press TAB to leave EditMode");
|
||||
}
|
||||
else {
|
||||
if(videosc_dir[0]==0) strcpy(videosc_dir, G.sce);
|
||||
activate_fileselect(FILE_SPECIAL, "Export Videoscape", videosc_dir,
|
||||
write_videoscape);
|
||||
}
|
||||
}
|
||||
extern char temp_dir[]; /* exotic.c */
|
||||
|
||||
void write_vrml_fs()
|
||||
{
|
||||
@ -218,9 +206,9 @@ void write_vrml_fs()
|
||||
error("Can't save VRML. Press TAB to leave EditMode");
|
||||
}
|
||||
else {
|
||||
if(videosc_dir[0]==0) strcpy(videosc_dir, G.sce);
|
||||
if(temp_dir[0]==0) strcpy(temp_dir, G.sce);
|
||||
|
||||
activate_fileselect(FILE_SPECIAL, "Export VRML 1.0", videosc_dir, write_vrml);
|
||||
activate_fileselect(FILE_SPECIAL, "Export VRML 1.0", temp_dir, write_vrml);
|
||||
}
|
||||
}
|
||||
|
||||
@ -231,9 +219,9 @@ void write_dxf_fs()
|
||||
}
|
||||
else {
|
||||
|
||||
if(videosc_dir[0]==0) strcpy(videosc_dir, G.sce);
|
||||
if(temp_dir[0]==0) strcpy(temp_dir, G.sce);
|
||||
|
||||
activate_fileselect(FILE_SPECIAL, "Export DXF", videosc_dir, write_dxf);
|
||||
activate_fileselect(FILE_SPECIAL, "Export DXF", temp_dir, write_dxf);
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,9 +232,9 @@ void write_stl_fs()
|
||||
}
|
||||
else {
|
||||
|
||||
if(videosc_dir[0]==0) strcpy(videosc_dir, G.sce);
|
||||
if(temp_dir[0]==0) strcpy(temp_dir, G.sce);
|
||||
|
||||
activate_fileselect(FILE_SPECIAL, "Export STL", videosc_dir, write_stl);
|
||||
activate_fileselect(FILE_SPECIAL, "Export STL", temp_dir, write_stl);
|
||||
}
|
||||
}
|
||||
/* ------------ */
|
||||
@ -608,9 +596,9 @@ static void do_info_file_importmenu(void *arg, int event)
|
||||
areawinset(sa->win);
|
||||
}
|
||||
|
||||
/* events >=4 are registered bpython scripts */
|
||||
if (event >= 4) {
|
||||
BPY_menu_do_python(PYMENU_IMPORT, event - 4);
|
||||
/* events >=3 are registered bpython scripts */
|
||||
if (event >= 3) {
|
||||
BPY_menu_do_python(PYMENU_IMPORT, event - 3);
|
||||
BIF_undo_push("Import file");
|
||||
}
|
||||
else {
|
||||
@ -622,10 +610,7 @@ static void do_info_file_importmenu(void *arg, int event)
|
||||
case 1: /* VRML 1.0 */
|
||||
activate_fileselect(FILE_BLENDER, "Import VRML 1.0", G.sce, BIF_read_file);
|
||||
break;
|
||||
case 2: /* VideoScape */
|
||||
activate_fileselect(FILE_BLENDER, "Import VideoScape", G.sce, BIF_read_file);
|
||||
break;
|
||||
case 3: /* STL */
|
||||
case 2: /* STL */
|
||||
activate_fileselect(FILE_BLENDER, "Import STL", G.sce, BIF_read_file);
|
||||
break;
|
||||
|
||||
@ -649,10 +634,8 @@ static uiBlock *info_file_importmenu(void *arg_unused)
|
||||
0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 1, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "DXF...",
|
||||
0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 0, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "VideoScape...",
|
||||
0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 2, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "STL...",
|
||||
0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 3, "");
|
||||
0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 2, "");
|
||||
|
||||
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||
|
||||
@ -676,8 +659,8 @@ static void do_info_file_exportmenu(void *arg, int event)
|
||||
areawinset(sa->win);
|
||||
}
|
||||
|
||||
/* events >=4 are registered bpython scripts */
|
||||
if (event >= 4) BPY_menu_do_python(PYMENU_EXPORT, event - 4);
|
||||
/* events >=3 are registered bpython scripts */
|
||||
if (event >= 3) BPY_menu_do_python(PYMENU_EXPORT, event - 3);
|
||||
|
||||
else switch(event) {
|
||||
|
||||
@ -688,9 +671,6 @@ static void do_info_file_exportmenu(void *arg, int event)
|
||||
write_dxf_fs();
|
||||
break;
|
||||
case 2:
|
||||
write_videoscape_fs();
|
||||
break;
|
||||
case 3:
|
||||
write_stl_fs();
|
||||
break;
|
||||
}
|
||||
@ -712,17 +692,15 @@ static uiBlock *info_file_exportmenu(void *arg_unused)
|
||||
0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 0, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "DXF...|Shift F2",
|
||||
0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 1, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Videoscape...|Alt W",
|
||||
0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 2, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "STL...",
|
||||
0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 3, "");
|
||||
0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 2, "");
|
||||
|
||||
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||
|
||||
/* note that we acount for the 3 previous entries with i+3: */
|
||||
for (pym = BPyMenuTable[PYMENU_EXPORT]; pym; pym = pym->next, i++) {
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20, menuwidth, 19,
|
||||
NULL, 0.0, 0.0, 1, i+4,
|
||||
NULL, 0.0, 0.0, 1, i+3,
|
||||
pym->tooltip?pym->tooltip:pym->filename);
|
||||
}
|
||||
|
||||
|
@ -873,10 +873,7 @@ int blenderqread(unsigned short event, short val)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else if(G.qual==LR_ALTKEY) {
|
||||
write_videoscape_fs();
|
||||
return 0;
|
||||
}
|
||||
/* python specials here? */
|
||||
}
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user