To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.cad.devOpen lugnet.cad.dev in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 CAD / Development / 7198
7197  |  7199
Subject: 
The use of type 5 lines for smoothing of objects.
Newsgroups: 
lugnet.cad.dev
Date: 
Wed, 8 May 2002 15:10:11 GMT
Viewed: 
517 times
  
Hello people,

this is my first post. A few weeks ago I mailed with Travis Cobbs and Lars
Hassing about an algorithm I constructed to make objects look smoother. This
can be done by using per vertex normals and smooth shading. The normals can
be calculated with the data contained in the 'type 5' lines, because they
mark edges that are smooth in the real world.

It is possible to calculate the normals for the 2 first vertices of the
optional line. To do that you can add up the normals of the 2 surfaces that
are defined by the optional line and renormalize this new normal. This way
you don't have to worry about cw or ccw. In my algorithm I use each of the 2
first vertices of the optional line as keys of a Vertext2SmoothNormal map.
If a key already exists I add the normal to the value already in the map.
This way I walk through al the optional lines in a .dat file. The result is
a map that uses a given vertex as a key and points to a smooth normal. When
you draw a face you can check first if the vertex is present in the map. If
it is then set the smooth normal for the vertex. If it is not draw the
vertex with the flat normal defined by the face itself.

So in pseudo code:

for(each optional line in the dat file) {
    Calculate normal defined by optional line;

    if(first vertex is present in map) {
        add normal to existing value;
    }
    else {
        create new key, value pair;
    }

    if(second vertex is present in map) {
        add normal to existing value;
    }
    else {
        create new key, value pair;
    }
}

This way you can create a Vertex2SmoothNormal map for a given dat file.

I have a demo running now and it works. Things look smooth now without
primitive substitution. Everything with optional lines can be smoothed this
way. The only problem is that hollow parts of objects are not equipped with
optional lines. So in my demo the outside of a minifig hand is smooth but
the inside not. That is because the original idea of the optional line was
to draw a black line around an object. In the future optional lines may be
used to indicate where a model has a smooth edge.

There are other ways to implement this idea off course. Lars wrote that he
liked the idea but that he hasn't got the time to implement or think about
it yet. I guess we will have to wait until we can render things like helmets
or dishes without facets.

I hope this is clear and understandable,

Martijn Zwaal



Message has 4 Replies:
  Re: The use of type 5 lines for smoothing of objects.
 
(...) One thing that someone noted (I think it was Don Heyse) when I mentioned this was that it might be possible to instead check for the lack of type 2 lines of color 24 between two adjoining faces, and use this as an indicator that the two faces (...) (23 years ago, 8-May-02, to lugnet.cad.dev)
  Re: The use of type 5 lines for smoothing of objects.
 
Here follows a more explicit form of the algoritm: For each dat file I make a map called Vertex2Normal When I move the dat file I do the following thing for each optional line: I call the 4 vertices in the line P0, P1, P2 and P3. Then I look at the (...) (23 years ago, 13-May-02, to lugnet.cad.dev)
  Re: The use of type 5 lines for smoothing of objects.
 
(...) Well, I added an initial go at Martijn's suggested algorithm to LDView (with some modifications here and there), and the results look extremely promising. Here is a sample: (URL) that this was rendered with Primitive Substitution disabled, so (...) (23 years ago, 20-May-02, to lugnet.cad.dev)
  Re: The use of type 5 lines for smoothing of objects.
 
On May 08 Martijn Zwaal wrote in lugnet.cad.dev: (...) Hi Martijn, that's a brilliant idea!! I have always regarded optional lines as only a mean for drawing the outline/contour on curved surfaces. But optional lines are actually a valuable (...) (23 years ago, 22-May-02, to lugnet.cad.dev)

22 Messages in This Thread:





Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR