Want to finalize a new wings_we:build for colors.
I have one that works below in the MIDDLE with rgb vertex colors.
Problem with it as I see it is ... it probably used the wrong sort of accumulator to inject the vertex colors (maybe slow).
Looking for a better way.
Cool thing about this is that with a few lines of code changes to the .ply importer ... I can get some neat vertex colors to import from MeshLab.
OH ... some background. I have been doing some mesh analysis that seems to benefit from Ambient Occulsion type vertex colors. But the wings3d built in ambient occ ... is too slow on my models. MeshLabs is a great deal vaster and a bit different w.r.t. quality. So I figured ... try to get those MeshLab colors in via vertex color. I had thought about a WRL importer ... but when looking at ASCII PLY format ... it looked far simpler to just augment the current ply importer to bring in the vertex colors. This seems to be true after it was all said and done. Fairly few lines of code needed to import the vertex colors.
I have one that works below in the MIDDLE with rgb vertex colors.
Problem with it as I see it is ... it probably used the wrong sort of accumulator to inject the vertex colors (maybe slow).
Looking for a better way.
Code:
%% build() -> We'
%% Create a we from faces and vertices or a mesh.
build(Mode, #e3d_mesh{fs=Fs0,vs=Vs,tx=Tx,he=He,vc=[]}) when is_atom(Mode) ->
Fs = translate_faces(Fs0, list_to_tuple(Tx), []),
#we{} = We = wings_we_build:we(Fs, Vs, He),
wings_we:renumber(We,0);
build(Mode, #e3d_mesh{fs=Fs0,vs=Vs,tx=Tx,he=He,vc=[{_R,_G,_B}|_]=Vc}) when is_atom(Mode) ->
Fs = translate_faces(Fs0, list_to_tuple(Tx), []),
#we{vp=VPos} = We = wings_we_build:we(Fs, Vs, He),
MyAcc = fun({Vi,_}, Acc) ->
wings_va:set_vertex_color( gb_sets:singleton(Vi), lists:nth(Vi+1,Vc) , Acc)
end,
We1 = lists:foldl(MyAcc, We, array:sparse_to_orddict(VPos)),
wings_we:renumber(We1,0);
build(Fs, Vs) ->
wings_we:renumber(wings_we_build:we(Fs, Vs, []),0).
Cool thing about this is that with a few lines of code changes to the .ply importer ... I can get some neat vertex colors to import from MeshLab.
OH ... some background. I have been doing some mesh analysis that seems to benefit from Ambient Occulsion type vertex colors. But the wings3d built in ambient occ ... is too slow on my models. MeshLabs is a great deal vaster and a bit different w.r.t. quality. So I figured ... try to get those MeshLab colors in via vertex color. I had thought about a WRL importer ... but when looking at ASCII PLY format ... it looked far simpler to just augment the current ply importer to bring in the vertex colors. This seems to be true after it was all said and done. Fairly few lines of code needed to import the vertex colors.