TweetFollow Us on Twitter

3D Graphic Tools
Volume Number:8
Issue Number:1
Column Tag:Tools of the trade

Related Info: Quickdraw Color Quickdraw

3D Graphic Tools

High-performance 3D drawing & rendering in your programs

By David Harr, Alhambra, California

Note: Source code files accompanying article are located on MacTech CD-ROM or source code disks.

Introduction

The Macintosh Toolbox provides good support for doing 2 dimensional computer graphics in the form of QuickDraw. Basic QuickDraw (B&W) provides 6 geometric primitives: line, rectangle, round-cornered rectangle, and circle, a polygon data structure, and a region data structure, which allows the programmer to deal with arbitrary areas and shapes. All of these can be drawn, outlined, filled, pattern filled, resized and used as masks. Color QuickDraw adds the capabilities of drawing in color, filling in color, using color patterns, palette animation, color masking, and provides support for photo-realistic color and double-buffered on-screen animation.

With all of this attention to 2 dimensional graphics, however, Apple has been lax in supporting the needs of those who are interested in doing 3 dimensional graphics and modeling. The only support that Apple gives is in the form of a set of slow, buggy library routines collectively known as Graf3D supplied in object form with MPW. The “documentation” of Graf3D consists of eleven pages in an appendix at the back of the MPW reference manual, Volume 1. This is a bare-bones listing of the routines and a short explanation of the calling conventions, parameters and purpose of each routine. Graf3D itself is a minimal effort in supporting 3d graphics. It provides only rotation, scaling, translation, clipping, and 2d projection. There are no provisions for hidden line removal, polygon fills, z-buffer rendering, light sources, or shading. It can be used, at best, for wire-frame drawings.

3D Graphic Tools version 3.0, published by Micro System Options of Seattle, Washington, is a set of routines written for programmers who wish to use high-performance 3 dimensional drawing and rendering in their programs. The package contains the source code for over 100 routines for 3D graphics. It provides a set of tools for graphics programmers, and is a good basis for someone interested in writing their own software for custom graphics applications.

This review discusses the C version of the package, which supports MPW C version 3.0 and later, and THINK C version 4.05 and later. There is also a Pascal version which is functionally identical to the C version and supports MPW Pascal version 3.0 and later, and THINK Pascal version 3.01 and later.

Rendering Environment

All of the drawing in 3D Graphic Tools is done in a three dimensional extension of the normal QuickDraw coordinate space. In other words, while most QuickDraw operations take place in a plane with (-32000, -32000) in the top, left corner and (32000, 32000) in the bottom, right corner, the coordinate space in 3D Graphic Tools is a cube that is 64000 units on a side. This gives a space that is large enough for most purposes, yet is small enough to allow the arithmetic operations to be carried out using high speed integer mathematics.

Figure 1

By convention, the three axes of the coordinate system are labeled the x, y, and z axes. The x and y axes are perpendicular to each other and lie in a horizontal plane, while the z-axis is perpendicular to them both, and runs straight up and down. Each axis runs from approximately -32000 to 32000, and each point in space has a unique coordinate given by (x, y, z), where x, y, and z each represent the respective coordinate of the three axes.

Mathematical Basis

Three dimensional rotations, transformations and scalings all involve considerable linear algebra, so they require a lot of multiplication. In order to speed the rendering of images and to make image manipulation as rapid as possible, it is common to use fixed-point, or integer mathematics in the calculations, with some loss in accuracy. 3D Graphic Tools supports a complete set of mathematical functions using both the Fixed and Fract data types, as described in Inside Macintosh volumes I and IV. These routines are not the routines included in the Macintosh ROMs, however. They are hand-crafted assembly language routines that have been optimized for speed. On average, the fixed math routines in 3D Graphic Tools are between 40% to 50% faster than the Toolbox routines. This makes 3D Graphic Tools significantly faster than Graf3D when performing line and point manipulation in three dimensions. In addition, many of the conversion routines between types, such as frac2fix or fix2frac are implemented as macros in 3D Graphic Tools, removing the overhead of a function call, again adding to the speed of the package. In those situations where accuracy is paramount, such as in zbuffer rendering, the routines revert to floating-point mathematics, which is slower (especially in those machines without a 68881/68882 FPU), but is more accurate.

Rendering Attributes

3D Graphic Tools has a full range of functions for performing three dimensional image manipulation and rendering. These include basic operations such as rotations, scalings, translations, and projections onto the two dimensional screen. In addition, once a three dimensional scene has been constructed, it can be rendered to almost any desired level of realism, from wire-frame drawings with no hidden line removal, to an image incorporating such sophisticated techniques as multiple inde-pendent light sources, shadows, specular highlighting, and texturing of objects. The only effort required of the programmer is that they set the appropriate global variables.

The basic data unit in 3D Graphic Tools is the patch. A patch is a set of vertices and facets that determines the shape of the object that the patch represents [see listing 1]. In addition to this shape information, however, the patch also contains an extensive set of rendering attributes that are needed when making use of the more sophisticated rendering options in the package. The rendering information associated with a patch is used to determine the effect of illumination on the object. Some of the information is also used to add texture and supply visual effects to the surface of the object.

Each vertex is defined by the coordinate (x, y, z) that it occupies in space and a number in the vertex list. Thus, vertex 7 might be at (17, 23, 48). Each facet is defined by a list of vertices, which are referenced by number, not by coordinate. This list is arranged so that the vertices are listed counterclockwise in order. The reason that each vertex is addressed by number is so that if an object is translated, rotated, or scaled, the changes need only be made to the master list of vertices, and all facets of the patch will automatically be correctly positioned. This is much faster than stepping through each facet and individually repositioning each vertex in that way, because each facet shares at least two vertices with other facets in the same object.

The ambience, diffusion, and reflection coefficients all control how light reflecting off the object is treated. The reflection coefficients consist of three numbers in the range 0 to 65535. Each controls what percentage of the red, green and blue light is reflected from the object. A coefficient of 0 indicates 0%, 32767 is 50%, and 65535 is 100% reflection. When using the zbuffer rendering, then the ambience and diffusion coefficients come into play also. If there is ambient light, then the ambience coefficient determines what percentage of that light is reflected from the object, while the diffusion coefficient determines what percentage of the light is reflected uniformly in all directions.

The specular index, the specularity and transparency coefficients all determine the quality of the illumination of the object. The transparency coefficient determines the percentage of the background color which is added to the final color of the object. If it is 0, then the object is opaque, and none of the background color is added, whereas if it is 1, then the object is invisible, and its color is 100% determined by the background color. The specular index and the specular coefficient are related and determine how shiny the object is and how that shininess is distributed across the surface of the object.

In addition to all of these rendering options for the patch, there are also several miscellaneous attributes. There are three attributes that are specifically concerned with lighting effects. If a patch is declared as a light source, then it emanates light of the color determined by the reflection coefficients. If the ambient effect and distance effect booleans are set, then the ambient light is added directly to the light reaching the viewer’s eye, causing more distant objects to become grayed out. The farther away an object is, the lower the intensity of the light reaching the viewer’s eye, causing more distant objects to become darker. There are also three attributes that are used to determine how the object is rendered. If the framed boolean is set, then all facets are drawn with the edges in a different color than the facet itself. The color to draw the edges in is given in the frameColor field. If the pattern boolean is set, then the facet is drawn with a QuickDraw color pattern inside. Related to the pattern boolean is the grayscale boolean, which fills the facet with one of 65 gray levels ranging from white to black.

Advanced Options

In order to give the objects displayed a more photo-realistic look, 3D Graphic Tools also has several advanced rendering options. These options, although they increase the time required to display the scene, do not require nearly as much time as full-blown ray traces, yet they provide a level of realism approaching that of ray tracing. These advanced functions include texture mapping, anti-aliasing, and shadows.

Texture mapping is one of the most impressive features of the package. It allows the programmer to add any one of six “textures” to an object. Each texturemap may be rotated, scaled, or translated to produce interesting effects when projected onto the object. The first of the six texture types is not really a texture at all, it is a PICT file of the programmer’s choosing that will be placed onto the object in much the same way as if the PICT were projected onto the object by a movie projector or slide projector. However, it is also possible for the PICT to be repeated in every facet of the object, causing it to appear again and again. In addition, the PICT can be enlarged or reduced to any desired extent. Three more “naturalistic” textures include wood, rock, and bumps. These have other attributes such as grain and roughness to make them even more versatile.

Anti-aliasing is a technique that is used to soften and smooth the appearance of the object. There are several algorithms used in computer graphics for anti-aliasing. The one used in 3D Graphic Tools is to create a 3 X 3 convolution matrix of the selected pixel and the eight pixels surrounding it, and then use that matrix to get a weighted average of the color of the pixels. This color is then used to determine the displayed color in the pixel. The main use for this technique is to soften the edges of facets in the object. Once an object is rendered, if edge anti-aliasing is enabled, then each visible facet in an object is processed a second time, but only the edge pixels are redrawn. In addition, it is possible to apply anti-aliasing to a rectangular portion of an image, allowing anti-aliasing to work either on any portion or the entirety of a rendered image.

Shadows are the result of a reduction in illumination intensity caused by the presence of an object between a light source and another object. The object between the light source and the second object will cast a shadow on the far object. The degree to which the illumination is reduced is a function of the transparency of the interposing object. The more opaque the interposing object is, the less light reaches the far object. This is the model that 3D Graphic Tools uses to generate shadows. This model does have one limitation. If there are multiple objects between a light source and the far object, only the first object encountered will be used to cast a shadow.

Rendering

There are three ways of rendering a scene using 3D Graphic Tools. The one the programmer uses depends on how fast the programmer wishes the scene rendered, how detailed the scene needs to be, and much memory the programmer is willing to devote to holding the image.

The fastest and least realistic looking rendering of a scene is when it is rendered in just wire-frame. In this case, the facets are all drawn and every edge of every facet is visible. There is no effort to block edges that are behind other edges. This can be done very rapidly because there is a minimal amount of calculation involved. The only calculations required are the transforms needed to place the vertices into the proper perspective in the scene, and then another set of mathematical transforms to place the points in their proper place on the screen so that the two dimensional representation is correct.

The second algorithm used is known as the painter’s algorithm. When the painter’s algorithm is used, first, the package figures the surface normal to each facet to determine if that facet is visible to the viewer. Then the package takes the center of mass of each visible facet and checks to see whether it is inside or outside of the clipping planes formed by the edges of the screen. Next, it determines the distance from the viewer to the center of mass of each visible facet. The facets are then rendered with the most distant facets rendered before the closer facets. In the same way as a painter paints in the background before the foreground, as the near facets are drawn, they obscure those parts of the far facets that are behind them. The painter’s algorithm is not as fast as plain wire-frame drawings; however, it is still relatively quick. However, it has a problem with facets that are of unusual shapes and also with intersecting objects. Because the center of mass of the facet is used to determine the distance of the facet from the viewer, the painter’s algorithm doesn’t handle long, thin facets, facets that intersect with each other or facets that are aligned generally along an axis parallel to the axis of viewing properly. This is not a particular defect of 3D Graphic Tools, rather, it is a known defect with the painter’s algorithm.

The final algorithm that is used for rendering in the package is called zbuffer rendering. In zbuffer rendering, each facet is processed, and each pixel is stored as a three dimensional value giving the x, y, and z coordinates of that pixel. The x and y coordinates are just the screen coordinates of that pixel, while the z coordinate is the distance from that pixel to the viewer. In addition, a global matrix of z values is maintained for each pixel on the screen, and the z value of the pixel closest to the viewer is kept in this global array. As each facet is drawn, each pixel’s z value is checked against the global value for that pixel, and if the value is greater than that in the global array, then that pixel of the facet is not visible to the viewer, so it is not drawn. Obviously, this checking of each rendered pixel against the global values is a rather time-consuming process, however, the zbuffer algorithm is capable of properly displaying even very complicated, intersecting facets in their proper perspective.

Several of the more advanced rendering techniques are available only when using zbuffer rendering. These include ambience, diffusion, specularity, transparency, texture mapping, shadows and anti-aliasing.

Using 3D Graphic Tools

To demonstrate the way in which the programmer would use 3D Graphic Tools, we will briefly examine one of the tutorials that is given in the manual. In this tutorial, the programmer uses the package to render a lamp on a table that is created from scratch, using only the tools provided in the package. See Figure 1.

To install the package, it is only necessary to drag the source and header files to your hard disk. Then you just ensure that the proper source files and header files are included in your project, if you are using THINK C, or are included in your makefile, if you are using MPW C.

First, the programmer has to allocate a place to store the information from which the scene is rendered. This is called a collection. A collection consists of an arbitrary number of groups, which in turn consist of an arbitrary number of patches, with each patch roughly corresponding to an object. So the pro-grammer creates a collection that will hold two groups, one group to contain the information for the lamp, the other to contain the information for the table.

The group containing the information for the lamp will be made up of four objects, the shade, the base, a support tube for bulb, and the bulb itself. In creating the lamp, first we create the body. This is done by passing an array of control points for the lamp body to HermiteCurve3D() which interpolates the control points to make a smooth curve. Then that two dimensional curve is rotated through 360š to create a smooth surface. This set of points is then installed into a patch and that patch added to the first group. Next, the support tube for the bulb is created by a call to SolidCylinder(). This is stored in another patch and then added to the first group. Then, the bulb is created using SolidSphere(), but then the programmer needs to call the function SetPatchRenderingAttribs() to set the lightSource boolean so that the program knows that the bulb is giving off light. This is then stored in a patch and the patch added to the group. Finally, the shade is created by calling the function SolidCylinder() with different diameters for the top and bottom circles. A similar procedure is followed in creating the table, the top is defined as a octagonal solid, each piece is installed into a patch, and then each patch is added to the second group.

Now that the objects are properly created, and all of the rendering attributes properly set, then the point of view must be selected. This is the point in space from which the scene is viewed. To choose this point, the programmer calls AimCamera3D(). Then, the lighting environment needs to be specified. 3D Graphic Tools allows the programmer to provide an unlimited number of light sources of arbitrary color and brightness located at any point within the internal three dimensional space of the package.

After the programmer has determined the position and the lighting, then it is possible to set up an off-screen GrafPort to do all the drawing in and then copybits the finished image into a window on-screen.

This is done through calls to NewOffScreenCPort(), UseOffScreenCPort(), ShowOffScreenCPort(), and DisposOffScreenCPort(). It is very convenient and easy to use these off-screen ports to give animations a smooth and professional look. The programmer renders the scene using xfRenderCollection(), and then shows the off-screen port, causing it to be copybitsed onto the on-screen window.

Conclusion

3D Graphic Tools is a comprehensive set of routines for doing three dimensional rendering on the Macintosh. The only limitations of the package are that it does not support parametric representation of surfaces, there is no provided way to import data sets from other three dimensional modeling programs into the package, and it stops just short of providing the facilities to do full ray tracing. However, since the entire package is provided with source code and there are no licensing fees, this makes it excellent for engineering or scientific programming where the programmer wishes to do three dimensional plots or as a starting place for those writing a three dimensional graphics application who do not wish to have to reinvent the wheel.

A Sample Listing of Lamp.c

/*Program:Lamp.c
 Purpose: Tutorial demonstration - Lamp on Table
 ©1991 Mark M. Owen - All Rights Reserved. */

/* Compiler specific headers */
#pragma segment  Main

#ifndef THINK_C

#include <OSEvents.h>
#include <Fonts.h>
#include <Desk.h>
#include <Dialogs.h>
#include <Menus.h>
#include <Memory.h>
#include <Packages.h>
#include <Quickdraw.h>
#include <Resources.h>
#include <Traps.h>
#include <Windows.h>

extern _DataInit();

#endif  THINK_C

/* 3d Graphic Tools headers (for things we’ll use only) */
#include <3dExterns.h>
#include <3dGrid.h>
#include <3dHermiteCurves.h>
#include <3dHierarchy.h>
#include <3dResources.h>
#include <3dMatrix2Patch.h>
#include <3dQuadratics.h>
#include <3dSolidsPgn.h>
#include <3dSpline2Patch.h>
#include <3dText.h>
#include <Camera.h>
#include <OffScreenPorts.h>
#include <SysEnvirons.h>

/* define this to observe the offscreen drawing effects */
#undef  _OFFSCREEN_

/* Define resource related items */
#define RESOURCEFILE “\pLamp.Π.rsrc”
#define WINDOWID 1001

/* Define a few, miscellaneous, fixed point constants */
#define f_0p1  6554L
#define f_0p4  26214L
#define f_0p6  39322L
#define f_3p6  235930L
#define f_6 393216L

/* Prototypes for our functions... very important */
void    main(void);
void    ProduceScene (void);
void    DrawGrid (void);
hCollection MakeLamp (void);
void    GenRotatedSurfaceBody (hGroup hG,short ixP);
void    GenRotatedSurfaceTable(hGroup hG,short ixP);
void    SetRenderingAttributes(pRendAttr pRA,colorFactor r,colorFactor 
g,colorFactor b);
pLighting SetupLighting   (void);

void main()
{
 short  masters = 4;
 EventRecordevt; /* for event polling*/
 WindowPtrwp;
 
#ifndef THINK_C
 UnloadSeg(_DataInit);  /* for MPW C only, get rid of Data Initializer 
after use */
#endif

 MaxApplZone();
 while( masters- )
 MoreMasters();
 FlushEvents(everyEvent, 0);
#ifndef THINK_C
 InitGraf(& QDGLOBALS thePort);
#else
 InitGraf(&thePort);
#endif  THINK_C
 InitFonts();
 InitWindows();
 InitMenus();
 TEInit();
 InitDialogs(0L);

 OpenResFile( RESOURCEFILE );
 SelectWindow( (wp = GetNewCWindow( WINDOWID, (Ptr)0L, 
(WindowPtr)-1L )) );
 SetPort( wp );
 
 Init3d();
 ProduceScene();
 while( !GetNextEvent( mDownMask|keyDownMask, &evt ) );
 
 FlushEvents(everyEvent, 0);
 DisposeWindow(FrontWindow());/* don’t need  */
 ExitToShell();  /* we are out of here NOW!  */
}

