Micheus. You have some good ideas and observations. I will use array:fold
Anyways ... your code is not finding Color . That is one the the problems. I'm using a GbTree now
to do it faster instead of lists:nth. lists nth is just tad slow.
Little bit better ... maybe. I should maybe check that Vs and Vc are of equal length !
I was able to get the PLY vertex colors to work very easily because standard import codes
are doing a bunch of work ... so I want to fix it in a general way ... you know ... and do a pull request if I can get it done just right. Then I can also update WRL importer (old I know).
Anyways ... your code is not finding Color . That is one the the problems. I'm using a GbTree now
to do it faster instead of lists:nth. lists nth is just tad slow.
Little bit better ... maybe. I should maybe check that Vs and Vc are of equal length !
I was able to get the PLY vertex colors to work very easily because standard import codes
are doing a bunch of work ... so I want to fix it in a general way ... you know ... and do a pull request if I can get it done just right. Then I can also update WRL importer (old I know).
Code:
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),
Dict = lists:zip(lists:seq(0,length(Vc)-1), Vc),
Tree = gb_trees:from_orddict(Dict),
MyAcc = fun(Vi,_VAL, Acc) ->
wings_va:set_vertex_color(gb_sets:singleton(Vi),gb_trees:get(Vi,Tree), Acc)
end,
We1 = array:fold(MyAcc, We, VPos),
wings_we:renumber(We1,0);