Skip to content

Commit

Permalink
POV-Ray plugin was only output .png file when using the menu option R…
Browse files Browse the repository at this point in the history
…ender. It was added the other file types supported by POV-Ray - the user can choose between them by using the "File type" dropbox in the Render dialog: .bmp (Windows), .pict (Mac), .ppm (Linux), .tga compressed. Thanks ekolis for request it. [Micheus]
  • Loading branch information
Micheus committed Oct 19, 2013
1 parent bb543ef commit b157924
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
44 changes: 41 additions & 3 deletions plugins_src/import_export/wpc_pov.erl
Expand Up @@ -132,15 +132,51 @@ menu(_, Menu) ->
povray_menu(Menu) ->
Menu ++ [{?__(1,"POV-Ray (.pov)"),?TAG,[option]}].

pov_output_exts() ->
wings_job:render_formats(),
OSDep = case os:type() of
{win32,_} -> {bmp,"+FS"};
{unix,darwin} -> {pic,"+FS"};
_ -> {ppm,"+FP"}
end,
[OSDep,{png,"+FN"},{tga,"+FT"}].

get_ext_info([]) -> {"",""};
get_ext_info(ExtInfo) ->
Exts=pov_output_exts(),
lists:foldl(fun({Key,Ext,Dsc}, Acc) ->
case lists:keysearch(Key,1,Exts) of
{value,_} -> Acc++[{Ext,Dsc}];
_ -> Acc
end
end, [], ExtInfo).

get_output_param(Filename) ->
ExtsInfo=wings_job:render_formats(),
PovExts=pov_output_exts(),
{value, {_,DefParam}}=lists:keysearch(?DEF_RENDER_FORMAT,1,PovExts),
Ext=filename:extension(Filename),
case lists:keysearch(Ext, 2, ExtsInfo) of
{value, {RenderFormat, _, _}} ->
case lists:keysearch(RenderFormat,1,PovExts) of
{value, {_,Param}} -> Param;
_ -> DefParam
end;
_ -> DefParam
end.

%dialog and file type properties
% POV-Ray output file formats: http://www.povray.org/documentation/view/3.6.0/219/
props(render, Attr) ->
RenderFormat = proplists:get_value(render_format, Attr, ?DEF_RENDER_FORMAT),
{value, {RenderFormat, Ext, Desc}} = lists:keysearch(RenderFormat, 1, wings_job:render_formats()),
ExtsInfo=wings_job:render_formats(),
{value, {RenderFormat, Ext, Desc}} = lists:keysearch(RenderFormat, 1, ExtsInfo),
Title = case os:type() of
{win32,_} -> "Render";
_Other -> ?__(1,"Render")
end,
[{title,Title}, {ext,Ext}, {ext_desc,Desc}];
Exts=get_ext_info(ExtsInfo),
[{title,Title}, {ext,Ext}, {ext_desc,Desc}, {extensions,Exts}];
props(export, _Attr) ->
{Title,File} = case os:type() of
{win32,_} -> {"Export","POV-Ray File"};
Expand Down Expand Up @@ -224,6 +260,7 @@ pref_dialog(St) ->
{?__(8,"Limit number of vertices, indices per line"), LimitVertices, [{key, limit_vertices}]}
]}],
wpa:dialog(?__(9,"POV-Ray Options"), Dialog, fun (Attr) -> pref_result(Attr,St) end).

pref_result(Attr, St) ->
set_user_prefs(Attr),
init_pref(),
Expand Down Expand Up @@ -332,7 +369,8 @@ export(Filename, Contents, Attr) ->
{Renderer, true} ->
ArgStr = wings_job:quote(filename:basename(ExportFile))++" +W"++wings_job:quote(integer_to_list(Width))++
" +H"++wings_job:quote(integer_to_list(Height))++
" +FN +o"++wings_job:quote(filename:basename(Filename))++
" "++get_output_param(Filename) ++
" +o"++wings_job:quote(filename:basename(Filename))++
case proplists:get_value(antialias, Attr, false) of
false->[];
true->" +A"++ wings_util:nice_float(proplists:get_value(aa_threshold, Attr, 0.3))++
Expand Down
4 changes: 3 additions & 1 deletion src/wings_job.erl
Expand Up @@ -43,7 +43,9 @@ render_formats() ->
{png,".png","Portable Network Graphics"},
{jpg,".jpg","JPeg compressed bitmap"},
{hdr,".hdr","High Dynamic Range image"},
{exr,".exr","OpenEXR"}].
{exr,".exr","OpenEXR"},
{pic,".pict","Picture"},
{ppm,".ppm","Portable Pixmap"}].
%% Formats that internal image loader can handle
%%
-define(LOAD_IMAGE_FORMATS, [tga,bmp,png,jpg]).
Expand Down

0 comments on commit b157924

Please sign in to comment.