void  ProduceScene()
{
 hCollection hC; /* collection storage ref   */
 Point3d Camera = {-f_100,f_45,-f_180}; /* loc */
 Point3d Focus = {f_0,f_0,f_0};  /* focus pt */
 Fixed Lens = Lens80mm; /*angle of view/magnification */
 pLightingpL;  /* lighting information */
 WindowPtrtheWindow = FrontWindow();
 GrafPtrosGP;

 /*Generate the scene objects */
 hC = MakeLamp();
 
 AimCamera3d( Camera.x,Camera.y,Camera.z, Focus.x,Focus.y,Focus.z, Lens 
);
 
 /*Setup ambient & point light sources */
 pL = SetupLighting();

#ifdef  _OFFSCREEN_
 /*Create offscreen drawing port */
 if( ColorPresent )
 {
 osGP = (GrafPtr)NewOffScreenCPort ( &theWindow->portRect );
 UseOffScreenCPort( (CGrafPtr)osGP );
 }
 else
 {
 osGP = NewOffScreenPort(&theWindow->portRect);
 UseOffScreenPort( osGP );
 }
#endif  _OFFSCREEN_
 
 /* Clear the screen */
 EraseRect( &theWindow->portRect );
 
 DrawGrid();
 
 /*How to render it based on graphics device bit depth */
 if( GDevicePixelBits() > 8 )
 { /* We have a VERY good screen so use ZBuffered rendering method */
 SetAntiAliasing(true);
 xfRenderCollectionPgn( hC, &xFormViewer, pL );
 }
 else
 /*We have only a basic mono, grayscale or 8 bit color screen, so use 
the Paint rendering method */
 xfRenderCollection( hC, &xFormViewer, pL, false );
 
 /*release some of the memory we allocated */
 DisposeCollection( hC );
 DisposPtr( (Ptr)pL );

#ifdef  _OFFSCREEN_
 /*Display offscreen buffer & dispose of it */
 if( ColorPresent )
 {
 ShowOffScreenCPort((CGrafPtr)osGP, theWindow);
 DisposeOffScreenCPort( (CGrafPtr)osGP );
 }
 else
 {
 ShowOffScreenPort( osGP, theWindow );
 DisposeOffScreenPort( osGP );
 }
#endif  _OFFSCREEN_
}

void  DrawGrid(void)
{
 Point3dmin = { -f_16,-f_16,-f_16 };
 Point3dmax = {  f_16, f_16, f_16 };
 Point3dsteps  = { f_8,f_8,f_8 };
 GridOptionsoptions;
 
 options.left  = false;
 options.right = true;
 options.top= false;
 options.bottom  = true;
 options.front = false;
 options.back  = true;
 options.gridPat = GP_BLACK;
 options.connectX= false;
 options.connectY= false;
 options.connectZ= false;
 ForeColor( blueColor );
 xfGrid(min, max, steps, options, &xFormViewer);
 ForeColor( blackColor );
 xFormCombined = xFormViewer;
 TextFace( bold );
 TextFont( geneva );
 TextSize( 12 );
 DrawString3d(min.x,f_0,max.z,”\pX”,centerAlign);
 DrawString3d(f_0,max.y,max.z,”\pY”,centerAlign);
 DrawString3d(f_0,min.y,min.z,”\pZ”,centerAlign);
}

hCollection MakeLamp()
{
 hCollection hC; /*collection storage ref */
 hGroup hG; /* group storage ref */
 RendAttr RA;    /* working copy of rendering attributes*/

 hC = NewCollection( 2 );/* allocate storage for collection*/
 hG = NewGroup( 4 ); /* ditto for the group and patches*/
 
 (**hC).hG[0] = hG;/* put group handle in collection*/
 
 /*Make the lamp body */
 GenRotatedSurfaceBody( hG, 0 );

 /*Now a cylinder for the bulb support */
 SetRenderingAttributes( &RA, 32767,32767,32767 );
 SetInstanceReferenceFrame(f_0, f_0, f_0, f_1, f_1, f_1, f_0, Int2Fix(12), 
f_0);
 SolidCylinder( 8,f_0p25,f_0p25,Int2Fix(12),f_8,false,hG,1,RA,&xFormInstance);

 /*The light bulb itself */
 SetRenderingAttributes(&RA, 65535, 65535, 65535);
 SetInstanceReferenceFrame(f_0, f_0, f_0, f_2, f_2 + f_0p5, f_2, f_0, 
Int2Fix(14), f_0);
 SolidSphere(9,9,f_1,Int2Fix(9),false,hG,2,RA,&xFormInstance);

 /*And the lamp’s shade */
 SetRenderingAttributes(&RA, 42000,42000,42000);
 RA.transparency = f_0p25;
 RA.framed= true;
 SetInstanceReferenceFrame(f_0, f_0, f_0, f_1, f_1, f_1, f_0, Int2Fix(12), 
f_0);
 SolidCylinder( 8,f_3,f_10,Int2Fix(12),f_8,false,hG,3,RA,&xFormInstance);

 /*A table to set it on  */
 hG = NewGroup( 1 ); /* alloc group & patches */
 (**hC).hG[1] = hG; /* put group handle in collection */ 
 GenRotatedSurfaceTable(hG,0);

 return hC;
}

void  GenRotatedSurfaceBody(hGroup hG,short ixP)
{
 int    nDataPts = 8;
 Point3dDataPt[] =
 {
 {f_1,f_0,f_0}
 , {f_2,f_1,f_0}
 , {f_3,f_3,f_0}
 , {f_2,f_4,f_0}
 , {f_2,f_5,f_0}
 , {f_1,f_6,f_0}
 , {f_0,f_4,f_0}
 , {f_0,f_2,f_0}
 };
 Point3daxis = {f_0,f_1,f_0}; /* rotation axis */
 RendAttr RA;    /* rendering attributes */
 
 int    nPts;
 Point3d*pPts;
 
HermiteCurve3d(HERMITE_CLOSEDCURVE, 3, nDataPts, DataPt, &nPts, &pPts);
 SetInstanceReferenceFrame( f_0, f_0, f_0, f_2, f_3, f_2,
 f_0,-Int2Fix(9),f_0);
 SetRenderingAttributes(&RA, 32767, 32767, 42000);
 RotateToSurface
 ( f_0, f_360, axis, 12,
 nPts, pPts,
 hG,ixP,RA, &xFormInstance
 );
 DisposPtr( (Ptr)pPts );
}

void  GenRotatedSurfaceTable(hGroup hG,short ixP)
{
 int    nDataPts = 5;
 Point3dDataPt[] =
 {
 {f_0  ,-f_0p6,f_0}
 , {f_3p6,-f_0p6,f_0}
 , {f_3p6,-f_0p4,f_0}
 , {f_3  , f_0  ,f_0}
 , {f_0  , f_0  ,f_0}
 };
 Point3daxis = {f_0,f_1,f_0}; /* rotation axis */
 RendAttr RA;    /* rendering attributes */
 
 SetInstanceReferenceFrame(f_0, f_0, f_0, f_6, f_2, f_6, f_0, -Int2Fix(9),f_0);
#undef  _WOOD_
#ifdef  _WOOD_
 SetRenderingAttributes(&RA, 58000,36000,18000);
 RA.framed= true;
 RA.frameColor.red = 65000;
 RA.frameColor.green =  57000;
 RA.frameColor.blue= 18000;
 RA.normalVisibility =  true;
 RA.texture = TX_WOOD;
 SetPt3d( &RA.tx[TXI_WOOD].txRotations, Int2Fix(85), Int2Fix(30), f_0 
);
 SetPt3d( &RA.tx[TXI_WOOD].txScalars, f_2  f_0p5, f_2 + f_0p5, f_2 + 
f_0p5 );
 SetPt3d( &RA.tx[TXI_WOOD].txTranslations, f_0, f_0, f_0 );
 RA.tx[TXI_WOOD].txArgument[0] = 0;
 /* do not add noise values */
 RA.tx[TXI_WOOD].txArgument[1] = f_0p6;
 /* lightest grain */
 RA.tx[TXI_WOOD].txArgument[2] = f_0p5;
 /* darkest grain*/
 RA.tx[TXI_WOOD].txArgument[3] = 0;
 /* not used for wood texture */
#else // _ROCK_
 SetRenderingAttributes(&RA, 65000,65000,65000);
 RA.framed= true;
 RA.frameColor.red = 65000;
 RA.frameColor.green =  47000;
 RA.frameColor.blue=  3000;
 RA.normalVisibility =  true;
 RA.texture = TX_ROCK;
 SetPt3d( &RA.tx[TXI_ROCK].txRotations, Int2Fix(30),Int2Fix(0),Int2Fix(20) 
);
 SetPt3d( &RA.tx[TXI_ROCK].txScalars, f_1,f_1,f_1 );
 SetPt3d( &RA.tx[TXI_ROCK].txTranslations, f_45,f_0,f_0 );
 RA.tx[TXI_ROCK].txArgument[0] = fixratio(16,1);
 RA.tx[TXI_ROCK].txArgument[1] = fixratio(4,10);   
 RA.tx[TXI_ROCK].txArgument[2] = fixratio(8,10);   
 RA.tx[TXI_ROCK].txArgument[3] = fixratio(7,10);
 RA.diffusion    = fixratio(15,100);
 RA.specIndex    = 30;
 RA.specularity  = fixratio(85,100);
 RA.ambience=  fixratio(1,100);
#endif  _WOOD_
 RotateToSurface
 ( f_0, f_360, axis, 8,
 nDataPts, DataPt,
 hG,ixP,RA, &xFormInstance
 );
}

void  SetRenderingAttributes(pRendAttr pRA, colorFactor r, colorFactor 
g,colorFactor b)
{
 pRA->R = r;
 pRA->G = g;
 pRA->B = b;
 pRA->frameColor.red =  32767;
 pRA->frameColor.green  = 32767;
 pRA->frameColor.blue=  32767;
 pRA->lightSource= false;
 pRA->distanceEffect =  true;
 pRA->ambientEffect= true;
 pRA->normalVisibility  = false;
 pRA->framed=  false;
 pRA->patterned  = true;
 pRA->grayScaled = false;
 pRA->texture    = TX_NONE;
 pRA->diffusion  = f_0p5;
 pRA->specIndex  = 20;
 pRA->specularity= f_0p25;
 pRA->ambience   = f_0p1;
 pRA->absorption = 0;
 pRA->translucence = 0;
 pRA->refraction = 0;
 pRA->transparency = 0;
}
pLighting SetupLighting()
{
 pLightingpL;
 LtSource LS[3];

 /*create light sources */
 Set3dLtSource
 ( &LS[0],65535,65535,65535,f_0p1,
 Int2Fix(  0 ), Int2Fix( 14 ), Int2Fix( 0 )    
 );
 Set3dLtSource
 ( &LS[1],32767, 32767, 32767,f_1+f_0p5,
 Int2Fix( 180 ), Int2Fix( 180 ), Int2Fix( -80 )
 );
 Set3dLtSource
 ( &LS[2],32767, 65535, 65535,fixratio(29,10),
 Int2Fix( -200 ), Int2Fix(  180 ), Int2Fix(  200 )
 );

 /*set ambient light and store point sources */
 pL = NewLighting(32767, 32767, 32767,fixratio(5,100), 3, LS );
 
 /*transform its coordinates into the viewer’s (camera’s) reference frame 
*/
 TransformLighting(pL,&xFormViewer);

 /*apply the ambient light color to the background (if we have color) 
*/
 if( ColorPresent )
 RGBBackColor( &pL->color );
 return pL;
}


 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Posterino 4.4 - Create posters, collages...
Posterino offers enhanced customization and flexibility including a variety of new, stylish templates featuring grids of identical or odd-sized image boxes. You can customize the size and shape of... Read more
Chromium 119.0.6044.0 - Fast and stable...
Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all Internet users to experience the web. List of changes available here. Version for Apple... Read more
Spotify 1.2.21.1104 - Stream music, crea...
Spotify is a streaming music service that gives you on-demand access to millions of songs. Whether you like driving rock, silky R&B, or grandiose classical music, Spotify's massive catalogue puts... Read more
Tor Browser 12.5.5 - Anonymize Web brows...
Using Tor Browser you can protect yourself against tracking, surveillance, and censorship. Tor was originally designed, implemented, and deployed as a third-generation onion-routing project of the U.... Read more
Malwarebytes 4.21.9.5141 - Adware remova...
Malwarebytes (was AdwareMedic) helps you get your Mac experience back. Malwarebytes scans for and removes code that degrades system performance or attacks your system. Making your Mac once again your... Read more
TinkerTool 9.5 - Expanded preference set...
TinkerTool is an application that gives you access to additional preference settings Apple has built into Mac OS X. This allows to activate hidden features in the operating system and in some of the... Read more
Paragon NTFS 15.11.839 - Provides full r...
Paragon NTFS breaks down the barriers between Windows and macOS. Paragon NTFS effectively solves the communication problems between the Mac system and NTFS. Write, edit, copy, move, delete files on... Read more
Apple Safari 17 - Apple's Web brows...
Apple Safari is Apple's web browser that comes bundled with the most recent macOS. Safari is faster and more energy efficient than other browsers, so sites are more responsive and your notebook... Read more
Firefox 118.0 - Fast, safe Web browser.
Firefox offers a fast, safe Web browsing experience. Browse quickly, securely, and effortlessly. With its industry-leading features, Firefox is the choice of Web development professionals and casual... Read more
ClamXAV 3.6.1 - Virus checker based on C...
ClamXAV is a popular virus checker for OS X. Time to take control ClamXAV keeps threats at bay and puts you firmly in charge of your Mac’s security. Scan a specific file or your entire hard drive.... Read more

Latest Forum Discussions

See All

‘Monster Hunter Now’ October Events Incl...
Niantic and Capcom have just announced this month’s plans for the real world hunting action RPG Monster Hunter Now (Free) for iOS and Android. If you’ve not played it yet, read my launch week review of it here. | Read more »
Listener Emails and the iPhone 15! – The...
In this week’s episode of The TouchArcade Show we finally get to a backlog of emails that have been hanging out in our inbox for, oh, about a month or so. We love getting emails as they always lead to interesting discussion about a variety of topics... | Read more »
TouchArcade Game of the Week: ‘Cypher 00...
This doesn’t happen too often, but occasionally there will be an Apple Arcade game that I adore so much I just have to pick it as the Game of the Week. Well, here we are, and Cypher 007 is one of those games. The big key point here is that Cypher... | Read more »
SwitchArcade Round-Up: ‘EA Sports FC 24’...
Hello gentle readers, and welcome to the SwitchArcade Round-Up for September 29th, 2023. In today’s article, we’ve got a ton of news to go over. Just a lot going on today, I suppose. After that, there are quite a few new releases to look at... | Read more »
‘Storyteller’ Mobile Review – Perfect fo...
I first played Daniel Benmergui’s Storyteller (Free) through its Nintendo Switch and Steam releases. Read my original review of it here. Since then, a lot of friends who played the game enjoyed it, but thought it was overpriced given the short... | Read more »
An Interview with the Legendary Yu Suzuk...
One of the cool things about my job is that every once in a while, I get to talk to the people behind the games. It’s always a pleasure. Well, today we have a really special one for you, dear friends. Mr. Yu Suzuki of Ys Net, the force behind such... | Read more »
New ‘Marvel Snap’ Update Has Balance Adj...
As we wait for the information on the new season to drop, we shall have to content ourselves with looking at the latest update to Marvel Snap (Free). It’s just a balance update, but it makes some very big changes that combined with the arrival of... | Read more »
‘Honkai Star Rail’ Version 1.4 Update Re...
At Sony’s recently-aired presentation, HoYoverse announced the Honkai Star Rail (Free) PS5 release date. Most people speculated that the next major update would arrive alongside the PS5 release. | Read more »
‘Omniheroes’ Major Update “Tide’s Cadenc...
What secrets do the depths of the sea hold? Omniheroes is revealing the mysteries of the deep with its latest “Tide’s Cadence" update, where you can look forward to scoring a free Valkyrie and limited skin among other login rewards like the 2nd... | Read more »
Recruit yourself some run-and-gun royalt...
It is always nice to see the return of a series that has lost a bit of its global staying power, and thanks to Lilith Games' latest collaboration, Warpath will be playing host the the run-and-gun legend that is Metal Slug 3. [Read more] | Read more »

