From: <bor...@us...> - 2011-02-16 16:14:19
|
Revision: 266 http://axiomcontrib.svn.sourceforge.net/axiomcontrib/?rev=266&view=rev Author: borrillis Date: 2011-02-16 16:14:10 +0000 (Wed, 16 Feb 2011) Log Message: ----------- Updated Stats Panels removed unused materials Updated Browser Binaries to latest svn Modified Paths: -------------- AxiomContrib.Samples/trunk/Reference Assemblies/Axiom.Framework.dll AxiomContrib.Samples/trunk/Reference Assemblies/Axiom.Framework.pdb AxiomContrib.Samples/trunk/Reference Assemblies/Axiom.RenderSystems.DirectX9.dll AxiomContrib.Samples/trunk/Reference Assemblies/Axiom.RenderSystems.DirectX9.pdb AxiomContrib.Samples/trunk/Reference Assemblies/Axiom.Samples.Common.dll AxiomContrib.Samples/trunk/Reference Assemblies/Axiom.Samples.Common.pdb AxiomContrib.Samples/trunk/Reference Assemblies/Axiom.dll AxiomContrib.Samples/trunk/Reference Assemblies/Axiom.pdb AxiomContrib.Samples/trunk/Source/Jitter/AxiomContrib.Samples.Jitter.2010.csproj AxiomContrib.Samples/trunk/Source/Jitter/AxiomContrib.Samples.Jitter.2010.csproj.user AxiomContrib.Samples/trunk/Source/Jitter/JitterSample.cs AxiomContrib.Samples/trunk/Source/Jitter/Primitives3D/GeometricPrimitive.cs AxiomContrib.Samples/trunk/Source/Jitter/Scenes/Scene.cs AxiomContrib.Samples/trunk/Source/Jitter/Scenes/Terrain.cs AxiomContrib.Samples/trunk/bin/media/AxiomContrib.Samples.Media.2010.csproj AxiomContrib.Samples/trunk/bin/media/archives/SdkTrays.zip AxiomContrib.Samples/trunk/bin/media/materials/scripts/JitterSample.material AxiomContrib.Samples/trunk/bin/win32/Axiom.Framework.dll AxiomContrib.Samples/trunk/bin/win32/Axiom.Framework.pdb AxiomContrib.Samples/trunk/bin/win32/Axiom.Platforms.Win32.dll AxiomContrib.Samples/trunk/bin/win32/Axiom.Platforms.Win32.pdb AxiomContrib.Samples/trunk/bin/win32/Axiom.Plugins.CgProgramManager.dll AxiomContrib.Samples/trunk/bin/win32/Axiom.Plugins.CgProgramManager.pdb AxiomContrib.Samples/trunk/bin/win32/Axiom.Plugins.FreeImageCodecs.dll AxiomContrib.Samples/trunk/bin/win32/Axiom.Plugins.FreeImageCodecs.pdb AxiomContrib.Samples/trunk/bin/win32/Axiom.Plugins.ParticleFX.dll AxiomContrib.Samples/trunk/bin/win32/Axiom.Plugins.ParticleFX.pdb AxiomContrib.Samples/trunk/bin/win32/Axiom.RenderSystems.DirectX9.dll AxiomContrib.Samples/trunk/bin/win32/Axiom.RenderSystems.DirectX9.pdb AxiomContrib.Samples/trunk/bin/win32/Axiom.Samples.Browser.exe.Config AxiomContrib.Samples/trunk/bin/win32/Axiom.Samples.Common.dll AxiomContrib.Samples/trunk/bin/win32/Axiom.Samples.Common.pdb AxiomContrib.Samples/trunk/bin/win32/Axiom.dll AxiomContrib.Samples/trunk/bin/win32/Axiom.pdb Added Paths: ----------- AxiomContrib.Samples/trunk/Source/Jitter/JitterSampleController.cs AxiomContrib.Samples/trunk/Source/OpenNI/ AxiomContrib.Samples/trunk/Source/OpenNI/Axiom.Samples.OpenNI.csproj AxiomContrib.Samples/trunk/Source/OpenNI/AxiomContrib.Samples.OpenNI.2010.csproj AxiomContrib.Samples/trunk/Source/OpenNI/OpenNISample.cs AxiomContrib.Samples/trunk/Source/OpenNI/Plugin.cs AxiomContrib.Samples/trunk/Source/OpenNI/Properties/ AxiomContrib.Samples/trunk/Source/OpenNI/Properties/AssemblyInfo.cs AxiomContrib.Samples/trunk/Source/OpenNI/SinbadCharacterController.cs AxiomContrib.Samples/trunk/Source/OpenNI/SkeletonPoseDetector.cs AxiomContrib.Samples/trunk/Source/OpenNI/bin/ AxiomContrib.Samples/trunk/Source/OpenNI/bin/Debug/ AxiomContrib.Samples/trunk/Source/OpenNI/bin/Release/ AxiomContrib.Samples/trunk/Source/OpenNI/obj/ AxiomContrib.Samples/trunk/Source/OpenNI/obj/x86/ AxiomContrib.Samples/trunk/Source/OpenNI/obj/x86/Debug/ AxiomContrib.Samples/trunk/Source/OpenNI/obj/x86/Debug/AxiomContrib.Samples.OpenNI.2010.csproj.FileListAbsolute.txt AxiomContrib.Samples/trunk/Source/OpenNI/obj/x86/Debug/AxiomContrib.Samples.OpenNISample.dll AxiomContrib.Samples/trunk/Source/OpenNI/obj/x86/Debug/AxiomContrib.Samples.OpenNISample.pdb AxiomContrib.Samples/trunk/Source/OpenNI/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache AxiomContrib.Samples/trunk/Source/OpenNI/obj/x86/Debug/TempPE/ Removed Paths: ------------- AxiomContrib.Samples/trunk/Source/Jitter/JitterStatsHandler.cs AxiomContrib.Samples/trunk/bin/media/materials/scripts/JitterSampleDisplay.overlay AxiomContrib.Samples/trunk/bin/media/materials/scripts/Rockwall.material AxiomContrib.Samples/trunk/bin/media/materials/textures/rockwall.tga Property Changed: ---------------- AxiomContrib.Samples/trunk/Source/ Modified: AxiomContrib.Samples/trunk/Reference Assemblies/Axiom.Framework.dll =================================================================== (Binary files differ) Modified: AxiomContrib.Samples/trunk/Reference Assemblies/Axiom.Framework.pdb =================================================================== (Binary files differ) Modified: AxiomContrib.Samples/trunk/Reference Assemblies/Axiom.RenderSystems.DirectX9.dll =================================================================== (Binary files differ) Modified: AxiomContrib.Samples/trunk/Reference Assemblies/Axiom.RenderSystems.DirectX9.pdb =================================================================== (Binary files differ) Modified: AxiomContrib.Samples/trunk/Reference Assemblies/Axiom.Samples.Common.dll =================================================================== (Binary files differ) Modified: AxiomContrib.Samples/trunk/Reference Assemblies/Axiom.Samples.Common.pdb =================================================================== (Binary files differ) Modified: AxiomContrib.Samples/trunk/Reference Assemblies/Axiom.dll =================================================================== (Binary files differ) Modified: AxiomContrib.Samples/trunk/Reference Assemblies/Axiom.pdb =================================================================== (Binary files differ) Property changes on: AxiomContrib.Samples/trunk/Source ___________________________________________________________________ Added: svn:ignore + *.suo Modified: AxiomContrib.Samples/trunk/Source/Jitter/AxiomContrib.Samples.Jitter.2010.csproj =================================================================== --- AxiomContrib.Samples/trunk/Source/Jitter/AxiomContrib.Samples.Jitter.2010.csproj 2011-02-16 10:24:37 UTC (rev 265) +++ AxiomContrib.Samples/trunk/Source/Jitter/AxiomContrib.Samples.Jitter.2010.csproj 2011-02-16 16:14:10 UTC (rev 266) @@ -69,7 +69,7 @@ <ItemGroup> <Compile Include="Conversion.cs" /> <Compile Include="DebugDrawer.cs" /> - <Compile Include="JitterStatsHandler.cs" /> + <Compile Include="JitterSampleController.cs" /> <Compile Include="JitterSample.cs" /> <Compile Include="PhysicsObjects\ConvexHullObject.cs" /> <Compile Include="PhysicsObjects\TerrainObject.cs" /> Modified: AxiomContrib.Samples/trunk/Source/Jitter/AxiomContrib.Samples.Jitter.2010.csproj.user =================================================================== --- AxiomContrib.Samples/trunk/Source/Jitter/AxiomContrib.Samples.Jitter.2010.csproj.user 2011-02-16 10:24:37 UTC (rev 265) +++ AxiomContrib.Samples/trunk/Source/Jitter/AxiomContrib.Samples.Jitter.2010.csproj.user 2011-02-16 16:14:10 UTC (rev 266) @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> - <StartProgram>..\bin\win32\Axiom.Samples.Browser.exe</StartProgram> - <StartWorkingDirectory>..\win32\</StartWorkingDirectory> + <StartProgram>C:\Projects\axiomcontrib\AxiomContrib.Samples\trunk\bin\win32\Axiom.Samples.Browser.exe</StartProgram> + <StartWorkingDirectory>C:\Projects\axiomcontrib\AxiomContrib.Samples\trunk\bin\win32</StartWorkingDirectory> <StartAction>Program</StartAction> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> Modified: AxiomContrib.Samples/trunk/Source/Jitter/JitterSample.cs =================================================================== --- AxiomContrib.Samples/trunk/Source/Jitter/JitterSample.cs 2011-02-16 10:24:37 UTC (rev 265) +++ AxiomContrib.Samples/trunk/Source/Jitter/JitterSample.cs 2011-02-16 16:14:10 UTC (rev 266) @@ -13,10 +13,10 @@ 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 @@ -50,58 +50,58 @@ namespace AxiomContrib.Samples.Jitter { - public enum BodyTag { DrawMe, DontDrawMe } + public enum BodyTag { DrawMe, DontDrawMe } - public class JitterSample : SdkSample - { - private GeometricPrimitive[] _primitives = new GeometricPrimitive[ (int)PrimitiveType.Count ]; + public class JitterSample : SdkSample + { + private GeometricPrimitive[] _primitives = new GeometricPrimitive[ (int)PrimitiveType.Count ]; - private int _currentScene = 0; - private bool _multithreadingEnabled = true; - private bool _leftMouseButtonDown = false; - private Vector2 _currentMousePos; + private int _currentScene = 0; + private bool _multithreadingEnabled = true; + private bool _leftMouseButtonDown = false; + private Vector2 _currentMousePos; - private Random random = new Random(); - private RigidBody lastBody = null; - private int _activeBodiesCount = 0; - private List<ConvexHullObject> _convexHulls = new List<ConvexHullObject>(); + private Random random = new Random(); + private RigidBody lastBody = null; + private int _activeBodiesCount = 0; + private List<ConvexHullObject> _convexHulls = new List<ConvexHullObject>(); - // Store information for drag and drop - private JVector hitPoint, hitNormal; - private WorldPointConstraint grabConstraint; - private RigidBody grabBody; - private float hitDistance = 0.0f; - //private int scrollWheel = 0; + // Store information for drag and drop + private JVector hitPoint, hitNormal; + private WorldPointConstraint grabConstraint; + private RigidBody grabBody; + private float hitDistance = 0.0f; + //private int scrollWheel = 0; - //public DebugDrawer DebugDrawer { get; private set; } - public World PhysicWorld { get; private set; } - public IList<Scene> PhysicScenes { get; private set; } - public JitterStatsHandler StatsHandler { get; private set; } + //public DebugDrawer DebugDrawer { get; private set; } + public World PhysicWorld { get; private set; } + public IList<Scene> PhysicScenes { get; private set; } + public JitterSampleController StatsHandler { get; private set; } - public JitterSample() - { - Metadata[ "Title" ] = "Jitter Sample"; - Metadata[ "Description" ] = "Demonstrates how to use Jitter Physics Engine with Axiom."; - Metadata[ "Thumbnail" ] = "thumb_Jitter.png"; - Metadata[ "Category" ] = "Physics"; - } + public JitterSample() + { + Metadata[ "Title" ] = "Jitter Sample"; + Metadata[ "Description" ] = "Demonstrates how to use Jitter Physics Engine with Axiom."; + Metadata[ "Thumbnail" ] = "thumb_Jitter.png"; + Metadata[ "Category" ] = "Physics"; + } - public override bool FrameRenderingQueued( FrameEventArgs evt ) - { - float step = evt.TimeSinceLastFrame; - if ( step > 1.0f / 100.0f ) - step = 1.0f / 100.0f; + public override bool FrameRenderingQueued( FrameEventArgs evt ) + { + float step = evt.TimeSinceLastFrame; + if ( step > 1.0f / 100.0f ) + step = 1.0f / 100.0f; - PhysicWorld.Step( step, _multithreadingEnabled ); - _activeBodiesCount = 0; + PhysicWorld.Step( step, _multithreadingEnabled ); + _activeBodiesCount = 0; - foreach ( RigidBody body in PhysicWorld.RigidBodies ) - { - if ( body.IsActive ) - _activeBodiesCount++; + foreach ( RigidBody body in PhysicWorld.RigidBodies ) + { + if ( body.IsActive ) + _activeBodiesCount++; - _addBodyToUpdateList( body ); - } + _addBodyToUpdateList( body ); + } foreach ( GeometricPrimitive prim in _primitives ) { @@ -118,386 +118,368 @@ if ( _currentScene > 0 && _currentScene < PhysicScenes.Count && null != PhysicScenes[ _currentScene ] ) PhysicScenes[ _currentScene ].PhysicUpdate(); - #region drag and drop physical objects with the mouse - if ( _leftMouseButtonDown ) - { - if ( grabBody != null ) - { - Vector3 ray = _rayTo( _currentMousePos.x, _currentMousePos.y ); - ray.Normalize(); - grabConstraint.Anchor = Conversion.ToJitterVector( Camera.Position + ray * hitDistance ); - } - } - else - { - grabBody = null; + #region drag and drop physical objects with the mouse + if ( _leftMouseButtonDown ) + { + if ( grabBody != null ) + { + Vector3 ray = _rayTo( _currentMousePos.x, _currentMousePos.y ); + ray.Normalize(); + grabConstraint.Anchor = Conversion.ToJitterVector( Camera.Position + ray * hitDistance ); + } + } + else + { + grabBody = null; - if ( grabConstraint != null ) - PhysicWorld.RemoveConstraint( grabConstraint ); - } - #endregion + if ( grabConstraint != null ) + PhysicWorld.RemoveConstraint( grabConstraint ); + } + #endregion - // Draw the debug data provided by Jitter - //DrawIslands(); - //DrawJitterDebugInfo(); + // Draw the debug data provided by Jitter + //DrawIslands(); + //DrawJitterDebugInfo(); - //Update Stats - if ( StatsHandler.AreStatsVisible ) - { - int contactCount = 0; - int entries = (int)World.DebugType.num; - double total = 0; + //Update Stats + if ( StatsHandler.AreStatsVisible ) + { + int contactCount = 0; + int entries = (int)World.DebugType.num; + double total = 0; - for ( int i = 0; i < entries; i++ ) - { - World.DebugType type = (World.DebugType)i; - StatsHandler.SetValue( type.ToString(), PhysicWorld.DebugTimes[ i ] ); - total += PhysicWorld.DebugTimes[ i ]; - } + for ( int i = 0; i < entries; i++ ) + { + World.DebugType type = (World.DebugType)i; + StatsHandler.SetValue( type.ToString(), PhysicWorld.DebugTimes[ i ] ); + total += PhysicWorld.DebugTimes[ i ]; + } - foreach ( Arbiter ar in PhysicWorld.ArbiterMap.Values ) - contactCount += ar.ContactList.Count; + foreach ( Arbiter ar in PhysicWorld.ArbiterMap.Values ) + contactCount += ar.ContactList.Count; - StatsHandler.SetValue( "ArbiterCount", PhysicWorld.ArbiterMap.Values.Count ); - StatsHandler.SetValue( "ContactCount", contactCount ); - StatsHandler.SetValue( "IslandCount", PhysicWorld.Islands.Count ); - StatsHandler.SetValue( "BodyCount", string.Format( "{0} ( {1} )", PhysicWorld.RigidBodies.Count, _activeBodiesCount ) ); - StatsHandler.SetValue( "MultiThreaded", _multithreadingEnabled ); - StatsHandler.SetValue( "Gen", string.Format( "gen0: {0} gen1: {1} gen2: {2}", GC.CollectionCount( 0 ), GC.CollectionCount( 1 ), GC.CollectionCount( 2 ) ) ); + StatsHandler.SetValue( "ArbiterCount", PhysicWorld.ArbiterMap.Values.Count ); + StatsHandler.SetValue( "ContactCount", contactCount ); + StatsHandler.SetValue( "IslandCount", PhysicWorld.Islands.Count ); + StatsHandler.SetValue( "BodyCount", string.Format( "{0} ( {1} )", PhysicWorld.RigidBodies.Count, _activeBodiesCount ) ); + StatsHandler.SetValue( "MultiThreaded", _multithreadingEnabled ); + StatsHandler.SetValue( "Gen", string.Format( "gen0: {0} gen1: {1} gen2: {2}", GC.CollectionCount( 0 ), GC.CollectionCount( 1 ), GC.CollectionCount( 2 ) ) ); - StatsHandler.SetValue( "TotalPhysicsTime", total ); - StatsHandler.SetValue( "PhysicsFramerate", ( 1000.0d / total ).ToString( "0" ) + " fps" ); + StatsHandler.SetValue( "TotalPhysicsTime", total ); + StatsHandler.SetValue( "PhysicsFramerate", ( 1000.0d / total ).ToString( "0" ) + " fps" ); - StatsHandler.Update(); - } + StatsHandler.Update(); + } - return base.FrameRenderingQueued( evt ); // don't forget the parent class updates! - } + return base.FrameRenderingQueued( evt ); // don't forget the parent class updates! + } - private Vector3 _rayTo( float x, float y ) - { - Ray mouseRay = Camera.GetCameraToViewportRay( x, y ); - return mouseRay.Direction; - } + private Vector3 _rayTo( float x, float y ) + { + Ray mouseRay = Camera.GetCameraToViewportRay( x, y ); + return mouseRay.Direction; + } - private bool _raycastCallback( RigidBody body, JVector normal, float fraction ) - { - return !body.IsStatic; - } + private bool _raycastCallback( RigidBody body, JVector normal, float fraction ) + { + return !body.IsStatic; + } - public override bool MouseMoved( SharpInputSystem.MouseEventArgs evt ) - { - float x = evt.State.X.Absolute / (float)Camera.Viewport.ActualWidth; - float y = evt.State.Y.Absolute / (float)Camera.Viewport.ActualHeight; - _currentMousePos = new Vector2( x, y ); + public override bool MouseMoved( SharpInputSystem.MouseEventArgs evt ) + { + float x = evt.State.X.Absolute / (float)Camera.Viewport.ActualWidth; + float y = evt.State.Y.Absolute / (float)Camera.Viewport.ActualHeight; + _currentMousePos = new Vector2( x, y ); - return base.MouseMoved( evt ); - } + return base.MouseMoved( evt ); + } - public override bool MousePressed( SharpInputSystem.MouseEventArgs evt, SharpInputSystem.MouseButtonID id ) - { - if ( id == SharpInputSystem.MouseButtonID.Left ) - { - _leftMouseButtonDown = true; + public override bool MousePressed( SharpInputSystem.MouseEventArgs evt, SharpInputSystem.MouseButtonID id ) + { + if ( id == SharpInputSystem.MouseButtonID.Left ) + { + _leftMouseButtonDown = true; - JVector ray = Conversion.ToJitterVector( _rayTo( _currentMousePos.x, _currentMousePos.y ) ); - JVector camp = Conversion.ToJitterVector( Camera.Position ); + JVector ray = Conversion.ToJitterVector( _rayTo( _currentMousePos.x, _currentMousePos.y ) ); + JVector camp = Conversion.ToJitterVector( Camera.Position ); - ray = JVector.Normalize( ray ) * 100; + ray = JVector.Normalize( ray ) * 100; - float fraction; - bool result = PhysicWorld.CollisionSystem.Raycast( camp, ray, _raycastCallback, out grabBody, out hitNormal, out fraction ); + float fraction; + bool result = PhysicWorld.CollisionSystem.Raycast( camp, ray, _raycastCallback, out grabBody, out hitNormal, out fraction ); - if ( result ) - { - hitPoint = camp + fraction * ray; + if ( result ) + { + hitPoint = camp + fraction * ray; - if ( grabConstraint != null ) - PhysicWorld.RemoveConstraint( grabConstraint ); + if ( grabConstraint != null ) + PhysicWorld.RemoveConstraint( grabConstraint ); - JVector lanchor = hitPoint - grabBody.Position; - lanchor = JVector.Transform( lanchor, JMatrix.Transpose( grabBody.Orientation ) ); + JVector lanchor = hitPoint - grabBody.Position; + lanchor = JVector.Transform( lanchor, JMatrix.Transpose( grabBody.Orientation ) ); - grabConstraint = new WorldPointConstraint( grabBody, lanchor ); + grabConstraint = new WorldPointConstraint( grabBody, lanchor ); - PhysicWorld.AddConstraint( grabConstraint ); - hitDistance = ( Conversion.ToVector3( hitPoint ) - Camera.Position ).Length; - //scrollWheel = evt.State. mouseState.ScrollWheelValue; - grabConstraint.Anchor = hitPoint; - } - } + PhysicWorld.AddConstraint( grabConstraint ); + hitDistance = ( Conversion.ToVector3( hitPoint ) - Camera.Position ).Length; + //scrollWheel = evt.State. mouseState.ScrollWheelValue; + grabConstraint.Anchor = hitPoint; + } + } - if ( id == SharpInputSystem.MouseButtonID.Right ) - { - this.DragLook = false; - } + if ( id == SharpInputSystem.MouseButtonID.Right ) + { + this.DragLook = false; + } - return base.MousePressed( evt, id ); ; - } + return base.MousePressed( evt, id ); ; + } - public override bool MouseReleased( SharpInputSystem.MouseEventArgs evt, SharpInputSystem.MouseButtonID id ) - { - if ( id == SharpInputSystem.MouseButtonID.Left ) - { - _leftMouseButtonDown = false; - } + public override bool MouseReleased( SharpInputSystem.MouseEventArgs evt, SharpInputSystem.MouseButtonID id ) + { + if ( id == SharpInputSystem.MouseButtonID.Left ) + { + _leftMouseButtonDown = false; + } - if ( id == SharpInputSystem.MouseButtonID.Right ) - { - this.CameraManager.manualStop(); - this.DragLook = true; - } + if ( id == SharpInputSystem.MouseButtonID.Right ) + { + this.CameraManager.manualStop(); + this.DragLook = true; + } - return base.MouseReleased( evt, id ); - } + return base.MouseReleased( evt, id ); + } - public override bool KeyPressed( SharpInputSystem.KeyEventArgs evt ) - { - bool baseRetValue = base.KeyPressed( evt ); + public override bool KeyPressed( SharpInputSystem.KeyEventArgs evt ) + { + bool baseRetValue = base.KeyPressed( evt ); - // change threading mode - if ( evt.Key == SharpInputSystem.KeyCode.Key_M ) - _multithreadingEnabled = !_multithreadingEnabled; + // change threading mode + if ( evt.Key == SharpInputSystem.KeyCode.Key_M ) + _multithreadingEnabled = !_multithreadingEnabled; - // create random primitives - if ( evt.Key == SharpInputSystem.KeyCode.Key_SPACE ) - { - _spawnRandomPrimitive( Conversion.ToJitterVector( Camera.Position ), - Conversion.ToJitterVector( Camera.Direction * 40.0f ) ); - } + // create random primitives + if ( evt.Key == SharpInputSystem.KeyCode.Key_SPACE ) + { + _spawnRandomPrimitive( Conversion.ToJitterVector( Camera.Position ), + Conversion.ToJitterVector( Camera.Direction * 40.0f ) ); + } - // Show/Hide physics stats - if ( evt.Key == SharpInputSystem.KeyCode.Key_F12 ) - { - StatsHandler.AreStatsVisible = !StatsHandler.AreStatsVisible; - } + // Show/Hide physics stats + if ( evt.Key == SharpInputSystem.KeyCode.Key_F12 ) + { + StatsHandler.AreStatsVisible = !StatsHandler.AreStatsVisible; + } - return baseRetValue; - } + return baseRetValue; + } - private void _sceneSelector_SelectedIndexChanged( object sender, EventArgs e ) - { - SelectMenu menu = sender as SelectMenu; + public void ChangeCurrentScene( int newSceneIndex, bool skipDestroy ) + { + if ( !skipDestroy ) + { + PhysicScenes[ _currentScene ].Destroy(); + this.SceneManager.ClearScene(); + this.SceneManager.DestroyAllMovableObjectsByType( "ManualObject" ); + } - if ( menu == null ) - return; + _initPrimitives(); + _convexHulls.Clear(); - _changeCurrentScene( menu.SelectionIndex, false ); - } + _currentScene = newSceneIndex; + PhysicScenes[ _currentScene ].Build(); + StatsHandler.SetValue( "CurrentScene", this.PhysicScenes[ _currentScene ].GetType().Name ); - private void _changeCurrentScene( int newSceneIndex, bool skipDestroy ) - { - if ( !skipDestroy ) - { - PhysicScenes[ _currentScene ].Destroy(); - this.SceneManager.ClearScene(); - this.SceneManager.DestroyAllMovableObjectsByType( "ManualObject" ); - } + // add a skybox (disabled for now due to an issue when switching from scenes) + //SceneManager.SetSkyBox( true, "Examples/StormySkyBox", 5000 ); - _initPrimitives(); - _convexHulls.Clear(); + // setup some basic lighting for our scene + SceneManager.AmbientLight = new ColorEx( 0.5f, 0.5f, 0.5f ); + SceneManager.CreateLight( "Light1" ).Position = new Vector3( 20, 80, 50 ); - _currentScene = newSceneIndex; - PhysicScenes[ _currentScene ].Build(); - StatsHandler.SetValue( "CurrentScene", this.PhysicScenes[ _currentScene ].GetType().Name ); + // set initial camera position and style + this.DragLook = true; + CameraManager.TopSpeed = 10; + Camera.Position = new Vector3( 15, 15, 30 ); + } - // add a skybox (disabled for now due to an issue when switching from scenes) - //SceneManager.SetSkyBox( true, "Examples/StormySkyBox", 5000 ); + private void _addBodyToUpdateList( RigidBody rb ) + { + if ( rb.Tag is BodyTag && ( (BodyTag)rb.Tag ) == BodyTag.DontDrawMe ) + return; - // setup some basic lighting for our scene - SceneManager.AmbientLight = new ColorEx( 0.5f, 0.5f, 0.5f ); - SceneManager.CreateLight( "Light1" ).Position = new Vector3( 20, 80, 50 ); + bool isCompoundShape = ( rb.Shape is CompoundShape ); - // set initial camera position and style - this.DragLook = true; - CameraManager.TopSpeed = 10; - Camera.Position = new Vector3( 15, 15, 30 ); - } + if ( !isCompoundShape ) + { + _addShapeToUpdateList( rb.Shape, rb.Orientation, rb.Position ); + } + else + { + CompoundShape cShape = rb.Shape as CompoundShape; + JMatrix orientation = rb.Orientation; + JVector position = rb.Position; - private void _addBodyToUpdateList( RigidBody rb ) - { - if ( rb.Tag is BodyTag && ( (BodyTag)rb.Tag ) == BodyTag.DontDrawMe ) - return; + foreach ( var ts in cShape.Shapes ) + { + JVector pos = ts.Position; + JMatrix ori = ts.Orientation; - bool isCompoundShape = ( rb.Shape is CompoundShape ); + JVector.Transform( ref pos, ref orientation, out pos ); + JVector.Add( ref pos, ref position, out pos ); - if ( !isCompoundShape ) - { - _addShapeToUpdateList( rb.Shape, rb.Orientation, rb.Position ); - } - else - { - CompoundShape cShape = rb.Shape as CompoundShape; - JMatrix orientation = rb.Orientation; - JVector position = rb.Position; + JMatrix.Multiply( ref ori, ref orientation, out ori ); - foreach ( var ts in cShape.Shapes ) - { - JVector pos = ts.Position; - JMatrix ori = ts.Orientation; + _addShapeToUpdateList( ts.Shape, ori, pos ); + } + } + } - JVector.Transform( ref pos, ref orientation, out pos ); - JVector.Add( ref pos, ref position, out pos ); + private void _addShapeToUpdateList( Shape shape, JMatrix ori, JVector pos ) + { + GeometricPrimitive primitive = null; + Vector3 scale = Vector3.UnitScale; - JMatrix.Multiply( ref ori, ref orientation, out ori ); + if ( shape is BoxShape ) + { + primitive = _primitives[ (int)PrimitiveType.Box ]; + scale = Conversion.ToVector3( ( shape as BoxShape ).Size ); + } + else if ( shape is SphereShape ) + { + primitive = _primitives[ (int)PrimitiveType.Sphere ]; + scale = new Vector3( ( shape as SphereShape ).Radius ); + } + else if ( shape is CylinderShape ) + { + primitive = _primitives[ (int)PrimitiveType.Cylinder ]; + CylinderShape cs = shape as CylinderShape; + scale = new Vector3( cs.Radius, cs.Height, cs.Radius ); + } + else if ( shape is CapsuleShape ) + { + primitive = _primitives[ (int)PrimitiveType.Capsule ]; + CapsuleShape cs = shape as CapsuleShape; + scale = new Vector3( cs.Radius * 2, cs.Length, cs.Radius * 2 ); - _addShapeToUpdateList( ts.Shape, ori, pos ); - } - } - } + } + else if ( shape is ConeShape ) + { + primitive = _primitives[ (int)PrimitiveType.Cone ]; + ConeShape cs = shape as ConeShape; + scale = new Vector3( cs.Radius, cs.Height, cs.Radius ); + } - private void _addShapeToUpdateList( Shape shape, JMatrix ori, JVector pos ) - { - GeometricPrimitive primitive = null; - Vector3 scale = Vector3.UnitScale; + primitive.PhysicUpdate( Conversion.ToVector3( pos ), Conversion.ToQuat( ori ), scale ); + } - if ( shape is BoxShape ) - { - primitive = _primitives[ (int)PrimitiveType.Box ]; - scale = Conversion.ToVector3( ( shape as BoxShape ).Size ); - } - else if ( shape is SphereShape ) - { - primitive = _primitives[ (int)PrimitiveType.Sphere ]; - scale = new Vector3( ( shape as SphereShape ).Radius ); - } - else if ( shape is CylinderShape ) - { - primitive = _primitives[ (int)PrimitiveType.Cylinder ]; - CylinderShape cs = shape as CylinderShape; - scale = new Vector3( cs.Radius, cs.Height, cs.Radius ); - } - else if ( shape is CapsuleShape ) - { - primitive = _primitives[ (int)PrimitiveType.Capsule ]; - CapsuleShape cs = shape as CapsuleShape; - scale = new Vector3( cs.Radius * 2, cs.Length, cs.Radius * 2 ); + private void _spawnRandomPrimitive( JVector position, JVector velocity ) + { + RigidBody body = null; + int rndn = random.Next( 7 ); - } - else if ( shape is ConeShape ) - { - primitive = _primitives[ (int)PrimitiveType.Cone ]; - ConeShape cs = shape as ConeShape; - scale = new Vector3( cs.Radius, cs.Height, cs.Radius ); - } + // less of the more advanced objects + if ( rndn == 5 || rndn == 6 || rndn == 7 ) + rndn = random.Next( 7 ); - primitive.PhysicUpdate( Conversion.ToVector3( pos ), Conversion.ToQuat( ori ), scale ); - } + switch ( rndn ) + { + case 0: + body = new RigidBody( new ConeShape( (float)random.Next( 5, 50 ) / 20.0f, (float)random.Next( 10, 20 ) / 20.0f ) ); + break; - private void _spawnRandomPrimitive( JVector position, JVector velocity ) - { - RigidBody body = null; - int rndn = random.Next( 7 ); + case 1: + body = new RigidBody( new BoxShape( (float)random.Next( 10, 30 ) / 20.0f, (float)random.Next( 10, 30 ) / 20.0f, (float)random.Next( 10, 30 ) / 20.0f ) ); + break; - // less of the more advanced objects - if ( rndn == 5 || rndn == 6 || rndn == 7 ) - rndn = random.Next( 7 ); + case 2: + body = new RigidBody( new SphereShape( (float)random.Next( 30, 100 ) / 100.0f ) ); + break; - switch ( rndn ) - { - case 0: - body = new RigidBody( new ConeShape( (float)random.Next( 5, 50 ) / 20.0f, (float)random.Next( 10, 20 ) / 20.0f ) ); - break; + case 3: + body = new RigidBody( new CylinderShape( 1.0f, 0.5f ) ); + break; - case 1: - body = new RigidBody( new BoxShape( (float)random.Next( 10, 30 ) / 20.0f, (float)random.Next( 10, 30 ) / 20.0f, (float)random.Next( 10, 30 ) / 20.0f ) ); - break; + case 4: + body = new RigidBody( new CapsuleShape( 1.0f, 0.5f ) ); + break; - case 2: - body = new RigidBody( new SphereShape( (float)random.Next( 30, 100 ) / 100.0f ) ); - break; + case 5: + Shape b1 = new BoxShape( new JVector( 3, 1, 1 ) ); + Shape b2 = new BoxShape( new JVector( 1, 1, 3 ) ); + Shape b3 = new CylinderShape( 3.0f, 0.5f ); - case 3: - body = new RigidBody( new CylinderShape( 1.0f, 0.5f ) ); - break; + CompoundShape.TransformedShape t1 = new CompoundShape.TransformedShape( b1, JMatrix.Identity, JVector.Zero ); + CompoundShape.TransformedShape t2 = new CompoundShape.TransformedShape( b2, JMatrix.Identity, JVector.Zero ); + CompoundShape.TransformedShape t3 = new CompoundShape.TransformedShape( b3, JMatrix.Identity, new JVector( 0, 0, 0 ) ); - case 4: - body = new RigidBody( new CapsuleShape( 1.0f, 0.5f ) ); - break; + CompoundShape ms = new CompoundShape( new CompoundShape.TransformedShape[ 3 ] { t1, t2, t3 } ); - case 5: - Shape b1 = new BoxShape( new JVector( 3, 1, 1 ) ); - Shape b2 = new BoxShape( new JVector( 1, 1, 3 ) ); - Shape b3 = new CylinderShape( 3.0f, 0.5f ); + body = new RigidBody( ms ); + break; - CompoundShape.TransformedShape t1 = new CompoundShape.TransformedShape( b1, JMatrix.Identity, JVector.Zero ); - CompoundShape.TransformedShape t2 = new CompoundShape.TransformedShape( b2, JMatrix.Identity, JVector.Zero ); - CompoundShape.TransformedShape t3 = new CompoundShape.TransformedShape( b3, JMatrix.Identity, new JVector( 0, 0, 0 ) ); + case 6: + ConvexHullObject obj2 = new ConvexHullObject( this ); + body = obj2.body; + body.Restitution = 0.2f; + body.StaticFriction = 0.8f; + _convexHulls.Add( obj2 ); + break; + } - CompoundShape ms = new CompoundShape( new CompoundShape.TransformedShape[ 3 ] { t1, t2, t3 } ); + PhysicWorld.AddBody( body ); - body = new RigidBody( ms ); - break; + body.Position = position; + body.LinearVelocity = velocity; - case 6: - ConvexHullObject obj2 = new ConvexHullObject( this ); - body = obj2.body; - body.Restitution = 0.2f; - body.StaticFriction = 0.8f; - _convexHulls.Add( obj2 ); - break; - } + lastBody = body; + } - PhysicWorld.AddBody( body ); + private void _initPrimitives() + { + for ( int i = 0; i < (int)PrimitiveType.Count; ++i ) + { + if ( _primitives[ i ] == null ) + continue; - body.Position = position; - body.LinearVelocity = velocity; + if ( !_primitives[ i ].IsDisposed ) + _primitives[ i ].Dispose(); - lastBody = body; - } + _primitives[ i ] = null; + } - private void _initPrimitives() - { - for ( int i = 0; i < (int)PrimitiveType.Count; ++i ) - { - if ( _primitives[ i ] == null ) - continue; + _primitives[ (int)PrimitiveType.Box ] = new BoxPrimitive( this ); + _primitives[ (int)PrimitiveType.Capsule ] = new CapsulePrimitive( this ); + _primitives[ (int)PrimitiveType.Cone ] = new ConePrimitive( this ); + _primitives[ (int)PrimitiveType.Cylinder ] = new CylinderPrimitive( this ); + _primitives[ (int)PrimitiveType.Sphere ] = new SpherePrimitive( this ); + } - if ( !_primitives[ i ].IsDisposed ) - _primitives[ i ].Dispose(); + protected override void SetupContent() + { + //Setting Up Physics System + CollisionSystem collision = new CollisionSystemSAP(); + PhysicWorld = new World( collision ); + PhysicWorld.AllowDeactivation = true; - _primitives[ i ] = null; - } + //DebugDrawer = new DebugDrawer(); - _primitives[ (int)PrimitiveType.Box ] = new BoxPrimitive( this ); - _primitives[ (int)PrimitiveType.Capsule ] = new CapsulePrimitive( this ); - _primitives[ (int)PrimitiveType.Cone ] = new ConePrimitive( this ); - _primitives[ (int)PrimitiveType.Cylinder ] = new CylinderPrimitive( this ); - _primitives[ (int)PrimitiveType.Sphere ] = new SpherePrimitive( this ); - } - protected override void SetupContent() - { - //Setting Up Physics System - CollisionSystem collision = new CollisionSystemSAP(); - PhysicWorld = new World( collision ); - PhysicWorld.AllowDeactivation = true; + //Get available scenes and add them into the scene selector + PhysicScenes = new List<Scene>(); + foreach ( Type type in Assembly.GetExecutingAssembly().GetTypes() ) + { + if ( type.Namespace == "AxiomContrib.Samples.Jitter.Scenes" && !type.IsAbstract ) + { + Scene scene = (Scene)Activator.CreateInstance( type, this ); + this.PhysicScenes.Add( scene ); + } + } - //DebugDrawer = new DebugDrawer(); + StatsHandler = new JitterSampleController( this, TrayManager ); + StatsHandler.Initialize(); - StatsHandler = new JitterStatsHandler( this, true ); - StatsHandler.Initialize(); - - //Get available scenes and add them into the scene selector - SelectMenu sceneSelector = TrayManager.CreateLongSelectMenu( TrayLocation.Bottom, "SceneSelector", "Select Scene", 250, 140, 15 ); - PhysicScenes = new List<Scene>(); - - foreach ( Type type in Assembly.GetExecutingAssembly().GetTypes() ) - { - if ( type.Namespace == "AxiomContrib.Samples.Jitter.Scenes" && !type.IsAbstract ) - { - Scene scene = (Scene)Activator.CreateInstance( type, this ); - this.PhysicScenes.Add( scene ); - sceneSelector.AddItem( scene.GetType().Name ); - } - } - - if ( PhysicScenes.Count > 0 ) - { - sceneSelector.SelectItem( 0 ); - sceneSelector.SelectedIndexChanged += _sceneSelector_SelectedIndexChanged; - _changeCurrentScene( 0, true ); - } - } - } + } + } } Copied: AxiomContrib.Samples/trunk/Source/Jitter/JitterSampleController.cs (from rev 255, AxiomContrib.Samples/trunk/Source/Jitter/JitterStatsHandler.cs) =================================================================== --- AxiomContrib.Samples/trunk/Source/Jitter/JitterSampleController.cs (rev 0) +++ AxiomContrib.Samples/trunk/Source/Jitter/JitterSampleController.cs 2011-02-16 16:14:10 UTC (rev 266) @@ -0,0 +1,164 @@ +#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.Collections.Generic; +using Axiom.Collections; +using Axiom.Overlays; +using Axiom.Overlays.Elements; +using Axiom.Samples; +using AxiomContrib.Samples.Jitter.Scenes; +using System; + +#endregion + +namespace AxiomContrib.Samples.Jitter +{ + public class JitterSampleController + { + private JitterSample _sample; + private ParamsPanel _statsPanel; + private SortedList<string, string> _stats; + private Queue<string> _updatedStats = new Queue<string>(); + + private SdkTrayManager TrayManager; + + public bool AreStatsVisible + { + get; + set; + } + + public JitterSampleController( JitterSample sample , SdkTrayManager trayManager ) + { + _sample = sample; + AreStatsVisible = true; + TrayManager = trayManager; + } + + public void Initialize() + { + DecorWidget logo = TrayManager.CreateLogoWidget( TrayLocation.TopLeft, "Jitter/Logo", "Panel", "JitterSample/JitterLogo" ); + SelectMenu sceneSelector = TrayManager.CreateLongSelectMenu( TrayLocation.TopLeft, "SceneSelector", "Scene:", 250, 140, 15 ); + + foreach ( Scene scene in _sample.PhysicScenes ) + { + sceneSelector.AddItem( scene.GetType().Name ); + } + + _stats = new SortedList<string, string>() { + {"ArbiterCount" , string.Empty}, + {"ContactCount" , string.Empty}, + {"IslandCount" , string.Empty}, + {"BodyCount" , string.Empty}, + {"MultiThreaded" , string.Empty}, + {"Gen" , string.Empty}, + {"CollisionDetect" , string.Empty}, + {"BuildIslands" , string.Empty}, + {"HandleArbiter" , string.Empty}, + {"UpdateContacts" , string.Empty}, + {"PreStep" , string.Empty}, + {"DeactivateBodies" , string.Empty}, + {"IntegrateForces" , string.Empty}, + {"Integrate" , string.Empty}, + {"PostStep" , string.Empty}, + {"TotalPhysicsTime" , string.Empty}, + {"PhysicsFramerate" , string.Empty} + }; + _statsPanel = TrayManager.CreateParamsPanel( TrayLocation.TopLeft, "Jitter/StatsPanel", 250, _stats.Keys ); + + // Enqueue all of available stats to force the first time update + foreach ( string key in _stats.Keys ) + { + _updatedStats.Enqueue( key ); + } + + sceneSelector.SelectedIndexChanged += sceneSelector_SelectedIndexChanged; + + if ( _sample.PhysicScenes.Count > 0 ) + { + sceneSelector.SelectItem( 0 ); + } + + } + + public void SetValue( string key, int value ) + { + SetValue( key, value.ToString() ); + } + + public void SetValue( string key, float value ) + { + SetValue( key, value.ToString( "F2" ) ); + } + + public void SetValue( string key, double value ) + { + SetValue( key, value.ToString( "0.00" ) ); + } + + public void SetValue( string key, bool value ) + { + SetValue( key, value ? "true" : "false" ); + } + + public void SetValue( string key, string value ) + { + if ( !_stats.ContainsKey( key ) || !AreStatsVisible ) + return; + + _stats[ key ] = value; + + if ( !_updatedStats.Contains( key ) ) + _updatedStats.Enqueue( key ); + } + + public void Update() + { + if ( _updatedStats.Count == 0 || !AreStatsVisible ) + return; + + _statsPanel.ParamValues = _stats.Values; + } + + private void sceneSelector_SelectedIndexChanged( object sender, EventArgs e ) + { + SelectMenu menu = sender as SelectMenu; + + if ( menu == null ) + return; + + _sample.ChangeCurrentScene( menu.SelectionIndex, false ); + } + + + } +} Deleted: AxiomContrib.Samples/trunk/Source/Jitter/JitterStatsHandler.cs =================================================================== --- AxiomContrib.Samples/trunk/Source/Jitter/JitterStatsHandler.cs 2011-02-16 10:24:37 UTC (rev 265) +++ AxiomContrib.Samples/trunk/Source/Jitter/JitterStatsHandler.cs 2011-02-16 16:14:10 UTC (rev 266) @@ -1,164 +0,0 @@ -#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.Collections.Generic; -using Axiom.Collections; -using Axiom.Overlays; -using Axiom.Overlays.Elements; - -#endregion - -namespace AxiomContrib.Samples.Jitter -{ - public class JitterStatsHandler - { - private JitterSample _sample; - private BorderPanel _statsPanel; - private NameValuePairList _stats; - private Queue<string> _updatedStats; - private bool _areStatsVisible; - - public bool AreStatsVisible - { - get - { - return _areStatsVisible; - } - - set - { - _areStatsVisible = value; - _statsPanel.IsVisible = value; - } - } - - public JitterStatsHandler( JitterSample sample , bool areStatsVisible ) - { - _sample = sample; - _stats = new NameValuePairList(); - _updatedStats = new Queue<string>(); - _areStatsVisible = areStatsVisible; - } - - public void Initialize() - { - _stats.Add( "CurrentScene", string.Empty ); - _stats.Add( "ArbiterCount", string.Empty ); - _stats.Add( "ContactCount", string.Empty ); - _stats.Add( "IslandCount", string.Empty ); - _stats.Add( "BodyCount", string.Empty ); - _stats.Add( "MultiThreaded", string.Empty ); - _stats.Add( "Gen", string.Empty ); - _stats.Add( "CollisionDetect", string.Empty ); - _stats.Add( "BuildIslands", string.Empty ); - _stats.Add( "HandleArbiter", string.Empty ); - _stats.Add( "UpdateContacts", string.Empty ); - _stats.Add( "PreStep", string.Empty ); - _stats.Add( "DeactivateBodies", string.Empty ); - _stats.Add( "IntegrateForces", string.Empty ); - _stats.Add( "Integrate", string.Empty ); - _stats.Add( "PostStep", string.Empty ); - _stats.Add( "TotalPhysicsTime", string.Empty ); - _stats.Add( "PhysicsFramerate", string.Empty ); - - // Enqueue all of available stats to force the first time update - foreach ( string key in _stats.Keys ) - _updatedStats.Enqueue( key ); - - Overlay ov = OverlayManager.Instance.GetByName( "JitterSample/StatesOverlay" ); - if ( ov == null ) - { - ov = OverlayManager.Instance.Create( "JitterSample/StatesOverlay" ); - - _statsPanel = (BorderPanel)OverlayManager.Instance.Elements.CreateElementFromTemplate( "JitterSample/StatPanel", "BorderPanel", "StatPanel" ); - ov.AddElement( _statsPanel ); - - Panel logo = (Panel)OverlayManager.Instance.Elements.CreateElementFromTemplate( "JitterSample/JitterLogo", "Panel", "Logo" ); - ov.AddElement( logo ); - } - else - _statsPanel = (BorderPanel)OverlayManager.Instance.Elements.GetElement( "StatPanel" ); - - ov.ZOrder = 10; - ov.IsVisible = true; - - _statsPanel.IsVisible = _areStatsVisible; - } - - public void SetValue( string key, int value ) - { - SetValue( key, value.ToString() ); - } - - public void SetValue( string key, float value ) - { - SetValue( key, value.ToString( "F2" ) ); - } - - public void SetValue( string key, double value ) - { - SetValue( key, value.ToString( "0.00" ) ); - } - - public void SetValue( string key, bool value ) - { - SetValue( key, value ? "true" : "false" ); - } - - public void SetValue( string key, string value ) - { - if ( !_stats.ContainsKey( key ) || !_areStatsVisible ) - return; - - _stats[ key ] = value; - - if ( !_updatedStats.Contains( key ) ) - _updatedStats.Enqueue( key ); - } - - public void Update() - { - if ( _updatedStats.Count == 0 || !_areStatsVisible ) - return; - - TextArea currentTextarea = null; - string currentKey = null; - - while ( _updatedStats.Count != 0 ) - { - currentKey = _updatedStats.Dequeue(); - currentTextarea = (TextArea)_statsPanel.GetChild( "StatPanel/" + currentKey ); - currentTextarea.Text = string.Format( "{0}: {1}", currentKey, _stats[ currentKey ] ); - } - } - } -} Modified: AxiomContrib.Samples/trunk/Source/Jitter/Primitives3D/GeometricPrimitive.cs =================================================================== --- AxiomContrib.Samples/trunk/Source/Jitter/Primitives3D/GeometricPrimitive.cs 2011-02-16 10:24:37 UTC (rev 265) +++ AxiomContrib.Samples/trunk/Source/Jitter/Primitives3D/GeometricPrimitive.cs 2011-02-16 16:14:10 UTC (rev 266) @@ -13,10 +13,10 @@ 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 @@ -40,151 +40,151 @@ namespace AxiomContrib.Samples.Jitter.Primitives3D { - public enum PrimitiveType : int - { - Box = 0, - Sphere = 1, - Cylinder = 2, - Cone = 3, - Capsule = 4, - Count = 5 - } + public enum PrimitiveType : int + { + Box = 0, + Sphere = 1, + Cylinder = 2, + Cone = 3, + Capsule = 4, + Count = 5 + } - /// <summary> - /// Base class for simple geometric primitive models. This provides a vertex - /// buffer, an index buffer, plus methods for drawing the model. Classes for - /// specific types of primitive (CubePrimitive, SpherePrimitive, etc.) are - /// derived from this common base, and use the AddVertex and AddIndex methods - /// to specify their geometry. - /// </summary> - public abstract class GeometricPrimitive : IDisposable - { - #region Fields + /// <summary> + /// Base class for simple geometric primitive models. This provides a vertex + /// buffer, an index buffer, plus methods for drawing the model. Classes for + /// specific types of primitive (CubePrimitive, SpherePrimitive, etc.) are + /// derived from this common base, and use the AddVertex and AddIndex methods + /// to specify their geometry. + /// </summary> + public abstract class GeometricPrimitive : IDisposable + { + #region Fields - private List<SceneNode> _nodes = new List<SceneNode>(); - private int _currentIndex = 0; + private List<SceneNode> _nodes = new List<SceneNode>(); + private int _currentIndex = 0; - protected JitterSample _sample { get; private set; } + protected JitterSample _sample { get; private set; } - // During the process of constructing a primitive model, vertex - // and index data is stored on the CPU in these managed lists. - private List<Vector3> _vertexNormalSet = new List<Vector3>(); - private List<ushort> _indexSet = new List<ushort>(); + // During the process of constructing a primitive model, vertex + // and index data is stored on the CPU in these managed lists. + private List<Vector3> _vertexNormalSet = new List<Vector3>(); + private List<ushort> _indexSet = new List<ushort>(); - #endregion + #endregion - public PrimitiveType Type { get; private set; } + public PrimitiveType Type { get; private set; } - protected GeometricPrimitive( JitterSample sample, PrimitiveType type ) - { - this._sample = sample; - this.IsDisposed = false; - this.Type = type; - } + protected GeometricPrimitive( JitterSample sample, PrimitiveType type ) + { + this._sample = sample; + this.IsDisposed = false; + this.Type = type; + } - /// <summary> - /// Adds a new vertex to the primitive model. This should only be called - /// during the initialization process, before InitializePrimitive. - /// </summary> - protected void AddVertex( Vector3 position, Vector3 normal ) - { - _vertexNormalSet.Add( position ); - _vertexNormalSet.Add( normal ); - } + /// <summary> + /// Adds a new vertex to the primitive model. This should only be called + /// during the initialization process, before InitializePrimitive. + /// </summary> + protected void AddVertex( Vector3 position, Vector3 normal ) + { + _vertexNormalSet.Add( position ); + _vertexNormalSet.Add( normal ); + } - /// <summary> - /// Adds a new index to the primitive model. This should only be called - /// during the initialization process, before InitializePrimitive. - /// </summary> - protected void AddIndex( int index ) - { - if ( index > ushort.MaxValue ) - throw new ArgumentOutOfRangeException( "index" ); + /// <summary> + /// Adds a new index to the primitive model. This should only be called + /// during the initialization process, before InitializePrimitive. + /// </summary> + protected void AddIndex( int index ) + { + if ( index > ushort.MaxValue ) + throw new ArgumentOutOfRangeException( "index" ); - _indexSet.Add( (ushort)index ); - } + _indexSet.Add( (ushort)index ); + } - /// <summary> - /// Queries the index of the current vertex. This starts at - /// zero, and increments every time AddVertex is called. - /// </summary> - protected int CurrentVertex - { - get { return _vertexNormalSet.Count / 2; } - } + /// <summary> + /// Queries the index of the current vertex. This starts at + /// zero, and increments every time AddVertex is called. + /// </summary> + protected int CurrentVertex + { + get { return _vertexNormalSet.Count / 2; } + } - /// <summary> - /// Once all the geometry has been specified by calling AddVertex and AddIndex, - /// this method copies the vertex and index data into GPU format buffers, ready - /// for efficient rendering. - private ManualObject InitializePrimitive() - { - ManualObject primitive = _sample.SceneManager.CreateManualObject( this.GetType().Name + this._nodes.Count ); - primitive.Begin( "BaseWhite", OperationType.TriangleList ); + /// <summary> + /// Once all the geometry has been specified by calling AddVertex and AddIndex, + /// this method copies the vertex and index data into GPU format buffers, ready + /// for efficient rendering. + private ManualObject InitializePrimitive() + { + ManualObject primitive = _sample.SceneManager.CreateManualObject( this.GetType().Name + this._nodes.Count ); + primitive.Begin( "JitterSample/Geometries", OperationType.TriangleList ); - //Vertices and normals - for ( int i = 0; i < _vertexNormalSet.Count; i += 2 ) - { - primitive.Position( _vertexNormalSet[ i ] ); - primitive.Normal( _vertexNormalSet[ i + 1 ] ); - } + //Vertices and normals + for ( int i = 0; i < _vertexNormalSet.Count; i += 2 ) + { + primitive.Position( _vertexNormalSet[ i ] ); + primitive.Normal( _vertexNormalSet[ i + 1 ] ); + } - //Indices - foreach ( ushort idx in _indexSet ) - { - primitive.Index( idx ); - } + //Indices + foreach ( ushort idx in _indexSet ) + { + primitive.Index( idx ); + } - primitive.End(); - return primitive; - } + primitive.End(); + return primitive; + } - public void PhysicUpdate( Vector3 pos, Quaternion orientation, Vector3 scale ) - { - if ( _currentIndex == _nodes.Count ) - { - SceneNode n = this._sample.SceneManager.RootSceneNode.CreateChildSceneNode(); - n.AttachObject( this.InitializePrimitive() ); - _nodes.Add( n ); - } + public void PhysicUpdate( Vector3 pos, Quaternion orientation, Vector3 scale ) + { + if ( _currentIndex == _nodes.Count ) + { + SceneNode n = this._sample.SceneManager.RootSceneNode.CreateChildSceneNode(); + n.AttachObject( this.InitializePrimitive() ); + _nodes.Add( n ); + } - _nodes[ _currentIndex ].Scale = scale; - _nodes[ _currentIndex ].Orientation = orientation; - _nodes[ _currentIndex ].Position = pos; - _currentIndex++; - } + _nodes[ _currentIndex ].Scale = scale; + _nodes[ _currentIndex ].O... [truncated message content] |