From: <bor...@us...> - 2011-03-02 22:36:11
|
Revision: 272 http://axiomcontrib.svn.sourceforge.net/axiomcontrib/?rev=272&view=rev Author: borrillis Date: 2011-03-02 22:36:04 +0000 (Wed, 02 Mar 2011) Log Message: ----------- ok, really, the sample project Added Paths: ----------- Axiom.SharpGorilla/trunk/src/SharpGorilla.Samples/ Axiom.SharpGorilla/trunk/src/SharpGorilla.Samples/DejaVueSample.cs Axiom.SharpGorilla/trunk/src/SharpGorilla.Samples/Plugin.cs Axiom.SharpGorilla/trunk/src/SharpGorilla.Samples/Properties/ Axiom.SharpGorilla/trunk/src/SharpGorilla.Samples/Properties/AssemblyInfo.cs Axiom.SharpGorilla/trunk/src/SharpGorilla.Samples/SharpGorrilla.Samples.2010.csproj Axiom.SharpGorilla/trunk/src/SharpGorilla.Samples/ThreeDSample.cs Added: Axiom.SharpGorilla/trunk/src/SharpGorilla.Samples/DejaVueSample.cs =================================================================== --- Axiom.SharpGorilla/trunk/src/SharpGorilla.Samples/DejaVueSample.cs (rev 0) +++ Axiom.SharpGorilla/trunk/src/SharpGorilla.Samples/DejaVueSample.cs 2011-03-02 22:36:04 UTC (rev 272) @@ -0,0 +1,127 @@ +#region MIT License +/* +----------------------------------------------------------------------------- +This source file is part of the Jitter Sample +Jitter Physics Engine Copyright (c) 2010 Thorben Linneweber (ad...@ji...) + +This a port for Axiom of samples using Jitter Physics Engine, +developed by Thorben Linneweber and ported by Francesco Guastella (aka romeoxbm). + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +----------------------------------------------------------------------------- +*/ +#endregion + +#region Using Statements + +using System; +using System.Collections.Generic; +using System.Reflection; +using Axiom.Core; +using Axiom.Math; +using Axiom.Samples; +using SharpGorilla; + +#endregion + +namespace SharpGorilla.Samples +{ + + public class DejaVueSample : SdkSample + { + + public const string AtlasName = "dejavue"; + public Real Timer { get; set; } + public Real Timer2 { get; set; } + /// <summary> + /// + /// </summary> + public Screen Screen { get; set; } + public Silverback Silverback { get; set; } + public Layer Layer { get; set; } + public Polygon Poly { get; set; } + public LineList List { get; set; } + public Caption Caption { get; set; } + public SharpGorilla.Rectangle Rectangle { get; set; } + public QuadList QuadList { get; set; } + public MarkupText Markup { get; set; } + + Caption _fps; + //AxiomConsole _console; + + public DejaVueSample() + { + Metadata[ "Title" ] = "SharpGorilla DejaVue Sample"; + Metadata[ "Description" ] = "Demonstrates how to use SharpGorilla with Axiom."; + Metadata[ "Thumbnail" ] = "thumb_gorilla.png"; + Metadata[ "Category" ] = "Gui"; + } + + protected override void SetupContent() + { + // Create Silverback and load in dejavu + Silverback = new Silverback(); + Silverback.LoadAtlas( AtlasName ); + Screen = Silverback.CreateScreen( base.Viewport, AtlasName ); + Real vpW = base.Viewport.ActualWidth; + Real vpH = base.Viewport.ActualHeight; + + // Create our drawing layer + Layer = Screen.CreateLayer(); + Rectangle = Layer.CreateRectangle( 0, 0, vpW, vpH ); + Rectangle.SetBackgroundGradient( Gradient.Diagonal, Converter.ToRGB( 98, 0, 63 ), Converter.ToRGB( 255, 180, 174 ) ); + + Markup = Layer.CreateMarkupText( 9, 5, 5 + 80, "%@24%A Haiku\n%@14%Written by Betajaen%@14%\nAnd ported by Bostich%@9%\nSo many to choose from\nPretty typefaces on Axiom screen\nTime to update Git" ); + Caption = Layer.CreateCaption( 9, vpW - 55, 5 + 80, "9" ); + Caption.Width = 50; + Caption.HorizontalAlign = TextAlignment.Right; + Caption.Color = ColorEx.Yellow; + Caption = Layer.CreateCaption( 14, vpW - 55, 18 + 80, "14" ); + Caption.Width = 50; + Caption.HorizontalAlign = TextAlignment.Right; + + Caption = Layer.CreateCaption( 24, vpW - 55, 33 + 80, "14" ); + Caption.Width = 50; + Caption.HorizontalAlign = TextAlignment.Right; + + _fps = Layer.CreateCaption( 14, 0, vpH - 33, "" ); + //_console = new AxiomConsole(); + //_console.Init( Screen ); + //_console.AddCommand( "version", new AxiomConsole.CommandDelegate( PrintAxiomVersion ) ); + //_console.AddCommand( "make", new AxiomConsole.CommandDelegate( Make ) ); + //_console.AddCommand( "quit", new AxiomConsole.CommandDelegate( Quit ) ); + + base.SetupContent(); + } + + public override void Paused() + { + Layer.Hide(); + + base.Paused(); + } + + public override void Unpaused() + { + Layer.Show(); + + base.Unpaused(); + } + } +} Property changes on: Axiom.SharpGorilla/trunk/src/SharpGorilla.Samples/DejaVueSample.cs ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: Axiom.SharpGorilla/trunk/src/SharpGorilla.Samples/Plugin.cs =================================================================== --- Axiom.SharpGorilla/trunk/src/SharpGorilla.Samples/Plugin.cs (rev 0) +++ Axiom.SharpGorilla/trunk/src/SharpGorilla.Samples/Plugin.cs 2011-03-02 22:36:04 UTC (rev 272) @@ -0,0 +1,45 @@ +#region MIT License +/* +----------------------------------------------------------------------------- +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +----------------------------------------------------------------------------- +*/ +#endregion + +#region Using Statements + +using System; +using Axiom.Samples; + +#endregion + +namespace SharpGorilla.Samples +{ + public class Plugin : SamplePlugin + { + + public override void Initialize() + { + Name = "Sharp Gorilla Samples"; + + AddSample( new DejaVueSample() ); + AddSample( new ThreeDSample() ); + } + } +} Property changes on: Axiom.SharpGorilla/trunk/src/SharpGorilla.Samples/Plugin.cs ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: Axiom.SharpGorilla/trunk/src/SharpGorilla.Samples/Properties/AssemblyInfo.cs =================================================================== --- Axiom.SharpGorilla/trunk/src/SharpGorilla.Samples/Properties/AssemblyInfo.cs (rev 0) +++ Axiom.SharpGorilla/trunk/src/SharpGorilla.Samples/Properties/AssemblyInfo.cs 2011-03-02 22:36:04 UTC (rev 272) @@ -0,0 +1,64 @@ +#region MIT License +/* +----------------------------------------------------------------------------- +This a port for Axiom of samples using SharpGorrilla. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +----------------------------------------------------------------------------- +*/ +#endregion + +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle( "SharpGorrilla.Samples" )] +[assembly: AssemblyDescription( "" )] +[assembly: AssemblyConfiguration( "" )] +[assembly: AssemblyProduct( "SharpGorrilla.Samples" )] +[assembly: AssemblyCompany( "Axiom Rendering Engine Project Team (http://axiom3d.net)" )] +[assembly: AssemblyCopyright( "Copyright © 2003-2011 Axiom Rendering Engine Project Team." )] +[assembly: AssemblyTrademark( "" )] +[assembly: AssemblyCulture( "" )] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible( false )] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid( "85fff7a0-3259-41f2-9cef-f89607122806" )] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion( "1.0.0.0" )] +#if !( XBOX || XBOX360 ) +[assembly: AssemblyFileVersion( "1.0.0.0" )] +#endif + Property changes on: Axiom.SharpGorilla/trunk/src/SharpGorilla.Samples/Properties/AssemblyInfo.cs ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: Axiom.SharpGorilla/trunk/src/SharpGorilla.Samples/SharpGorrilla.Samples.2010.csproj =================================================================== --- Axiom.SharpGorilla/trunk/src/SharpGorilla.Samples/SharpGorrilla.Samples.2010.csproj (rev 0) +++ Axiom.SharpGorilla/trunk/src/SharpGorilla.Samples/SharpGorrilla.Samples.2010.csproj 2011-03-02 22:36:04 UTC (rev 272) @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>8.0.30703</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{53543F70-38CC-4C67-AA11-56F01BC0C9EA}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>SharpGorrilla.Samples</RootNamespace> + <AssemblyName>SharpGorrilla.Samples</AssemblyName> + <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <TargetFrameworkProfile /> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> + <DebugSymbols>true</DebugSymbols> + <OutputPath>..\..\bin\samples\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <DebugType>full</DebugType> + <PlatformTarget>x86</PlatformTarget> + <CodeAnalysisLogFile>..\..\bin\samples\SharpGorrilla.Samples.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile> + <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression> + <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile> + <ErrorReport>prompt</ErrorReport> + <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> + <CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories> + <CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets> + <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories> + <CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> + <OutputPath>..\..\bin\samples\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <Optimize>true</Optimize> + <DebugType>pdbonly</DebugType> + <PlatformTarget>x86</PlatformTarget> + <CodeAnalysisLogFile>bin\Release\SharpGorrilla.Samples.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile> + <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression> + <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile> + <ErrorReport>prompt</ErrorReport> + <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> + <CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories> + <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories> + <CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules> + <CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules> + </PropertyGroup> + <ItemGroup> + <Reference Include="Axiom"> + <HintPath>..\..\lib\Axiom.dll</HintPath> + <Private>False</Private> + </Reference> + <Reference Include="Axiom.Samples.Common"> + <HintPath>..\..\lib\Axiom.Samples.Common.dll</HintPath> + <Private>False</Private> + </Reference> + <Reference Include="SharpInputSystem"> + <HintPath>..\..\lib\SharpInputSystem.dll</HintPath> + <Private>False</Private> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="ThreeDSample.cs" /> + <Compile Include="Plugin.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="DejaVueSample.cs" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\SharpGorilla\SharpGorilla.csproj"> + <Project>{92FF9232-A66F-467B-9285-7855B4C51AD9}</Project> + <Name>SharpGorilla</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\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. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> \ No newline at end of file Property changes on: Axiom.SharpGorilla/trunk/src/SharpGorilla.Samples/SharpGorrilla.Samples.2010.csproj ___________________________________________________________________ Added: svn:eol-style + native Added: Axiom.SharpGorilla/trunk/src/SharpGorilla.Samples/ThreeDSample.cs =================================================================== --- Axiom.SharpGorilla/trunk/src/SharpGorilla.Samples/ThreeDSample.cs (rev 0) +++ Axiom.SharpGorilla/trunk/src/SharpGorilla.Samples/ThreeDSample.cs 2011-03-02 22:36:04 UTC (rev 272) @@ -0,0 +1,331 @@ +#region MIT License +/* +----------------------------------------------------------------------------- +This source file is part of the Jitter Sample +Jitter Physics Engine Copyright (c) 2010 Thorben Linneweber (ad...@ji...) + +This a port for Axiom of samples using Jitter Physics Engine, +developed by Thorben Linneweber and ported by Francesco Guastella (aka romeoxbm). + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +----------------------------------------------------------------------------- +*/ +#endregion + +#region Using Statements + +using System; +using System.Collections.Generic; +using System.Reflection; +using Axiom.Core; +using Axiom.Math; +using Axiom.Samples; +using SharpGorilla; + +#endregion + +namespace SharpGorilla.Samples +{ + + public class ThreeDSample : SdkSample + { + + public class Button + { + public bool IsHovered; + public Caption Caption; + /// <summary> + /// + /// </summary> + /// <param name="x"></param> + /// <param name="y"></param> + /// <param name="text"></param> + /// <param name="layer"></param> + public Button(Real x, Real y, string text, Layer layer) + { + Caption = layer.CreateCaption(14, x, y, text); + Caption.SetSize(64, 25); + Caption.HorizontalAlign = TextAlignment.Center; + Caption.VerticalAlign = VerticalAlignment.Middle; + Caption.BackgroundColor = Converter.ToRGB(255, 255, 255, 32); + IsHovered = false; + } + /// <summary> + /// + /// </summary> + /// <param name="position"></param> + /// <returns></returns> + public bool IsOver(Vector2 position) + { + bool result = Caption.Intersects(position); + if (result && !IsHovered) + { + Caption.BackgroundColor = Converter.ToRGB(255, 255, 255, 128); + } + else if (!result && IsHovered) + { + Caption.BackgroundColor = Converter.ToRGB(255, 255, 255, 28); + } + IsHovered = result; + return result; + } + } + + public struct D3Panel + { + public ScreenRendable Screen; + public SceneNode Node; + public Layer GuiLayer; + public Layer MousePointerLayer; + public SharpGorilla.Rectangle Background; + public SharpGorilla.Rectangle MousePointer; + public Vector2 Size; + public List<Button> Buttons; + + public D3Panel( Silverback silverback, SceneManager sceneMgr, Vector2 size ) + { + Size = size; + Screen = silverback.CreateScreenRendable( Size, "dejavue" ); + Node = sceneMgr.RootSceneNode.CreateChildSceneNode(); + Node.AttachObject( Screen ); + + GuiLayer = Screen.CreateLayer( 0 ); + Background = GuiLayer.CreateRectangle( 0, 0, size.x * 100, size.y * 100 ); + Background.SetBackgroundGradient( Gradient.NorthSouth, Converter.ToRGB( 94, 97, 255, 5 ), Converter.ToRGB( 94, 97, 255, 50 ) ); + Background.SetBorder( 2, Converter.ToRGB( 255, 255, 255, 150 ) ); + MousePointerLayer = Screen.CreateLayer( 15 ); + MousePointer = MousePointerLayer.CreateRectangle( 0, 0, 10, 18 ); + MousePointer.SetBackgroundImage( "mousepointer" ); + Buttons = new List<Button>(); + } + /// <summary> + /// + /// </summary> + /// <param name="ray"></param> + /// <param name="isOver"></param> + /// <returns></returns> + public Button Check( Ray ray, out bool isOver ) + { + isOver = false; + Matrix4 transform = Matrix4.Compose( Node.Position, Node.Scale, Node.Orientation ); + AxisAlignedBox aabb = Screen.BoundingBox; + aabb.Transform( transform ); + Axiom.Math.IntersectResult res = Axiom.Math.Utility.Intersects( ray, aabb ); + + if ( !res.Hit ) + return null; + + Vector3 a, b, c, d = Vector3.Zero; + Vector2 halfSize = Size * 0.5f; + a = transform * new Vector3( -halfSize.x, -halfSize.y, 0 ); + b = transform * new Vector3( halfSize.x, -halfSize.y, 0 ); + c = transform * new Vector3( -halfSize.x, halfSize.y, 0 ); + d = transform * new Vector3( halfSize.x, halfSize.y, 0 ); + + res = Axiom.Math.Utility.Intersects( ray, c, b, a, true, true ); + if ( !res.Hit ) + res = Axiom.Math.Utility.Intersects( ray, c, d, b, true, true ); + if ( !res.Hit ) + return null; + + if ( res.Distance > 6.0f ) + return null; + + isOver = true; + Vector3 hitPos = ( ray.Origin + ( ray.Direction * res.Distance ) ); + Vector3 localPos = transform.Inverse() * hitPos; + + localPos.x += halfSize.x; + localPos.y -= halfSize.y; + localPos.x *= 100; + localPos.y *= 100; + + // Cursor clip + localPos.x = Axiom.Math.Utility.Clamp<Real>( localPos.x, ( Size.x * 100 ) - 10, 0 ); + localPos.y = Axiom.Math.Utility.Clamp<Real>( -localPos.y, ( Size.y * 100 ) - 18, 0 ); + + MousePointer.Position = new Vector2( localPos.x, localPos.y ); + + for ( int i = 0; i < Buttons.Count; i++ ) + { + if ( Buttons[ i ].IsOver( MousePointer.Position ) ) + return Buttons[ i ]; + } + return null; + } + + public Caption CreateCaption( Real x, Real y, string text ) + { + return GuiLayer.CreateCaption( 14, x, y, text ); + } + + public Button CreateButton( Real x, Real y, string text ) + { + Button button = new Button( x, y, text, GuiLayer ); + Buttons.Add( button ); + return button; + } + } + + + private Silverback _silverback; + private Screen _hud; + private Screen _controlPanel; + private Layer _hudLayer; + private Layer _crossHairLayer; + private SharpGorilla.Rectangle _crossHair; + private D3Panel _powerPanel; + private SharpGorilla.Rectangle _powerValue; + private SharpGorilla.Rectangle _powerValueBackground; + private Button _powerUpButton; + private Button _powerDownButton; + private Real _basePower; + private SceneNode _node; + float timer, timer2; + + public ThreeDSample() + { + Metadata[ "Title" ] = "SharpGorilla 3D Sample"; + Metadata[ "Description" ] = "Demonstrates how to use SharpGorilla with Axiom in 3D."; + Metadata[ "Thumbnail" ] = "thumb_gorilla.png"; + Metadata[ "Category" ] = "Gui"; + } + + protected override void SetupContent() + { + _silverback = new Silverback(); + _silverback.LoadAtlas("dejavue"); + + CreateHUD(); + CreateControlPanel(); + + Camera.Position = new Vector3(10, 2, 10); + Camera.LookAt(new Vector3(0, 2, 0)); + Camera.Near = 0.05f; + Camera.Far = 1000; + } + + void CreateHUD() + { + _hud = _silverback.CreateScreen(Viewport, "dejavue"); + _hudLayer = _hud.CreateLayer(); + Caption fakeHealth = _hudLayer.CreateCaption(24, 0, 0, "+ 100"); + fakeHealth.Width = Viewport.ActualWidth - 16; + fakeHealth.Height = Viewport.ActualHeight - 4; + fakeHealth.HorizontalAlign = TextAlignment.Right; + fakeHealth.VerticalAlign = VerticalAlignment.Bottom; + + Caption fakeAmmo = _hudLayer.CreateCaption(24, 16, 0, ": 60"); + fakeAmmo.Width = Viewport.ActualWidth; + fakeAmmo.Height = Viewport.ActualHeight - 4; + fakeAmmo.VerticalAlign = VerticalAlignment.Bottom; + + _crossHairLayer = _hud.CreateLayer(); + _crossHair = _crossHairLayer.CreateRectangle((Viewport.ActualWidth * 0.5f) - 11, (Viewport.ActualHeight * 0.5f) - 11, 22, 22); + _crossHair.SetBackgroundImage("crosshair"); + + + } + + void CreateControlPanel() + { + + _powerPanel = new D3Panel(_silverback, this.SceneManager, new Vector2(4, 1)); + _powerPanel.Node.Position = new Vector3(0, 1.5f, -10); + Caption caption = _powerPanel.CreateCaption(0, 4, "Power Level"); + caption.Width = 400; + caption.HorizontalAlign = TextAlignment.Center; + + _powerValueBackground = _powerPanel.GuiLayer.CreateRectangle(10, 35, 380, 10); + _powerValueBackground.SetBackgroundColor(Converter.ToRGB(255, 255, 255, 100)); + + _powerValue = _powerPanel.GuiLayer.CreateRectangle(10, 35, 200, 10); + _powerValue.SetBackgroundGradient(Gradient.NorthSouth, Converter.ToRGB(255, 255, 255, 200), Converter.ToRGB(64, 64, 64, 200)); + _powerDownButton = _powerPanel.CreateButton(10, 65, "-"); + _powerUpButton = _powerPanel.CreateButton(84, 65, "+"); + } + + public override bool FrameStarted( FrameEventArgs evt ) + { + base.FrameStarted( evt ); + + //_fps.Text = "FPS: " + _renderWindow.LastFPS.ToString() + " , Batches " + _renderWindow.LastBatchCount.ToString(); + timer += evt.TimeSinceLastFrame; + + if (timer > 1.0f / 60) + { + _powerPanel.Node.Yaw(0.0005f); + + timer2 += Axiom.Math.Utility.RangeRandom(0, timer * 10); + timer = 0; + timer = Axiom.Math.Utility.Clamp<Real>(timer, 25, 0); + Real power = _basePower + (Axiom.Math.Utility.Cos(timer2) * 5); + power = Axiom.Math.Utility.Clamp<Real>(power, 380, 0); + _powerValue.Width = power; + } + + return false; + //Vector3 trans = new Vector3(0, 0, 0); + + //if (_input.IsKeyPressed(System.Windows.Forms.Keys.W)) + // trans.z = -1; + //if (_input.IsKeyPressed(System.Windows.Forms.Keys.S)) + // trans.z = 1; + //if (_input.IsKeyPressed(System.Windows.Forms.Keys.A)) + // trans.x = -1; + //if (_input.IsKeyPressed(System.Windows.Forms.Keys.D)) + // trans.x = 1; + + //if (trans.Length != 0) + //{ + // Vector3 pos = _camera.Position; + // pos += _camera.Orientation * (trans * 5.0f) * e.TimeSinceLastFrame; + // pos.y = 2.0f; + // _camera.Position = pos; + //} + } + + public override bool MousePressed( SharpInputSystem.MouseEventArgs evt, SharpInputSystem.MouseButtonID id ) + { + bool isOver = false; + + if ( id == SharpInputSystem.MouseButtonID.Left ) + { + Button button = _powerPanel.Check( Camera.GetCameraToViewportRay( 0.5f, 0.5f ), out isOver ); + //if (isOver) + // _crossHairLayer.Hide(); + //else + // _crossHairLayer.Show(); + + if ( button != null ) + { + if ( button == _powerDownButton ) + { + _basePower -= 1.0f; + } + if ( button == _powerUpButton ) + { + _basePower += 1.0f; + } + } + } + return base.MousePressed( evt, id ); + } + } +} Property changes on: Axiom.SharpGorilla/trunk/src/SharpGorilla.Samples/ThreeDSample.cs ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |