BaldEagle Tools - LODEditor

Home      LODEditor       Theater Building Utilities       Models

 

LODEditor Help & Tutorials

LOD Editor Tutorial

Normals

By

Rick "Dragon" Prior

 

Introduction:

I am sure that after you have begun to look through some LODs using LE, you have run across the use of the term "Normal" in several places. You might find yourself a little confused as to what they all mean and do. Well, this tutorial will describe what all the different Normals are and how they effect the model.

 

Types of Normals:

Again, for this tutorial, I will use the MiG-21 LOD (2835) as examples so you can follow along. First off, here is a list of all the various types of Normals found within a LOD:

Shading Normals: These are used to determine how to shade the object. They are referenced from the draw nodes by the "dColor" field and thus may be referred to as the "dColor Normals".

Node Normals: These are used to determine if a polygon is visible and is contained within the draw nodes.

Split Normals: These are used to determine the drawing order of the model. (See the Tutorial on Split Nodes for further information).

 

Normal Structure:

The structure of the Normal is 4 floating point variables. The first three make up the Unit Vector and the 4th is the Scale, or magnitude. NOTE: The dColor Normals do not contain the Scale value as it is not necessary to know the magnitude. We are only concerned with the direction in the dColor Normals.

nx = 0.000

ny = 0.000

nz = -1.000

Scale = 5.432

In the above Normal, it is pointing straight up (remember, Z- is Up in the Falcon world!) with a magnitude of 5.432. For Node Normals and Split Normals, the normal defines a plane which is located perpendicular to the Unit Vector and at a distance equal to the Scale. For the dColor Normals, it is simply indicating the direction.

nx = 0.707

ny = 0.000

nz = -0.707

In this Normal, since there is no Scale value, it must be a dColor Normal. It is pointing Up and to the Front at 45 degrees since sin(45) = 0.707.

 

Shading Normals (dColor):

dColor's are treated exactly like the Vectors in that they are contained within a table. Within the Root Node, there is a pointer to a Vector Table, Texture Table and dColor Table. When the LOD is to be drawn, the Root Node will load in each of these tables and use them until another node loads in a different table. The other node types that can use a different table include DOF and SubTree.

When a DOF or SubTree node is reached, it will load in a new set of Vectors and dColor's and use those until that branch is finished. Again, you can see why you should treat each group of nodes as separate objects as in many cases, they indeed have a complete set of Vectors and Normals.

If you load up the MiG-21 model, you will see that there are 159 dColor Normals and they are located at offset 41208 (which is the number of bytes from the Root Node). Clicking the Normal button will allow you to edit these normals.

Now, lets find a draw node to look at. Find node 77 which is a CP node (make sure you find one that does not have any tags, -s2 or -d4. Those tags indicate that they are contained within a Switch or DOF branch and may have a separate dColor Table loaded). If you look at 77.CP, you will notice first off that it is one of the wings. Secondly, you will see it is using color 935 and has a single dColor value of 0.

When a draw node only has a single dColor, then that dColor Normal is applied to the entire surface of the polygon. These are generally used on objects that touch only one other polygon, or are on an edge. The reason being, is that the dColor Normals are used to shade the lights. If you had a flat polygon with a polygon on either side, one going up and the other going down, you would want a different shade on either end to match that of the next polygon.

Now, pull up 296.CP and you will see that each vertex has a dColor Normal. This means that the graphics engine within Falcon will shade the light according to the normals at each vertex.

Lets go back to 77.CP. You noticed a dColor equal to 0 in this field. In order to edit this normal, you have to go back to the table where it is located. (Future updates will allow editing of these normals from right within the node). Since this is a Root Node normal (or Main Table), you have to exit out to the main entry page. Click the Normal button and edit record 0. The original values are:

nx = 0.0109

ny = 0.0517

nz = 0.9986

As you can see, this normal is pointing almost directly down which would indicate this is the bottom side of the wing. Also, since this is a node with a single dColor value, then this normal should be identical to the Node Normal within the CP node. You can check and see that they are indeed the same! Now if you were to look at 296.CP and look at the four dColor Normals for it (142, 143, 144 and 145), you wold see that each one is different. The way the dColors are set up is they should bisect the angle created between two adjoining polygons. Since the angles of the adjoining polygons may differ on each side, the dColors will also be different.

Lets look at node 10, or 10.CP-d0. The -d0 tag indicates it is part of the DOF #0 branch. Notice it is also using dColor of 0! Remember though, it is now using the tables contained with DOF #0. Open up DOF #0 at node 9 and click the Normal button. There you will see dColor 0 has the following values:

nx = -0.0734

ny = -0.0000

nz = 0.9973

Notice that even though they are using the same index number, 0, they are indeed different!

If you were to change vectors to modify a polygon's shape, you may have altered the angle of the polygon. If you leave the dColor value alone, then you may end up with a light or dark polygon when you view it within Falcon. You may have to tweak the dColor value to get a better appearance.

One final note on the dColor Normals, not all draw nodes have them! The PT nodes, for example do not have any dColor values. The CP and LP nodes have them but not all types of them use them. When the AddNode function is expanded to add nodes, you have to keep this in mind when choosing the drawing sub-type mode as you may get caught with a single dColor when you really wanted one at each vertex.

 

Node Normals:

These normals are contained within most of the draw nodes (PT sub-types 0 and 1 are the only ones that don't contain them since they are a Point and Line respectfully). Take a look at 77.CP. The normal should look like this:

nx = 0.0109

ny = 0.0517

nz = 0.9986

Scale = 0.1199

For these normals, it is defining the surface plane of the polygon. When the model is drawn, the users view is checked against this normal to determine if you can "see" the polygon. If you can see it, then it draws it. Otherwise, it does not draw it. This is called Backside Culling and is usually a process that is taken care of by the graphics engine as it will compute the Cross Product of the vertices to get the normal. The Falcon models contain these normals in there so your graphics device (or CPU) does not have to do the extra calculations. Essentially, it speeds things up.

If you were to change some vectors for a polygon, your normal may not be a true representation of the polygon's normal any more and when you view within Falcon, that polygon may "disappear" from certain view angles when it should not. To fix this, just hit the NormalCalc button and the Node Normal will be updated.

NOTE: The order of the vertices is important! Since Z- is Up, you have to order your vertices in the counter-clockwise direction! If you go the other way, then the calculated normal would be pointing in the opposite direction!

NOTE: There is one exception to the Note above and that is for the LP nodes. These nodes are basically two nodes together. The first part is for Side A of the polygon and the second half is for Side B. In these nodes, the vertices are in identical order BUT the normals are opposite! That means for Side B of an LP node, you should go clockwise. Or better yet, the vertices should match exactly with what is on Side A.

NOTE: When determining the direction to go (counter-clockwise) you MUST Be viewing the polygon's side you wish to be displayed. That means if you are working on a node on the bottom of the aircraft, you should rotate the plane upside down so you are looking at that polygon's surface!

 

Split Normals:

Split Normals work the exact same way as the Node Normals in that the program calculates if you can "see" it. Then it branches accordingly down either Ptr1 or Ptr2. See "Tutorial - Split Nodes" for further information on the Split Normals.