octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #55014] Property VertexNormals not updated whe


From: Guillaume
Subject: [Octave-bug-tracker] [bug #55014] Property VertexNormals not updated when Vertices are
Date: Mon, 12 Nov 2018 08:44:37 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0

URL:
  <https://savannah.gnu.org/bugs/?55014>

                 Summary: Property VertexNormals not updated when Vertices are
                 Project: GNU Octave
            Submitted by: gyom
            Submitted on: Mon 12 Nov 2018 01:44:36 PM UTC
                Category: Plotting with OpenGL
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: Guillaume
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: dev
        Operating System: Any

    _______________________________________________________

Details:

If you download the Stanford Bunny mesh and run the following:


% http://www-static.cc.gatech.edu/data_files/large_models/bunny.ply.gz
M = struct('vertices',[],'faces',[]);
fid = fopen('bunny.ply','rt');
while true
    l = fgetl(fid);
    if strcmp(l,'end_header'), break; end
end
nv = 35947; nf = 69451;
M.vertices = fscanf(fid,'%f %f %f',[5 nv])';
M.vertices = M.vertices(:,1:3);
M.faces    = fscanf(fid,'%d %d %d %d',[4 nf])';
M.faces    = M.faces(:,2:4) + 1;
fclose(fid);

figure; ax = axes;
axis(ax,'equal');
axis(ax,'off');
hp = patch(M,...
    'FaceColor', 'b',...
    'EdgeColor', 'none',...
    'Parent',ax);
camlight(ax);
camlight(ax,-80,-10);
lighting(ax,'gouraud');
set(hp,'FaceVertexCData',rand(nv,1), 'FaceColor','interp')

for i=1:3
    N = get(hp,'VertexNormals');
    normN = sqrt(sum(N.^2,2));
    normN(normN < eps) = 1;
    N     = bsxfun(@rdivide,N,normN);
    N(1:3,:)
    set(hp,'Vertices',get(hp,'Vertices')+N/400);
    drawnow
end


Matlab displays: 


ans =

  3x3 single matrix

    0.1962    0.9726   -0.1248
    0.2108    0.9510   -0.2262
    0.0530    0.8026    0.5941


ans =

  3x3 single matrix

    0.1977    0.9724   -0.1239
    0.1748    0.9599   -0.2193
    0.0545    0.8016    0.5953


ans =

  3x3 single matrix

    0.1993    0.9722   -0.1230
   -0.1381    0.9828   -0.1223
    0.0554    0.8009    0.5962


while Octave displays the same initial values:


ans =

   0.196148   0.972595  -0.124835
   0.210776   0.951005  -0.226191
   0.052961   0.802618   0.594137

ans =

   0.196148   0.972595  -0.124835
   0.210776   0.951005  -0.226191
   0.052961   0.802618   0.594137

ans =

   0.196148   0.972595  -0.124835
   0.210776   0.951005  -0.226191
   0.052961   0.802618   0.594137





    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?55014>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]