static TQ3GroupObject QD3DSupport_NewLights() { TQ3GroupPosition myGroupPosition; TQ3GroupObject myLightList; TQ3LightData myLightData; TQ3LightObject myAmbientLight = NULL; TQ3ColorRGB WhiteLight = { 1.0F, 1.0F, 1.0F }; /* Set up light data for ambient light. This light data will be used for point and fill light also. */ myLightData.isOn = kQ3True; myLightData.color = WhiteLight; /* Create ambient light. */ myLightData.brightness = 0.8F; myAmbientLight = Q3AmbientLight_New(&myLightData); if ( myAmbientLight == nil ) { goto bail; } /* Create light group and add each of the lights into the group. */ myLightList = Q3LightGroup_New(); if ( myLightList == nil ) { goto bail; } myGroupPosition = Q3Group_AddObject(myLightList, myAmbientLight); if ( myGroupPosition == 0 ) { goto bail; } Q3Object_Dispose( myAmbientLight ) ; /* Done! */ return ( myLightList ); bail: /* If any of the above failed, then return nothing! */ if (myAmbientLight != NULL) { Q3Object_Dispose( myAmbientLight ) ; } return ( nil ); }
TQ3GroupObject MyNewLights() { TQ3GroupPosition myGroupPosition; TQ3GroupObject myLightList; TQ3LightData myLightData; TQ3PointLightData myPointLightData; TQ3DirectionalLightData myDirectionalLightData; TQ3LightObject myAmbientLight, myPointLight, myFillLight; TQ3Point3D pointLocation = { -10.0F, 0.0F, 10.0F }; TQ3Vector3D fillDirection = { 10.0F, 0.0F, 10.0F }; TQ3ColorRGB WhiteLight = { 1.0F, 1.0F, 1.0F }; // Set up light data for ambient light. This light data will be used for point and fill // light also. myLightData.isOn = kQ3True; myLightData.color = WhiteLight; // Create ambient light. myLightData.brightness = .25F; myAmbientLight = Q3AmbientLight_New(&myLightData); if ( myAmbientLight == NULL ) goto bail; // Create point light. myLightData.brightness = 1.0F; myPointLightData.lightData = myLightData; myPointLightData.castsShadows = kQ3False; myPointLightData.attenuation = kQ3AttenuationTypeNone; myPointLightData.location = pointLocation; myPointLight = Q3PointLight_New(&myPointLightData); if ( myPointLight == NULL ) goto bail; // Create fill light. myLightData.brightness = .3F; myDirectionalLightData.lightData = myLightData; myDirectionalLightData.castsShadows = kQ3False; myDirectionalLightData.direction = fillDirection; myFillLight = Q3DirectionalLight_New(&myDirectionalLightData); if ( myFillLight == NULL ) goto bail; // Create light group and add each of the lights into the group. myLightList = Q3LightGroup_New(); if ( myLightList == NULL ) goto bail; myGroupPosition = Q3Group_AddObject(myLightList, myAmbientLight); if ( myGroupPosition == 0 ) goto bail; myGroupPosition = Q3Group_AddObject(myLightList, myPointLight); if ( myGroupPosition == 0 ) goto bail; myGroupPosition = Q3Group_AddObject(myLightList, myFillLight); if ( myGroupPosition == 0 ) goto bail; Q3Object_Dispose( myAmbientLight ) ; Q3Object_Dispose( myPointLight ) ; Q3Object_Dispose( myFillLight ) ; // Done! return ( myLightList ); bail: // If any of the above failed, then return nothing! return ( NULL ); }