function [ OUT ] = bvh_to_all(filename )
%BVH_TO_ALL Summary of this function goes here
%   Detailed explanation goes here

out_euler   = [];
out_pos     = [];
out_expmap  = [];
out_quat    = [];


%euler
[skel, out_euler, fl] = bvhReadFile(filename);

if fl < 1/60
    out_euler = out_euler(1:2:end,:);
end

%exp map
lastM = [];
for ii=1:size(out_euler,1)
    [skel_e,out_expmap(ii,:)] = bvh2expmap_skipbad(skel,out_euler(ii,:), lastM, ii);
    lastM = out_expmap(ii,:);
end

%position

out_pos = ch_exp2xyz(out_expmap, skel_e);


% remove empty
if size(out_euler,2) == 138
    skel.type = 'ms3';
elseif size(out_euler,2) == 66
    skel.type = 'ms3.x';
elseif size(out_euler,2) == 72
    skel.type = 'ms?';
end
    
[out_euler_prep, BVH_CONST_DIMS, BVH_NUM_DIMS, emptyindx] = Prep_RemoveEmpty_simple(out_euler, skel,0);

[out_expmap_prep, BVH_CONST_DIMS, BVH_NUM_DIMS, emptyindx] = Prep_RemoveEmpty_simple(out_expmap, skel,0);



OUT.filename = {filename};
OUT.skel     = skel;
OUT.fl       = fl;
OUT.pos      = out_pos;
OUT.euler    = out_euler_prep;
OUT.expmap   = out_expmap_prep;
% OUT.quat     = out_quat;

end

