Pro/ENGINEER Tips/Hints
Last modified: 3/29/97
#1 - Using POV-Ray to Render Pro/ENGINEER Models
I first became aware of POV-Ray
while reading a Pro/E Magazine article in late 1995. I immediately tried
to use POV-Ray to render Pro/E models myself. There was only one problem,
how was I going to convert the Pro/E data to POV-Ray format like the article
talked about? I did not have the time to write such a program. It didn't
take long until I hooked up with Bruce Bodnyk on the Pro/E newsgroup and
he told me that he had written a converter called SLP2POV.
So I downloaded a copy and off I went. Until recently, the converted data,
in POV-Ray .inc format, had to be edited if you wanted the colors in Pro/E
to "map" automatically to textures in POV-Ray. With the addition
of the SLP2POV "-T option", it is now possible to render
a complete Pro/E part or assembly without having to edit the POV-Ray include
(.inc) file
Below is a description of how to use POV-Ray to render Pro/ENGINEER
Models, with emphasis on using the -T option.
1. The first step to converting Pro/E data to POV-Ray is
to create a render file in Pro/E. Here is my mapkey for starting the render
file export command:
mapkey slp #interface;#export;#Render
If you are in part mode when you do this, all you need
to do is set the chord height. If you are in assembly mode you have two
options, one is to render the whole assembly, the other is to render only
selected parts in the assembly. To select everything in the assembly, select
#Exclude;#Done-Select, this will select everything. To select parts individually,
use #Include. Next, set the desired chord height. Pick #Output, select
the desired coordinate system and type in the desired output filename.
The render file that you created will be in your working directory and
has a .slp extension. Thats it!
Render files represent the surfaces of the solid model with
LOTS of small polygons. These polygons also have normal vectors and colors
associated with them. The format required by POV-Ray contains the same
information, but formatted differently. The program SLP2POV is what you
will need to do the conversion.
Here is the description provided in the SLP2POV documentation:
DESCRIPTION slp2pov translates a Pro/ENGINEER .slp file in "Render" format to a .inc file for use with POV-Ray where the .inc file has the same base name as the .slp file. The program creates a single POV-Ray object whose name is the base name of the input file converted to upper case. The file generated contains "declare" definitions for all colors in the render file making it easy to adjust the color of an object.......
At this point I am going to discuss using the -T option/method,
the SLP2POV documentation describes the other options/methods. The -T option
allows the "automatic mapping" of a particular color in Pro/E
to a particular texture in POV-Ray.
2. The key to this technique is to always use the
same color in Pro/E for any particular material (texture). Thus,
all titanium parts in Pro/E are ALWAYS the same color, etc, etc. These
actual colors are irrelevant, just be consistent! It does help if they
are close to the actual color so that they look good if you shade the part/assembly
in Pro/E. HINT: Some parts will be a dark color, so turn off the
color display found in #Environment if the parts are hard to see. It will
become apparent why shortly. This task is easier if you create Pro/E color
map files (color.map) to store your predefined colors. Otherwise you have
the task of "mixing" the color each time.
Pro/E color.map files are of the following format:
0.810 0.620 0.000 0.900 0.900 0.800 0.500 1.000 1.000 1.000 0.000 0.900 1.000 100.000 0 90 NO_TEXTURE NO_TEXTURE NO_TEXTURE 0.900 0.900 1.000 0.670 0.900 0.800 0.610 1.000 1.000 1.000 0.000 0.900 1.000 100.000 0 90 NO_TEXTURE NO_TEXTURE NO_TEXTURE 0.170 0.170 0.170 0.670 0.900 0.800 0.610 1.000 1.000 1.000 0.000 0.900 1.000 100.000 0 90 NO_TEXTURE NO_TEXTURE NO_TEXTURE 0.700 0.700 0.670 0.900 0.900 0.800 0.500 1.000 1.000 1.000 0.000 0.900 1.000 100.000 0 90 NO_TEXTURE NO_TEXTURE NO_TEXTURE 1.000 1.000 1.000 0.900 0.900 0.800 0.500 1.000 1.000 1.000 0.000 0.900 1.000 100.000 0 90 NO_TEXTURE NO_TEXTURE NO_TEXTURE 0.850 0.850 0.860 0.670 0.900 0.800 0.610 1.000 1.000 1.000 0.000 0.900 1.000 100.000 0 90 NO_TEXTURE NO_TEXTURE NO_TEXTURE 0.800 0.800 0.900 0.670 0.900 0.800 0.610 1.000 1.000 1.000 0.000 0.900 1.000 100.000 0 90 NO_TEXTURE NO_TEXTURE NO_TEXTURE
As far as I know, this file can contain up to seven colors when using X-Windows and up to twenty colors when using hardware graphics options. The seven colors in this file are shown in bold, the first color is: red 0.810 green 0.620 blue 0.000. In the context of this discussion the rest of this info is irrelevant, just leave it as-is. This file can be generated initially by using the save option under #View;#Cosmetic;#Appearances and then modifed for the other versions. I use four color.map files, I swap them out as needed by using the following cshell script.
#!/bin/csh cp /home/$USER/PROE/COLOR_MAPS/"color"$1".map" /v/pro-data/baldwin/WORK/color.map
Basically all it does is copy one of the files called
color1.map...color4.map to my work directory with a new name of color.map.
It could easily be a batch file on a NT machine. Note, these files are
in a different location to avoid being erased! The only drawback to this
method is that Pro/E will not recognize a change in the color.map file
if it is already running. So if you are already in Pro and you need a color
contained in one of the other color.map files, you will have to restart
Pro. Its still better than "mixing" the colors everytime!
3. Following the above technique produces a render file that
contains objects of unique colors and those colors map to a unique texture
in POV-Ray. In order for SLP2POV to know how to map those colors you need
what I call a pseudo color include file. Here is my file and a sample,
I call it protext.inc:
......
#declare black_al = color red .17 green .17 blue .17
#declare p_stainless = color red 1 green 1 blue 1
#declare acrylic = color red .8 green .8 blue .9
#declare titanium = color red .71 green .7 blue .72
#declare black_delrin = color red .2 green .2 blue .2
#declare white_delrin = color red .80 green .80 blue .80
.....
This file tells SLP2POV that all colors of color
red .17 green .17 blue .17 should be converted to the texture
called black_al which happens to be my name for my black anodized aluminum
texture.
I have a sample .slp file called tut1.slp that I have created
of the following Pro/E
assembly (please excuse the poor image quality).
Below are the proper SLP2POV command line options and output
for this render file:
> slp2pov -c protext.inc -t .05 -d -T tut1.slp Reading .slp file ................................... Writing .inc file ................................... Pro/ENGINEER to Persistence of Vision Ray Tracer Translator Ver 1.6 Extents of : TUT1 Min : < -2.852930, -3.360899, -0.000000 > Max : < 14.012910, 11.369110, 5.680000 > Triangle Count : 35088 Colors : COLOR_0 < 1.000, 1.000, 1.000 > ==> p_stainless COLOR_1 < 0.170, 0.170, 0.170 > ==> black_al COLOR_2 < 0.099, 0.099, 0.099 > ==> black_dull COLOR_3 < 0.896, 0.896, 1.000 > ==> clear_al COLOR_4 < 0.205, 0.205, 0.205 > ==> black_delrin COLOR_5 < 0.800, 0.800, 0.900 > ==> acrylic COLOR_6 < 0.810, 0.620, 0.000 > ==> gold_al COLOR_7 < 0.800, 0.700, 0.000 > ==> gold_pins COLOR_8 < 0.710, 0.700, 0.720 > ==> titanium COLOR_9 < 0.404, 0.398, 0.105 > ==> mil_conn_green COLOR_10 < 0.850, 0.850, 0.860 > ==> m_stainless COLOR_11 < 0.802, 0.802, 0.802 > ==> white_delrin COLOR_12 < 0.000, 0.000, 0.860 > ==> positronic_blue COLOR_13 < 0.660, 0.660, 0.660 > ==> monel COLOR_14 < 0.200, 0.850, 0.500 > ==> vero_green COLOR_15 < 0.150, 0.150, 0.150 > ==> black_rough_paint COLOR_16 < 1.000, 0.000, 0.000 > ==> red_plastic >
Here are explanations of the options that I use:
-c color_include_file_path
This option will cause the rgb color definitions present
in the .slp file to be replaced with the closest POV-Ray color defined
in the specified include file. (See -t)
-t tolerance
Specifies how close an rgb color definition in the .slp file
has to be to a color in the color include file for them to be considered
the same.
-T
This option will cause the color definitions to be treated
as textures rather than pigments. This is intended for users who have rgb
colors defined in one include file (protext.inc
in my case) for use with the translator and corresponding texture definitions
in another include file (arltext.inc
in my case) which will be used when doing the rendering.
Note that SLP2POV has found and mapped 17 colors to the appropriate
POV-Ray textures! The output file is called tut1.inc and it contains a
single POV-Ray "object". This object can be a single part or
an assembly of parts. For this example, it is an assembly of parts. This
object is used in the POV-Ray scene by "including" this file,
tut1.inc, in the POV-Ray
scene file.
4. The last thing that you need is a texture definition file
for use with POV-Ray. It needs to be included in each scene file (.pov).
My file is called arltext.inc,
here is a sample:
#declare gold_al = texture {pigment {color red .9 green .8 blue .5} finish {specular .8 roughness .005 reflection .1 ambient .25 diffuse .5 brilliance 4} } #declare clear_gold_al = texture {pigment {color red .9 green .8 blue .5 filter 1} finish {specular .8 roughness .005 reflection .1 ambient .25 diffuse .5 brilliance 4} } #declare clear_al = texture {pigment {White} finish {specular .6 roughness .005 reflection .1 ambient .25 diffuse .5 brilliance 4} } #declare black_al = texture {pigment{Black} finish {specular .7 roughness .03 reflection .05 ambient .2 diffuse .5 brilliance 4} }
Note that these texture names correspond to the ones found
in the pseudo color file, in my case protext.inc!
Typically, I include this include file in a "standard"
scene file and render it. I can create this render file, run it thru SLP2POV
and have the first shot at a POV-Ray rendering done in about 5 minutes.
Here is the POV-Ray
scene file for this example, the include file is too big to be provided,
I don't have enough space here at Geocities.. Of course not all assemblies
work in a single standard include file, so they will have to be modified
as needed.
Here is the POV-Ray image of this Pro/E
assembly:
All objects and textures but the wood floor were converted
from Pro/E to POV-Ray by SLP2POV!
Thanks goes out to Bruce Bodnyk for his hard work writing
SLP2POV and to his decision to share it with the rest of us!