![]() |
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
To access the contents, click the chapter and section titles.
Cutting Edge Direct 3D Programming
The Spotlight Demo Beam FunctionsThe Spotlight demo provides a Beam menu which allows the spotlights umbra and penumbra angles to be modified. The six member functions that provide this functionality follow: void SpotlightWin::OnBeamNormal() { spotlight->SetUmbra( D3DVALUE(0.2) ); spotlight->SetPenumbra( D3DVALUE(0.4) ); beamwidth=BEAM_NORMAL; } void SpotlightWin::OnBeamNarrow() { spotlight->SetUmbra( D3DVALUE(0.1) ); spotlight->SetPenumbra( D3DVALUE(0.2) ); beamwidth=BEAM_NARROW; } void SpotlightWin::OnBeamWide() { spotlight->SetUmbra( D3DVALUE(0.4) ); spotlight->SetPenumbra( D3DVALUE(0.8) ); beamwidth=BEAM_WIDE; } void SpotlightWin::OnUpdateBeamNormal(CCmdUI* pCmdUI) { pCmdUI->SetCheck( beamwidth==BEAM_NORMAL ); } void SpotlightWin::OnUpdateBeamNarrow(CCmdUI* pCmdUI) { pCmdUI->SetCheck( beamwidth==BEAM_NARROW ); } void SpotlightWin::OnUpdateBeamWide(CCmdUI* pCmdUI) { pCmdUI->SetCheck( beamwidth==BEAM_WIDE ); } One of the first three member functions is called when an entry on the Beam menu is selected. The SetUmbra() and SetPenumbra() functions are used to modify the spotlights characteristics. Also, the beamwidth data member is assigned according to which set of spotlight settings is currently in effect. This data member is used by the second three member functions to activate a check mark for the current spotlight settings. Multiple Light SourcesThe demos that weve looked at so far in this chapter are each intended to familiarize you with a specific light source type. Each demo uses one light source to clearly illustrate the light sources qualities. This does not mean, however, that you cant use more than one light source in your programs. Light sources can be used in any combination, and programs can use multiple instances of the same light source type as well. ShadowsThis chapter is titled Light Sources And Shadows, and weve talked about the five light source types that Direct3D supports, so its time to talk about shadows. Before we begin, however, it should be pointed out that in Direct3D, light sources and shadows have little to do with each other. In Direct3D, a shadow is an object that can be inserted into a scene to approximate the behavior of a real shadow. The Shadow DemoThe Shadow demo creates a scene where a fork is hovering above a rectangular platform. A light source illuminates the fork and the platform, and the forks shadow is cast onto the platform (or seems to be). The Shadow demo appears in Figure 6.10.
The Shadow demo demonstrates the following techniques:
The ShadowWin ClassThe bulk of the Shadow demos functionality is provided by the ShadowWin class: class ShadowWin : public RMWin { public: ShadowWin(); BOOL CreateScene(); protected: //{{AFX_MSG(ShadowWin) 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 DECLARE_MESSAGE_MAP() private: static void AdjustSpin(LPDIRECT3DRMFRAME frame, void*, D3DVALUE); private: LPDIRECT3DRMMESHBUILDER floorbuilder; LPDIRECT3DRMMESHBUILDER forkbuilder; }; The class provides two public member functions: a constructor and the CreateScene() function. It also declares the six Render menu functions that appear in the other demos. The AdjustSpin() function is a callback function that will be used to change the forks movement as the demo executes. The callback function is installed by the CreateScene() function. Finally, two data members are declared. Both data members are pointers to the Direct3DRMMeshBuilder interface. The pointers will be used during scene creation and by the Render menu message handler functions.
|
![]() |
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. |