![]() |
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
To access the contents, click the chapter and section titles.
Cutting Edge Direct 3D Programming
SpotlightsSpotlights produce light in the shape of a cone. The lights position decides the location of the tip of the cone, and the lights orientation decides the location of the base of the cone. Actually, the light that a spotlight produces is better described in terms of two cones: an outer cone and an inner cone. The outer cone determines the area that the spotlight is capable of illuminating. No light falls outside of the outer cone. The inner cone determines the area that receives the lights full illumination. The area between these two cones experiences a gradually fading illuminationfrom full illumination near the inner cone, to no illumination near the outer cone. The inner cone is called the umbra cone. The umbra cone size is determined by the umbra angle. The outer cone is called the penumbra cone. The penumbra cone size is determined by the penumbra angle. The umbra and penumbra cones are illustrated in Figure 6.8.
The Direct3DRMLight interface provides these member functions for the adjustment and inspection of the umbra and penumbra angles:
The Spotlight DemoThe Spotlight demo animates a spotlight over three spherical meshes. The spotlights umbra and penumbra angles can be adjusted with the Spotlight demos Beam menu. The Spotlight demo appears in Figure 6.9.
The Spotlight demo demonstrates the following techniques:
The Spotlight demo uses the Direct3DRMMesh interface instead of the Direct3DRMMeshBuilder interface to demonstrate alternatives to the way that the other demos are written. There is nothing exceptional about the Spotlight demo that requires the added performance benefits that come with the Direct3DRMMesh interface. The SpotlightWin ClassThe Spotlight demo uses the RMWin class as a base class for its SpotlightWin class: class SpotlightWin : public RMWin { public: SpotlightWin(); BOOL CreateScene(); protected: //{{AFX_MSG(SpotlightWin) afx_msg void OnRenderWireframe(); afx_msg void OnRenderFlat(); afx_msg void OnRenderGouraud(); afx_msg void OnUpdateRenderFlat(CCmdUI* pCmdUI); afx_msg void OnUpdateRenderGouraud(CCmdUI* pCmdUI); afx_msg void OnUpdateRenderWireframe(CCmdUI* pCmdUI); afx_msg void OnBeamNormal(); afx_msg void OnBeamNarrow(); afx_msg void OnBeamWide(); afx_msg void OnUpdateBeamNormal(CCmdUI* pCmdUI); afx_msg void OnUpdateBeamNarrow(CCmdUI* pCmdUI); afx_msg void OnUpdateBeamWide(CCmdUI* pCmdUI); //}}AFX_MSG DECLARE_MESSAGE_MAP() private: static void MoveLight(LPDIRECT3DRMFRAME frame, void* arg, D3DVALUE delta); private: LPDIRECT3DRMMESH mesh1, mesh2, mesh3; LPDIRECT3DRMLIGHT spotlight; int beamwidth; }; The SpotlightWin class definition looks quite a bit different than the class definitions for the other demos that weve looked at in this chapter. The first and most obvious difference is that there are more protected member functions. The first six protected functions are familiar from the other demos and are used to implement the demos Render menu. The new functions are used to implement the demos Beam menu. Well look at these functions later. Another difference is the presence of the MoveLight() function declaration. MoveLight() is a callback function that we will use to animate the spotlight. The classs data members are also different. The previous class definitions used a single Direct3DRMMeshBuilder pointer. The SpotlightWin class declares three pointers to the Direct3DRMMesh interface. These pointers are used to access the three sphere meshes used in the demo. The class also declares a Direct3DRMLight pointer. This pointer is used by the member functions that implement the Beam menu. These functions also use the beamwidth data member to store the current spotlight settings.
|
![]() |
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. |