ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/ot/obj2mesh.c
(Generate patch)

Comparing ray/src/ot/obj2mesh.c (file contents):
Revision 2.1 by greg, Tue Mar 11 17:08:55 2003 UTC vs.
Revision 2.5 by schorsch, Thu Jun 5 19:29:34 2003 UTC

# Line 31 | Line 31 | main(argc, argv)               /* compile a .OBJ file into a mesh *
31   int  argc;
32   char  *argv[];
33   {
34 <        int  i;
34 >        int  nmatf = 0;
35 >        char  *matinp[32];
36 >        int  i, j;
37  
38          progname = argv[0];
39          ofun[OBJ_FACE].funp = o_face;
# Line 44 | Line 46 | char  *argv[];
46                  case 'r':                               /* resolution limit */
47                          resolu = atoi(argv[++i]);
48                          break;
49 +                case 'a':                               /* material file */
50 +                        matinp[nmatf++] = argv[++i];
51 +                        break;
52                  case 'w':                               /* supress warnings */
53                          nowarn = 1;
54                          break;
# Line 54 | Line 59 | char  *argv[];
59                  }
60                                          /* initialize mesh */
61          cvinit(i==argc-2 ? argv[i+1] : "<stdout>");
62 <
63 <        if (i == argc)                  /* read .OBJ file into triangles */
62 >                                        /* load material input */
63 >        for (j = 0; j < nmatf; j++)
64 >                readobj(matinp[j]);
65 >                                        /* read .OBJ file into triangles */
66 >        if (i == argc)
67                  wfreadobj(NULL);
68          else
69                  wfreadobj(argv[i]);
# Line 65 | Line 73 | char  *argv[];
73          if (i == argc-2)                /* open output file */
74                  if (freopen(argv[i+1], "w", stdout) == NULL)
75                          error(SYSTEM, "cannot open output file");
76 < #ifdef MSDOS
69 <        setmode(fileno(stdout), O_BINARY);
70 < #endif
76 >        SET_FILE_BINARY(stdout);
77          newheader("RADIANCE", stdout);  /* new binary file header */
78          printargs(i<argc ? i+1 : argc, argv, stdout);
79          fputformat(MESHFMT, stdout);
# Line 76 | Line 82 | char  *argv[];
82          mincusize = ourmesh->mcube.cusize / resolu - FTINY;
83  
84          for (i = 0; i < nobjects; i++)  /* add triangles to octree */
85 <                addface(&ourmesh->mcube, i);
85 >                if (objptr(i)->otype == OBJ_FACE)
86 >                        addface(&ourmesh->mcube, i);
87  
88                                          /* optimize octree */
89          ourmesh->mcube.cutree = combine(ourmesh->mcube.cutree);
# Line 88 | Line 95 | char  *argv[];
95  
96          writemesh(ourmesh, stdout);     /* write mesh to output */
97          
98 < printmeshstats(ourmesh, stderr);
98 >        /* printmeshstats(ourmesh, stderr); */
99  
100          quit(0);
101   }
# Line 138 | Line 145 | addface(cu, obj)                       /* add a face to a cube */
145   register CUBE  *cu;
146   OBJECT  obj;
147   {
141        CUBE  cukid;
142        OCTREE  ot;
143        OBJECT  oset[MAXSET+1];
144        register int  i, j;
148  
149          if (o_face(objptr(obj), cu) == O_MISS)
150                  return;
151  
152          if (istree(cu->cutree)) {
153 <                                                /* do children */
153 >                CUBE  cukid;                    /* do children */
154 >                int  i, j;
155                  cukid.cusize = cu->cusize * 0.5;
156                  for (i = 0; i < 8; i++) {
157                          cukid.cutree = octkid(cu->cutree, i);
# Line 162 | Line 166 | OBJECT obj;
166                  return;
167          }
168          if (isempty(cu->cutree)) {
169 <                                                /* singular set */
169 >                OBJECT  oset[2];                /* singular set */
170                  oset[0] = 1; oset[1] = obj;
171                  cu->cutree = fullnode(oset);
172                  return;
173          }
174                                          /* add to full node */
175 +        add2full(cu, obj);
176 + }
177 +
178 +
179 + add2full(cu, obj)                       /* add object to full node */
180 + register CUBE  *cu;
181 + OBJECT  obj;
182 + {
183 +        OCTREE  ot;
184 +        OBJECT  oset[MAXSET+1];
185 +        CUBE  cukid;
186 +        register int  i, j;
187 +
188          objset(oset, cu->cutree);
189          cukid.cusize = cu->cusize * 0.5;
190  
191          if (oset[0] < objlim || cukid.cusize < mincusize) {
192                                                  /* add to set */
193                  if (oset[0] >= MAXSET) {
194 <                        sprintf(errmsg, "set overflow in addface (%s)",
194 >                        sprintf(errmsg, "set overflow in addobject (%s)",
195                                          objptr(obj)->oname);
196                          error(INTERNAL, errmsg);
197                  }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines