Documentation Archive Developer
Search

ADC Home > Reference Library > Technical Q&As > Legacy Documents > Graphics & Imaging >

Legacy Documentclose button

Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.

Current information on this Reference Library topic can be found here:

NOTE: This Technical Q&A has been retired. Please see the Technical Q&As page for current documentation.

Shading Using Trigrids

Q: I am trying to shade a 3D landscape using Trigrids, but I can't get this to work, and the examples in the documentation are not very helpful. The landscapes look fine as wire frames, but when I turn on shading, I just get one continuous gray blob. If I try to use a more advanced shading technique (e.g., pixmap), my application crashes.

A: Try setting up a surface shader (either Phong or Lambert). Assuming you are holding your displayable objects in a display group or an ordered group, you can do this in the following way:


//----------------------------------------------------------------------
// attach a shader to the group
TQ3Status MyAddShaderToGroup( TQ3GroupObject group )
{
	TQ3ShaderObject	illuminationShader = Q3PhongIllumination_New();
	Q3Group_AddObject(group, illuminationShader);
	Q3Object_Dispose(illuminationShader);
	return(kQ3Success);
}

Alternatively, you can create a shader object, and draw it before any of your geometries in your submit procedure. Remember that if you are using a plain display group, the shader object must be the first object placed in the group, or all the objects that are put in the group before the shader will be flat-shaded (this does not apply to ordered display groups).

The latest samples, libraries, and headers are available on the Developer CD. See also Apple's QuickDraw 3D home page for the most current 3D development information.

[Jul 15 1995]