Price Scanner via MacPrices.net

Clearance M1 Max Mac Studio available today a...
Apple has clearance M1 Max Mac Studios available in their Certified Refurbished store for $270 off original MSRP. Each Mac Studio comes with Apple’s one-year warranty, and shipping is free: – Mac... Read more
Apple continues to offer 24-inch iMacs for up...
Apple has a full range of 24-inch M1 iMacs available today in their Certified Refurbished store. Models are available starting at only $1099 and range up to $260 off original MSRP. Each iMac is in... Read more
Final weekend for Apple’s 2023 Back to School...
This is the final weekend for Apple’s Back to School Promotion 2023. It remains active until Monday, October 2nd. Education customers receive a free $150 Apple Gift Card with the purchase of a new... Read more
Apple drops prices on refurbished 13-inch M2...
Apple has dropped prices on standard-configuration 13″ M2 MacBook Pros, Certified Refurbished, to as low as $1099 and ranging up to $230 off MSRP. These are the cheapest 13″ M2 MacBook Pros for sale... Read more
14-inch M2 Max MacBook Pro on sale for $300 o...
B&H Photo has the Space Gray 14″ 30-Core GPU M2 Max MacBook Pro in stock and on sale today for $2799 including free 1-2 day shipping. Their price is $300 off Apple’s MSRP, and it’s the lowest... Read more
Apple is now selling Certified Refurbished M2...
Apple has added a full line of standard-configuration M2 Max and M2 Ultra Mac Studios available in their Certified Refurbished section starting at only $1699 and ranging up to $600 off MSRP. Each Mac... Read more
New sale: 13-inch M2 MacBook Airs starting at...
B&H Photo has 13″ MacBook Airs with M2 CPUs in stock today and on sale for $200 off Apple’s MSRP with prices available starting at only $899. Free 1-2 day delivery is available to most US... Read more
Apple has all 15-inch M2 MacBook Airs in stoc...
Apple has Certified Refurbished 15″ M2 MacBook Airs in stock today starting at only $1099 and ranging up to $230 off MSRP. These are the cheapest M2-powered 15″ MacBook Airs for sale today at Apple.... Read more
In stock: Clearance M1 Ultra Mac Studios for...
Apple has clearance M1 Ultra Mac Studios available in their Certified Refurbished store for $540 off original MSRP. Each Mac Studio comes with Apple’s one-year warranty, and shipping is free: – Mac... Read more
Back on sale: Apple’s M2 Mac minis for $100 o...
B&H Photo has Apple’s M2-powered Mac minis back in stock and on sale today for $100 off MSRP. Free 1-2 day shipping is available for most US addresses: – Mac mini M2/256GB SSD: $499, save $100 –... Read more

Jobs Board

Licensed Dental Hygienist - *Apple* River -...
Park Dental Apple River in Somerset, WI is seeking a compassionate, professional Dental Hygienist to join our team-oriented practice. COMPETITIVE PAY AND SIGN-ON Read more
Sublease Associate Optometrist- *Apple* Val...
Sublease Associate Optometrist- Apple Valley, CA- Target Optical Date: Sep 30, 2023 Brand: Target Optical Location: Apple Valley, CA, US, 92307 **Requisition Read more
*Apple* / Mac Administrator - JAMF - Amentum...
Amentum is seeking an ** Apple / Mac Administrator - JAMF** to provide support with the Apple Ecosystem to include hardware and software to join our team and Read more
Child Care Teacher - Glenda Drive/ *Apple* V...
Child Care Teacher - Glenda Drive/ Apple ValleyTeacher Share by Email Share on LinkedIn Share on Twitter Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.