home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.graphics:12266 comp.graphics.visualization:1809 comp.graphics.explorer:341 comp.sys.sgi:16805 comp.graphics.animation:1098 comp.windows.x.intrinsics:563
- Path: sparky!uunet!olivea!sgigate!odin!bananapc.csd.sgi.com!ciemo
- From: ciemo@bananapc.csd.sgi.com (Dave Ciemiewicz)
- Newsgroups: comp.graphics,comp.graphics.visualization,comp.graphics.explorer,comp.sys.sgi,comp.graphics.animation,comp.windows.x.intrinsics
- Subject: Re: Help needed about the Normal System.
- Message-ID: <1992Nov24.022611.24903@odin.corp.sgi.com>
- Date: 24 Nov 92 02:26:11 GMT
- References: <1992Nov20.200847.4985@ringer.cs.utsa.edu>
- Sender: news@odin.corp.sgi.com (Net News)
- Organization: Silicon Graphics, Customer Support Division
- Lines: 123
- Nntp-Posting-Host: bananapc.csd.sgi.com
-
- In article <1992Nov20.200847.4985@ringer.cs.utsa.edu>, cqu@ringer.cs.utsa.edu (Chang-ning Qu) writes:
- |> ...
- |> The problem is that we couldn't get correct illumination
- |> when displaying in draw-solid and draw-lighted, they are just
- |> reversed (lighted sides to be dark and dark becoming lighted)!
- |>
- |> The normal system of the original code seems using
- |>
- |> --> x1-x2 -(y1-y2)
- |> n = ( --------, --------, 0 )
- |> NORM NORM
- |>
-
- There is a feature of the GL called TWOSIDED lighting that might be
- biting you with respect to the Render module. The GL has this notion
- of polygons being drawn "backfacing" or "frontfacing". This face
- orientation is determined by the traversal order of the polygon
- vertices when drawing the object. When the "face" orientation of the
- polygon is frontfacing (pointing toward from screen), the lighting
- MATERIAL is used. When the polygon face orientation is backfacing
- (pointing away from the screen), the BACKMATERIAL is used. The normal
- is used by the lighting computations to determine how to "light" the
- BACKMATERIAL or MATERIAL of the polygon. See lmbind(3G) for more
- details.
-
- To guarantee that you get the orientation and lighting normals line up,
- you need to use the same traversal order for the vertices that you would
- use in computing the normal.
-
- Attached is a cxGeo module program which illustrates
-
- Create a module which has passes "cxGeo* Scalar &" to the sendCubeGeom()
- function. Connect this to a Geometry output port. This module will
- only generate a cube geometry data set when you manually fire the
- module. There are no inputs to the module which would cause to fire
- on it's own.
-
- --- Dave
- ----- gencube.c ------------------------------------------------------------
-
- #include <cx/DataTypes.h>
- #include <cx/DataAccess.h>
- #include <cx/Geometry.h>
-
- static float cubepoints[] = {
- -1, -1, -1,
- -1, -1, 1,
- -1, 1, -1,
- -1, 1, 1,
- 1, -1, -1,
- 1, -1, 1,
- 1, 1, -1,
- 1, 1, 1
- };
-
-
- static long cubefaces[] = {
- 0, 1, 3, 2, -1,
- 0, 4, 5, 1, -1,
- 0, 2, 6, 4, -1,
- 1, 5, 7, 3, -1,
- 2, 3, 7, 6, -1,
- /*
- 4, 5, 7, 6, -1
- */
- 4, 6, 7, 5, -1
- };
-
-
- static float cubefacenormals[] = {
- -1, 0, 0,
- 0, -1, 0,
- 0, 0, -1,
- 0, 0, 1,
- 0, 1, 0,
- 1, 0, 0
- };
-
-
- static float cubefacecolors[] = {
- 1, 0, 0,
- 0, 1, 0,
- 0, 0, 1,
- 1, 1, 0,
- 1, 0, 1,
- 0, 1, 1
- };
-
-
- void
- sendCubeGeom(cxGeometry **geom)
- {
- /* Initialize geometry library first time module is called */
- static int initgeom = 1;
- if (initgeom)
- {
- initgeom = 0;
- cxGeoInit();
- }
-
-
- /* Create new geometry buffer */
- *geom = cxGeoNew();
- cxGeoBufferSelect(*geom);
-
- cxGeoRoot();
- cxGeoDelete();
-
- cxGeoPolysDefine(8, cubepoints, 30, cubefaces);
- cxGeoNormalAdd(6, cubefacenormals, CX_GEO_PER_FACE);
- cxGeoColorAdd(6, cubefacecolors, CX_GEO_PER_FACE);
-
- cxGeoBufferClose(*geom);
- }
-
-
- --
-
- __ * __ _ __ ___
- / \ / / / / \/ \/ \ He was a man like any other man, however, not
- / / \/ / /\ / / quite like any other man.
- \___/\__/\_/ /_/ / \__/
- *
-