Project lights1

This chapter is a summary of a Direct3D-Tutorial from Microsoft: Tutorial4. You find the tutorial here: C:\DXSDK\Samples\Managed\Direct3D\Tutorials.

Main Menu after starting VS 2008: File → New Project... → Visual Studio installed templates: Windows Forms Application
Name: lights1 → Location: C:\temp → Create directory for solution: switch it off → OK
Delete the files Program.cs and Form1.Designer.cs and the content of Form1.cs, as described in the chapters 2DCisC1 to 2DCisC4.

If You find no Solution Explorer-window, open it via the main menu: View → Solution Explorer.
Inside the Solution Explorer-window click the plus-sign in front of lights1. A tree opens. Look for the branch "References". Right-click References and left-click Add Reference.... An Add Reference dialog box opens. Scroll down to the component name: Microsoft.DirectX Version 1.0.2902.0.
Highlight this reference by a left-click and (holding the Strg-key pressed) the reference Microsoft.DirectX.Direct3D Version 1.0.2902.0 somewhere below. Quit the Add Reference dialog box with OK.
Check if both references Microsoft.DirectX and Microsoft.DirectX.Direct3D are now visible inside the Solution Explorer window underneath lights1 → References.

If You use Visual Studio 2008 Professional You should switch off the vexatious automatic format- and indent- mechanism of the code editor before You copy the following code to Form1.cs (otherwise all the code will be reformatted into chaos):
1. Main menu of Visual Studio 2008 Professional: click menu "Tools".
2. A DropDown-menu appears. Click "Options...".
3. An Options dialog box appears.
4. Click the branch "Projects and Solutions". Click "General". Redirect all three paths to C:\temp.
5. Click the branch "Text Editor", then click "C#".
6. A sub-tree appears with the branches "General, Tabs, Advanced, Formatting, IntelliSense".
7. Click "Tabs". Change "Indenting" to None, "Tab size" and "Indent size" to 1 and switch on the option "Insert spaces".
8. Inside the sub-tree "C#" click the plus-sign in front of "Formatting" and change all "Formatting"-branches as follows:
"General": switch off all CheckBoxes, "Indentation": switch off all CheckBoxes, "New Lines": switch off all CheckBoxes, "Spacing": switch off all CheckBoxes, "Wrapping": switch on both CheckBoxes.
9. Leave the dialog box with button "OK".

Exercises

1. In the 5th next to the last line of protected static void OnTimer( Object myObject, EventArgs myEventArgs ) replace TriangleStrip by LineStrip and try out how the vertex framework changes when You vary the constant N (in the 5th line of the class declaration of Form1) from 6 to 8, to 12, to 48 etc. to 100.
2. Slow the animation down by increasing myTimer.Interval = 100; inside the constructor.
3. Accelerate the animation by increasing fAngle += 0.5f; in OnTimer.
4. Rotate the cylinder around other axes as (1,1,1) in OnTimer.
5. Light the cylinder with another diffuse color.
6. Light the cylinder with another ambient color.
7. Vary the position of the light source: from top only, from bottom only, from left only etc.
8. Step back with the eye point from ( 0f, 0f,-4f ) to ( 0f, 0f,-100f ) and get closer with ( 0f, 0f,-2f ).
9. Read the comments C3DCisC2_Comment.htm and try to understand the sense of the code lines.
10. You can find more explanations and comments about this chapter here: http://msdn.microsoft.com/en-us/library/default.aspx.Caution: Mozilla Firefox doesn't correctly display the tree on the left side. Use the Internet Explorer here !
Click trough the tree on the left side:
Win32 and COM Development → Graphics and Multimedia → DirectX → SDK Documentation → DirectX SDK Managed → DirectX SDK → Introducing DirectX 9.0 → Direct3D Graphics → Getting Started with Direct3D → Direct3D Tutorials → Tutorial 4: Using Materials and Lights.