3D Graphics Programming with QuickDraw 3D
TQ3PointLightData
and then call Q3PointLight_New
, as shown in Listing 8-1.Listing 8-1 Creating a new point light
TQ3LightObject MyNewPointLight (void) { TQ3LightData myLightData; TQ3PointLightData myPointLightData; TQ3LightObject myPointLight; TQ3Point3D pointLocation = {-20.0, 0.0, 20.0}; TQ3ColorRGB WhiteLight = { 1.0, 1.0, 1.0 }; /*Set up light data for a point light.*/ myLightData.isOn = kQ3True; myLightData.brightness = 1.0; myLightData.color = WhiteLight; myPointLightData.lightData = myLightData; myPointLightData.castsShadows = kQ3False; myPointLightData.attenuation = kQ3AttenuationTypeNone; myPointLightData.location = pointLocation; /*Create a point light.*/ myPointLight = Q3PointLight_New(&myPointLightData); return (myPointLight); }As you can see, the
MyNewPointLight
function defined in Listing 8-1 simply fills in the myPointLight
structure and then calls Q3PointLight_New
. MyNewPointLight
returns to its caller either a reference to the new light (if Q3PointLight_New
succeeds) or the value NULL
(if Q3PointLight_New
fails).Q3LightGroup_New
to create a new (empty) light group and Q3Group_AddObject
to add lights to that group. Then you need to call Q3View_SetLightGroup
to attach the light group to a view. Finally, you need to create an illumination shader that specifies the kind of illumination model you want applied to objects in the model. For example, to provide Phong illumination on the objects in a model, you can create an illumination shader by calling Q3PhongIllumination_New
. The illumination shader is not explicitly associated with the view. Instead, you specify the illumination shader by calling Q3Shader_Submit
in your rendering loop. See the chapter "Shader Objects" for details.
Let us know what you think of these prototype pages.
Generated with Harlequin WebMaker