POV-Ray : Newsgroups : povray.advanced-users : In a mesh(triangle to smooth_traingle) : Re: In a mesh(triangle to smooth_traingle) Server Time
5 Jul 2024 14:39:32 EDT (-0400)
  Re: In a mesh(triangle to smooth_traingle)  
From: Jim Charter
Date: 12 Feb 2008 12:46:23
Message: <47b1db6f@news.povray.org>
here_I_am wrote:
> Jan Dvorak <jan### [at] centrumcz> wrote:
> 
>>here_I_am napsal(a):
>>
>>>Hey everybody!
>>>
>>>I am in the middle of a project, where i have to do smooth shading from a scene
>>>file of 15000 triangles which have thge data as triangles rather that having in
>>>smooth_traingle.And since the number of triangles is very large I simple can't
>>>calculate vnormalize(vcross(v1-v2,v3-v2)) manually and implement to
>>>smooth_triangle for every triangle
>>
>>either you can or you don't have to ;-)
> 
> 
> 
> yeah! I don't have :)
> So could you please suggest something here??
> 
It's a little puzzling, if you know how to derive the normal then you 
must realize that you have to reparse the data somehow. You could 
probably get pov to do it but it will probably require that you edit the 
data externally such that there is a single triangle per line.

Its a little bit trickier than you suggest though because you have to 
grab all the triangles containing a given vertex and average the 
cross-product from each triangle.  So I think there would be some 
intermediate steps involved. I think you would have to produce a list of 
vertices and a corresponding list of triangles referencing the vertex 
list. Then produce a list of normals calculated for each vertex. For 
each vertex you would have to retrieve all the triangles containing it. 
Finally rewrite the sdl for smooth_triangles now contructed with 
vertex-normal pairs.


It would might be easier to do it in some other external scripting 
language with flexible string manipulation abilities.  I found Python 
very easy to learn.


Post a reply to this message

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