POV-Ray : Newsgroups : povray.general : img2mesh geometry improved : Re: img2mesh geometry improved Server Time
3 Oct 2025 01:37:50 EDT (-0400)
  Re: img2mesh geometry improved  
From: ingo
Date: 23 Sep 2025 07:55:00
Message: <web.68d28a38760e667517bac71e8ffb8ce3@news.povray.org>
Ilya Razmanov <ily### [at] gmailcom> wrote:
> Greeting,

Interesting what you do with the sharp transitions.

Other method that could work in various cases:

1. First calculate the face normal, either by cross product of three edges or
Newell's method

Newell:
  for i in 0..<vertices.len:
    let curr = vertices[i]
    let next = vertices[(i + 1) mod vertices.len]
    normal.x += (curr.y - next.y) * (curr.z + next.z)
    normal.y += (curr.z - next.z) * (curr.x + next.x)
    normal.z += (curr.x - next.x) * (curr.y + next.y)
  return normalize(normal)

2. Now calulate the vertex normals, there several weighting types can be used,
based on properties of the adjacent polygons.
   Weighted by area, weighted by angle or just average the face normals as they
are.


Regarding usefulness, always. Users do crazy things :) It may also be useful if
you provide an export as arrays, so one can (ab)use the data in SDL.

ingo


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.