5 |
|
.vs 12 |
6 |
|
.nr PD .5v |
7 |
|
.ds LF MGF |
8 |
< |
.ds RF Version 1.0 |
9 |
< |
.DA May 1995 |
8 |
> |
.ds RF Version 1.1 |
9 |
> |
.\" !Remember to update date on each modification! |
10 |
> |
.DA February 1996 |
11 |
|
.TL |
12 |
|
The Materials and Geometry Format |
13 |
|
.AU |
43 |
|
"http://radsite.lbl.gov/mgf/HOME.html". |
44 |
|
.RE |
45 |
|
.LP |
46 |
< |
The standard parser provides both immediate and a long-term |
46 |
> |
The standard parser provides both immediate and long-term |
47 |
|
benefits, since it presents a programming interface that is more |
48 |
|
stable even than the language itself. |
49 |
|
Unlike AutoCAD DXF and other de facto standards, a change to the |
233 |
|
n dx dy dz set surface normal for current vertex |
234 |
|
_ _ _ |
235 |
|
f v1 v2 v3 ... polygon using current material, spec. vertices |
236 |
+ |
fh v1 v2 v3 - ... face with explicit holes |
237 |
|
sph vc radius sphere |
238 |
|
cyl v1 radius v2 truncated right cylinder (open-ended) |
239 |
|
cone v1 rad1 v2 rad2 truncated right cone (open-ended) |
279 |
|
= = = = = |
280 |
|
Object o - - - |
281 |
|
Transform xf - - T{ |
282 |
< |
f, sph, cyl, cone, |
282 |
> |
f, fh, sph, cyl, cone, |
283 |
|
ring, torus, prism |
284 |
|
T} |
285 |
|
Material m 2-sided black T{ |
286 |
|
sides, rd, td, |
287 |
< |
ed, rs, ts |
287 |
> |
ed, rs, ts, ir |
288 |
|
T} T{ |
289 |
< |
f, sph, cyl, cone, |
289 |
> |
f, fh, sph, cyl, cone, |
290 |
|
ring, torus, prism |
291 |
|
T} |
292 |
|
Color c neutral grey T{ |
298 |
|
(0,0,0), |
299 |
|
no normal |
300 |
|
T} p, n T{ |
301 |
< |
f, sph, cyl, cone, |
301 |
> |
f, fh, sph, cyl, cone, |
302 |
|
ring, torus, prism |
303 |
|
T} |
304 |
|
.TE |
748 |
|
o |
749 |
|
o |
750 |
|
|
749 |
– |
i cubfurn.inc -mx -t 405 133.5 0 |
750 |
– |
o |
751 |
– |
|
751 |
|
# Six file cabinets (36" wide each) |
752 |
|
# ("filecab.inc" was given as an earlier example in Section 1.2) |
753 |
|
o filecab.x |
817 |
|
.TS |
818 |
|
lw(.75i) lw(1.75i) lw(3i). |
819 |
|
f v1 v2 v3 ... polygon using current material, spec. vertices |
820 |
+ |
fh v1 v2 v3 - ... face with explicit holes |
821 |
|
sph vc radius sphere |
822 |
|
cyl v1 radius v2 truncated right cylinder (open-ended) |
823 |
|
cone v1 rad1 v2 rad2 truncated right cone (open-ended) |
1269 |
|
Values in between are separated by |
1270 |
|
.I "(l_max-l_min)/(N-1)" |
1271 |
|
nanometers. |
1272 |
< |
All values must be non-negative, and the spectrum outside of the |
1272 |
> |
All values should be non-negative unless defining a component for |
1273 |
> |
complementary color mixing, and the spectrum outside of the |
1274 |
|
specified range is assumed to be zero. |
1275 |
|
(The visible range is 380 to 780 nm.)\0 |
1276 |
|
The actual units and scale of the measurements do not matter, |
1677 |
|
# A 100-watt incandescent bulb (1600 lumens) modeled as a sphere |
1678 |
|
m |
1679 |
|
c |
1680 |
< |
cct 3000 |
1680 |
> |
cct 3000 |
1681 |
|
ed 87712 |
1682 |
|
v cent = |
1683 |
|
p 0 0 0 |
2071 |
|
Also, specified normals should point in the general direction of the |
2072 |
|
surface for best results. |
2073 |
|
.LP |
2074 |
< |
There is no explicit representation of holes in MGF. A hole must be |
2075 |
< |
represented implicitly by connecting vertices to form "seams." For |
2074 |
> |
There is no explicit representation of holes in this entity, but see |
2075 |
> |
the |
2076 |
> |
.UL fh |
2077 |
> |
entity for an alternative specification. |
2078 |
> |
.LP |
2079 |
> |
A hole may be represented implicitly in a face entity |
2080 |
> |
by connecting vertices to form "seams." |
2081 |
> |
For |
2082 |
|
example, a wall with a window in it might look as shown in Figure 1. |
2083 |
|
In many systems, the wall itself would be represented with the first |
2084 |
|
list of vertices, (v1,v2,v3,v4) and the hole associated with that |
2085 |
< |
wall as a second set of vertices (v5,v6,v7,v8). In MGF, we must |
2085 |
> |
wall as a second set of vertices (v5,v6,v7,v8). |
2086 |
> |
Using the face entity, we must |
2087 |
|
give the whole thing as a single polygon, connecting the vertices so |
2088 |
|
as to create a "seam," as shown in Figure 2. |
2089 |
< |
This could be written in MGF as "f v1 v2 v3 v4 v5 v6 v7 v8 v5 v4". |
2089 |
> |
This could be written as "f v1 v2 v3 v4 v5 v6 v7 v8 v5 v4". |
2090 |
|
.LP |
2091 |
|
It is very important that the order of the hole be opposite to the |
2092 |
|
order of the outer perimeter, otherwise the polygon will be |
2135 |
|
.LP |
2136 |
|
.UL cone, |
2137 |
|
.UL cyl, |
2138 |
+ |
.UL fh, |
2139 |
|
.UL m, |
2140 |
|
.UL prism, |
2141 |
|
.UL ring, |
2142 |
|
.UL sph, |
2143 |
|
.UL torus, |
2144 |
|
.UL v |
2145 |
+ |
.ds RH FH |
2146 |
+ |
.bp |
2147 |
+ |
.SH |
2148 |
+ |
NAME |
2149 |
+ |
.LP |
2150 |
+ |
fh - create a polygonal face with explicit holes |
2151 |
+ |
.SH |
2152 |
+ |
SYNOPSIS |
2153 |
+ |
.LP |
2154 |
+ |
.B fh |
2155 |
+ |
.I "p1 p2 ... - h1.1 h1.2 ... - h2.1 h2.2 ..." |
2156 |
+ |
.SH |
2157 |
+ |
DESCRIPTION |
2158 |
+ |
.LP |
2159 |
+ |
Create a polygonal face with optional holes made of the current material. |
2160 |
+ |
The first contour is the outer perimeter, with vertices given in |
2161 |
+ |
counter-clockwise order as seen from the front side (the same as the |
2162 |
+ |
.UL f |
2163 |
+ |
entity). |
2164 |
+ |
A hole is indicated by a hyphen ('-') followed by the hole's |
2165 |
+ |
vertices, given in clockwise order as seen from the front side. |
2166 |
+ |
Multiple hole contours are separated by additional hyphens. |
2167 |
+ |
There must be at least three vertices for each contour, and the |
2168 |
+ |
last vertex is implicitly connected to the first. |
2169 |
+ |
If any vertex is undefined, an error will result. |
2170 |
+ |
.LP |
2171 |
+ |
If any vertices have associated surface normals, they will be used |
2172 |
+ |
instead of the average plane normal, though it is safest to specify |
2173 |
+ |
either all normals or no normals, and to stick with triangles |
2174 |
+ |
when normals are used. |
2175 |
+ |
Also, specified normals should point in the general direction of the |
2176 |
+ |
surface for best results. |
2177 |
+ |
.SH |
2178 |
+ |
EXAMPLE |
2179 |
+ |
.DS |
2180 |
+ |
# Make a wall with a window using an explicit hole. |
2181 |
+ |
# (See Figures 1 and 2.) |
2182 |
+ |
fh v1 v2 v3 v4 - v5 v6 v7 v8 |
2183 |
+ |
.DE |
2184 |
+ |
.SH |
2185 |
+ |
SEE ALSO |
2186 |
+ |
.LP |
2187 |
+ |
.UL cone, |
2188 |
+ |
.UL cyl, |
2189 |
+ |
.UL f, |
2190 |
+ |
.UL m, |
2191 |
+ |
.UL prism, |
2192 |
+ |
.UL ring, |
2193 |
+ |
.UL sph, |
2194 |
+ |
.UL torus, |
2195 |
+ |
.UL v |
2196 |
|
.ds RH SPH |
2197 |
|
.bp |
2198 |
|
.SH |
2288 |
|
p 0 0 .005 |
2289 |
|
v vend = |
2290 |
|
p 0 0 .05 |
2291 |
< |
cyl vtip1 .0015 |
2291 |
> |
cyl vtip1 .0015 vend |
2292 |
|
sph vend .0015 |
2293 |
|
cone vtip0 0 vtip1 .0015 |
2294 |
|
o |
2450 |
|
.SH |
2451 |
|
SYNOPSIS |
2452 |
|
.LP |
2453 |
< |
.B cyl |
2453 |
> |
.B ring |
2454 |
|
.I "vc rmin rmax" |
2455 |
|
.SH |
2456 |
|
DESCRIPTION |
2563 |
|
.NH |
2564 |
|
MGF Translators |
2565 |
|
.LP |
2566 |
< |
Initially, there are four translators for MGF data, but only |
2567 |
< |
one of these is distributed with the MGF parser itself, |
2568 |
< |
.I mgfilt. |
2566 |
> |
Initially, there are six translators for MGF data, and |
2567 |
> |
three of these are distributed with the MGF parser itself, |
2568 |
> |
.I mgfilt, |
2569 |
> |
.I mgf2inv |
2570 |
> |
and |
2571 |
> |
.I 3ds2mgf. |
2572 |
|
Two of the other translators, |
2573 |
|
.I mgf2rad |
2574 |
|
and |
2581 |
|
nestor.epfl.ch, or by WWW from |
2582 |
|
"http://radsite.lbl.gov/radiance/HOME.html" |
2583 |
|
.FE |
2584 |
< |
A third translator, |
2584 |
> |
The sixth translator, |
2585 |
|
.I mgf2meta, |
2586 |
|
converts to a 2-dimensional line plot, and is also |
2587 |
|
distributed with Radiance. |
2598 |
|
In future releases of MGF, this utility will also be handy for |
2599 |
|
taking new entities and producing older versions of MGF for |
2600 |
|
translators that have not yet been updated properly. |
2601 |
+ |
.LP |
2602 |
+ |
Mgf2inv converts from MGF to Inventor or VRML format. |
2603 |
+ |
Some information is lost, because these formats do not support |
2604 |
+ |
physical light sources or materials. |
2605 |
+ |
.LP |
2606 |
+ |
3ds2mgf converts from 3D Studio binary format to MGF. |
2607 |
+ |
Care must be taken to correct for errors in the material descriptions, |
2608 |
+ |
since 3D Studio is completely non-physical. |
2609 |
|
.ds LH Translators |
2610 |
|
.ds RH MGFILT |
2611 |
|
.bp |
2640 |
|
of MGF that is to be produced. |
2641 |
|
Since MGF is in its first major release, this is not yet a useful |
2642 |
|
form, but it will be when the second major release comes out. |
2643 |
+ |
This has the necessary side-effect of expanding all included files. |
2644 |
+ |
(See the |
2645 |
+ |
.UL i |
2646 |
+ |
entity.)\0 |
2647 |
|
.LP |
2648 |
|
In the second form, |
2649 |
|
.I mgfilt |
2668 |
|
.SH |
2669 |
|
SEE ALSO |
2670 |
|
.LP |
2671 |
< |
mgf2rad, rad2mgf |
2671 |
> |
i, mgf2inv, mgf2rad, rad2mgf |
2672 |
> |
.ds RH MGF2INV |
2673 |
> |
.bp |
2674 |
> |
.SH |
2675 |
> |
NAME |
2676 |
> |
.LP |
2677 |
> |
mgf2inv - convert from MGF to Inventor or VRML format |
2678 |
> |
.SH |
2679 |
> |
SYNOPSIS |
2680 |
> |
.LP |
2681 |
> |
.B mgf2inv |
2682 |
> |
[ |
2683 |
> |
.B "-1|-2|-vrml" |
2684 |
> |
] |
2685 |
> |
[ |
2686 |
> |
.B input .. |
2687 |
> |
] |
2688 |
> |
.SH |
2689 |
> |
DESCRIPTION |
2690 |
> |
.LP |
2691 |
> |
.I Mgf2inv |
2692 |
> |
takes one or more MGF input files and converts it to |
2693 |
> |
Inventor or VRML format. |
2694 |
> |
If the |
2695 |
> |
.I \-1 |
2696 |
> |
option is used, then Inventor 1.0 ASCII output is produced. |
2697 |
> |
If the |
2698 |
> |
.I \-2 |
2699 |
> |
option is used, then Inventor 2.0 ASCII output is produced. |
2700 |
> |
(This is the default.)\0 |
2701 |
> |
If the |
2702 |
> |
.I \-vrml |
2703 |
> |
option is used, then VRML 1.0 ASCII output is produced. |
2704 |
> |
.LP |
2705 |
> |
This converter does not work properly for light sources, since |
2706 |
> |
the output formats do not support IES-type luminaires with recorded |
2707 |
> |
distributions. |
2708 |
> |
Also, some material information may be lost because Inventor lacks |
2709 |
> |
a physically valid reflectance model. |
2710 |
> |
.SH |
2711 |
> |
EXAMPLES |
2712 |
> |
.LP |
2713 |
> |
To take an MGF file and convert it to VRML format: |
2714 |
> |
.IP |
2715 |
> |
mgf2inv -vrml myscene.mgf > myscene.iv |
2716 |
> |
.SH |
2717 |
> |
SEE ALSO |
2718 |
> |
.LP |
2719 |
> |
mgf2rad(1), mgfilt(1), 3ds2mgf(1), rad2mgf(1) |
2720 |
> |
.ds RH 3DS2MGF |
2721 |
> |
.bp |
2722 |
> |
.SH |
2723 |
> |
NAME |
2724 |
> |
.LP |
2725 |
> |
3ds2mgf - convert 3D Studio binary file to Materials and Geometry Format |
2726 |
> |
.SH |
2727 |
> |
SYNOPSIS |
2728 |
> |
.LP |
2729 |
> |
.B 3ds2mgf |
2730 |
> |
.B input |
2731 |
> |
[ |
2732 |
> |
.B output |
2733 |
> |
] |
2734 |
> |
[ |
2735 |
> |
.B -lMatlib |
2736 |
> |
][ |
2737 |
> |
.B -xObjname |
2738 |
> |
][ |
2739 |
> |
.B -sAngle |
2740 |
> |
][ |
2741 |
> |
.B -aAnimfile |
2742 |
> |
][ |
2743 |
> |
.B -fN |
2744 |
> |
] |
2745 |
> |
.SH |
2746 |
> |
DESCRIPTION |
2747 |
> |
.LP |
2748 |
> |
.I 3ds2mgf |
2749 |
> |
converts a 3D Studio binary scene description |
2750 |
> |
to the Materials and Geometry Format (MGF). |
2751 |
> |
If no output file name is given, the input root name |
2752 |
> |
will be taken as the output root, and an "mgf" extension |
2753 |
> |
will be added. |
2754 |
> |
This file will contain any light sources and materials, and an include |
2755 |
> |
statement for a similarly named file ending in "inc", which will contain |
2756 |
> |
the MGF geometry of all the translated 3DS meshes. |
2757 |
> |
.LP |
2758 |
> |
The MGF material names and properties |
2759 |
> |
for the surfaces will be those assigned in 3D Studio, |
2760 |
> |
unless they are named in one or more MGF material libraries given in a |
2761 |
> |
.I -l |
2762 |
> |
option. |
2763 |
> |
.LP |
2764 |
> |
The |
2765 |
> |
.I -x |
2766 |
> |
option may be used to exclude a named object from the output. |
2767 |
> |
.LP |
2768 |
> |
The |
2769 |
> |
.I -s |
2770 |
> |
option may be used to adjust automatic mesh smoothing such that adjacent |
2771 |
> |
triangle faces with less than the given angle between them (in degrees) |
2772 |
> |
will be smoothed. |
2773 |
> |
A value of zero turns smoothing off. |
2774 |
> |
The default value is 60 degrees. |
2775 |
> |
.LP |
2776 |
> |
The |
2777 |
> |
.I -a |
2778 |
> |
option may be used to specify a 3D Studio animation file, and together with the |
2779 |
> |
.I -f |
2780 |
> |
option, |
2781 |
> |
.I 3ds2mgf |
2782 |
> |
will generate a scene description for the specified frame. |
2783 |
> |
.LP |
2784 |
> |
Note that there are no spaces between the options and their arguments. |
2785 |
> |
.SH |
2786 |
> |
LIMITATIONS |
2787 |
> |
.LP |
2788 |
> |
Obviously, since 3D Studio has no notion of physical materials, the |
2789 |
> |
translation to MGF material descriptions is very ad hoc, and it will |
2790 |
> |
usually be necessary to edit the materials and light sources in |
2791 |
> |
the output file or replace materials with proper entries from a material |
2792 |
> |
library using the |
2793 |
> |
.I -l |
2794 |
> |
option. |
2795 |
> |
.LP |
2796 |
> |
With smoothing turned on (i.e., a non-zero value for the |
2797 |
> |
.I -s |
2798 |
> |
option), vertices in the MGF output will not be linked in a proper |
2799 |
> |
mesh for each object. |
2800 |
> |
This is due to the way the automatic smoothing code was originally |
2801 |
> |
written, and is too difficult to repair. |
2802 |
> |
If a good mesh is needed, then smoothing must be turned off. |
2803 |
> |
.SH |
2804 |
> |
EXAMPLES |
2805 |
> |
.LP |
2806 |
> |
To convert a 3D Studio robot model to MGF without smoothing. |
2807 |
> |
(Output will be put into "robot.mgf" and "robot.inc".) |
2808 |
> |
.IP |
2809 |
> |
3ds2mgf robot.3ds -s0 |
2810 |
> |
.LP |
2811 |
> |
To convert a DC10 jet model to MGF using a hand-created material library: |
2812 |
> |
.IP |
2813 |
> |
3ds2mgf dc10.3ds -ldc10mat.mgf |
2814 |
> |
.SH |
2815 |
> |
AUTHORS |
2816 |
> |
.LP |
2817 |
> |
Steve Anger, Jeff Bowermaster and Greg Ward |
2818 |
> |
.br |
2819 |
> |
Extended from 3ds2pov 1.8. |
2820 |
> |
.SH |
2821 |
> |
SEE ALSO |
2822 |
> |
.LP |
2823 |
> |
mgf2inv(1), mgf2meta(1), mgf2rad(1) |
2824 |
|
.ds RH MGF2RAD |
2825 |
|
.bp |
2826 |
|
.SH |
3350 |
|
#define MG_E_CMIX 4 /* cmix */ |
3351 |
|
#define MG_E_CSPEC 5 /* cspec */ |
3352 |
|
#define MG_E_CXY 6 /* cxy */ |
3353 |
< |
#define MG_E_CYL 7 /* cyl */ |
3353 |
> |
#define MG_E_CYL 7 /* cyl */ |
3354 |
|
#define MG_E_ED 8 /* ed */ |
3355 |
|
#define MG_E_FACE 9 /* f */ |
3356 |
|
#define MG_E_INCLUDE 10 /* i */ |
3502 |
|
#define MG_EMEM 8 /* out of memory */ |
3503 |
|
#define MG_ESEEK 9 /* file seek error */ |
3504 |
|
#define MG_EBADMAT 10 /* bad material specification */ |
3505 |
+ |
#define MG_ELINE 11 /* input line too long */ |
3506 |
+ |
#define MG_ECNTXT 12 /* unmatched context close */ |
3507 |
|
|
3508 |
< |
#define MG_NERRS 11 |
3508 |
> |
#define MG_NERRS 13 |
3509 |
|
.DE |
3510 |
|
If it is inappropriate to send output to standard error, the calling |
3511 |
|
program should use the routines listed under |
3519 |
|
.SH |
3520 |
|
SEE ALSO |
3521 |
|
.LP |
3522 |
< |
mg_fgetpos, mg_handle, mg_init |
3522 |
> |
mg_fgetpos, mg_handle, mg_init, mg_open |
3523 |
|
.ds RH MG_OPEN |
3524 |
|
.bp |
3525 |
|
.SH |
3589 |
|
function reads the next input line from the current file, |
3590 |
|
returning the number of characters in the line, or zero if the |
3591 |
|
end of file is reached or there is a file error. |
3592 |
< |
The function skips over escaped newlines, and keeps track of the |
3592 |
> |
If the value returned equals MG_MAXLINE-1, |
3593 |
> |
then the input line was too long, and you |
3594 |
> |
should return an MG_ELINE error. |
3595 |
> |
The function keeps track of the |
3596 |
|
line number in the current file context |
3597 |
|
.I mg_file, |
3598 |
|
which also contains the line that was read. |
3928 |
|
transform has not changed, which is uniquely identified by the |
3929 |
|
global |
3930 |
|
.I xf_context->xid |
3931 |
< |
variable, but only if one is using the parser libraries transform |
3931 |
> |
variable, but only if one is using the parser library's transform |
3932 |
|
handler. |
3933 |
|
(See the |
3934 |
|
.I xf_handler |
4659 |
|
The hardest part is translating the specular power to a roughness value. |
4660 |
|
For this, we recommend the following approximation: |
4661 |
|
.IP |
4662 |
< |
roughness = 0.6/sqrt(specular_power) |
4662 |
> |
roughness = sqrt(2/specular_power) |
4663 |
|
.LP |
4664 |
|
It is not a perfect correlation, but it is about as close as one can get. |
4665 |
|
.NH 3 |
4721 |
|
#define CIE_y_w 0.3333 |
4722 |
|
#endif |
4723 |
|
|
4724 |
< |
#define CIE_D ( CIE_x_r*(CIE_y_g - CIE_y_b) + \\\\ |
4725 |
< |
CIE_x_g*(CIE_y_b - CIE_y_r) + \\\\ |
4724 |
> |
#define CIE_D ( CIE_x_r*(CIE_y_g - CIE_y_b) + \\ |
4725 |
> |
CIE_x_g*(CIE_y_b - CIE_y_r) + \\ |
4726 |
|
CIE_x_b*(CIE_y_r - CIE_y_g) ) |
4727 |
< |
#define CIE_C_rD ( (1./CIE_y_w) * \\\\ |
4728 |
< |
( CIE_x_w*(CIE_y_g - CIE_y_b) - \\\\ |
4729 |
< |
CIE_y_w*(CIE_x_g - CIE_x_b) + \\\\ |
4727 |
> |
#define CIE_C_rD ( (1./CIE_y_w) * \\ |
4728 |
> |
( CIE_x_w*(CIE_y_g - CIE_y_b) - \\ |
4729 |
> |
CIE_y_w*(CIE_x_g - CIE_x_b) + \\ |
4730 |
|
CIE_x_g*CIE_y_b - CIE_x_b*CIE_y_g ) ) |
4731 |
< |
#define CIE_C_gD ( (1./CIE_y_w) * \\\\ |
4732 |
< |
( CIE_x_w*(CIE_y_b - CIE_y_r) - \\\\ |
4733 |
< |
CIE_y_w*(CIE_x_b - CIE_x_r) - \\\\ |
4731 |
> |
#define CIE_C_gD ( (1./CIE_y_w) * \\ |
4732 |
> |
( CIE_x_w*(CIE_y_b - CIE_y_r) - \\ |
4733 |
> |
CIE_y_w*(CIE_x_b - CIE_x_r) - \\ |
4734 |
|
CIE_x_r*CIE_y_b + CIE_x_b*CIE_y_r ) ) |
4735 |
< |
#define CIE_C_bD ( (1./CIE_y_w) * \\\\ |
4736 |
< |
( CIE_x_w*(CIE_y_r - CIE_y_g) - \\\\ |
4737 |
< |
CIE_y_w*(CIE_x_r - CIE_x_g) + \\\\ |
4735 |
> |
#define CIE_C_bD ( (1./CIE_y_w) * \\ |
4736 |
> |
( CIE_x_w*(CIE_y_r - CIE_y_g) - \\ |
4737 |
> |
CIE_y_w*(CIE_x_r - CIE_x_g) + \\ |
4738 |
|
CIE_x_r*CIE_y_g - CIE_x_g*CIE_y_r ) ) |
4739 |
|
|
4740 |
|
#define CIE_rf (CIE_y_r*CIE_C_rD/CIE_D) |