[Rpgworldmodel-commits] SF.net SVN: rpgworldmodel: [11] src/test_applications/ItemsViewer
Status: Inactive
Brought to you by:
deadwood_pl
From: <pos...@us...> - 2006-07-06 14:56:39
|
Revision: 11 Author: poserdev Date: 2006-07-06 07:56:26 -0700 (Thu, 06 Jul 2006) ViewCVS: http://svn.sourceforge.net/rpgworldmodel/?rev=11&view=rev Log Message: ----------- Cool! Now we all can rotate/scale the object. Someone did a great job there :P Modified Paths: -------------- src/test_applications/ItemsViewer/Form1.Designer.cs src/test_applications/ItemsViewer/Form1.cs src/test_applications/ItemsViewer/ItemsViewer.csproj Added Paths: ----------- src/test_applications/ItemsViewer/Camera.cs Added: src/test_applications/ItemsViewer/Camera.cs =================================================================== --- src/test_applications/ItemsViewer/Camera.cs (rev 0) +++ src/test_applications/ItemsViewer/Camera.cs 2006-07-06 14:56:26 UTC (rev 11) @@ -0,0 +1,34 @@ +using System; + +namespace ItemsViewer +{ + public struct Camera + { + private int ZMax; + public int Z; + private int ZMin; + public float RotationY; + public float RotationX; + + public Camera(int zMax, int z, int zMin) + { + this.ZMax = zMax; + this.Z = z; + this.ZMin = zMin; + this.RotationY = 0; + this.RotationX = 0; + } + + public void ZoomIn() + { + if ((ZMin + 1) != Z) + Z--; + } + + public void ZoomOut() + { + if ((ZMax - 1) != Z) + Z++; + } + } +} \ No newline at end of file Modified: src/test_applications/ItemsViewer/Form1.Designer.cs =================================================================== --- src/test_applications/ItemsViewer/Form1.Designer.cs 2006-07-06 13:53:21 UTC (rev 10) +++ src/test_applications/ItemsViewer/Form1.Designer.cs 2006-07-06 14:56:26 UTC (rev 11) @@ -39,6 +39,7 @@ this.Name = "Form1"; this.Text = "Form1"; this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyDown); this.ResumeLayout(false); } Modified: src/test_applications/ItemsViewer/Form1.cs =================================================================== --- src/test_applications/ItemsViewer/Form1.cs 2006-07-06 13:53:21 UTC (rev 10) +++ src/test_applications/ItemsViewer/Form1.cs 2006-07-06 14:56:26 UTC (rev 11) @@ -17,6 +17,7 @@ { private Device m_Device; private SwordObject m_SceenObject; + private Camera m_Camera; public Form1() { @@ -32,11 +33,13 @@ { this.m_Device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, 1, 1, 100.0f); - this.m_Device.Transform.View = Matrix.LookAtLH(new Vector3(0, 0, 20), new Vector3(), + + this.m_Device.Transform.View = Matrix.LookAtLH(new Vector3(0, 0, this.m_Camera.Z), new Vector3(), new Vector3(0, 1, 0)); - this.m_Device.Transform.World = Matrix.RotationZ(Environment.TickCount / 1000.0f) * - Matrix.RotationY(Environment.TickCount / 1000.0f) * Matrix.Scaling(0.02f, 0.02f, 0.02f); + this.m_Device.Transform.World = Matrix.Scaling(0.02f, 0.02f, 0.02f) + * Matrix.RotationY(this.m_Camera.RotationY) * + Matrix.RotationX(this.m_Camera.RotationX); } private void InitializeGraphics() @@ -53,6 +56,8 @@ this.m_SceenObject = new SwordObject(this.m_Device); this.m_SceenObject.LoadMesh(@"Models\Base\Sword\sword.x"); + + this.m_Camera = new Camera(100, 10, 2); } private void Form1_Paint(object sender, PaintEventArgs e) @@ -81,11 +86,29 @@ void Form1_MouseWheel(object sender, MouseEventArgs e) { if (e.Delta > 0) + this.m_Camera.ZoomIn(); + else + this.m_Camera.ZoomOut(); + } + + private void Form1_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Left) { + this.m_Camera.RotationY += 0.05f; } - else + else if (e.KeyCode == Keys.Right) { + this.m_Camera.RotationY -= 0.05f; } + else if (e.KeyCode == Keys.Up) + { + this.m_Camera.RotationX += 0.05f; + } + else if (e.KeyCode == Keys.Down) + { + this.m_Camera.RotationX -= 0.05f; + } } } } \ No newline at end of file Modified: src/test_applications/ItemsViewer/ItemsViewer.csproj =================================================================== --- src/test_applications/ItemsViewer/ItemsViewer.csproj 2006-07-06 13:53:21 UTC (rev 10) +++ src/test_applications/ItemsViewer/ItemsViewer.csproj 2006-07-06 14:56:26 UTC (rev 11) @@ -39,6 +39,7 @@ <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> + <Compile Include="Camera.cs" /> <Compile Include="Form1.cs"> <SubType>Form</SubType> </Compile> @@ -51,6 +52,12 @@ <Compile Include="SceenObject.cs" /> <Compile Include="SwordObject.cs" /> </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="Form1.resx"> + <SubType>Designer</SubType> + <DependentUpon>Form1.cs</DependentUpon> + </EmbeddedResource> + </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |