Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Offline GreatVV  
#1 Posted : Wednesday, November 23, 2011 5:22:53 PM(UTC)
GreatVV

Joined: 10/29/2011(UTC)
Posts: 4

I'm creating platformer with physics and have a problem (because of i can't find sample I wrote here)
I wanna create polygon body (rectangle has no problem) when I try to do it I have following error:


Program: Shaman v0.9.0.0
Modules: Graphic=OpenTK, Input=Windows, Audio=OpenTK, Video=, Physics=Farseer
Start Time: 2011-11-23 21:51:26
Platform: Windows, 3 CPU Cores, 32 bit (on 64 bit OS), Windows 7 v7601 Service Pack 1, Resolution: 1024, 768
User: GreatVV (GREATVVPC)

Program: Shaman v0.9.0.0
Modules: Graphic=OpenTK, Input=Windows, Audio=OpenTK, Video=, Physics=Farseer
Start Time: 2011-11-23 22:02:54
Platform: Windows, 3 CPU Cores, 32 bit (on 64 bit OS), Windows 7 v7601 Service Pack 1, Resolution: 1024, 768
User: GreatVV (GREATVVPC)

00.113 Warning: You have used no modules and no run code, there is nothing to do for this application. Please add some render code.
at Delta.Utilities.Log.Warning(System.String message)
at Delta.Engine.Application.GagdpQkbw7DN9vFsam8(System.Object )
at Delta.Engine.Application.Start()
D:\My Projects\Shaman\Shaman\Program.cs(26,13): at Shaman.Program.Main()

05.869 Warning: CreateInstance failed for 'Shaman.Game': Адресат вызова создал исключение.
System.InvalidCastException: Объект должен реализовывать интерфейс IConvertible. (sorry for russian: error about there is no implementation of IConvertible
в System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
в System.Convert.ChangeType(Object value, Type conversionType)
в Delta.Utilities.Helpers.ArrayHelper.SafeGet[KeyType,ValueType](Dictionary`2 dict, KeyType key)
в Delta.PhysicsEngines.Farseer.FarseerBody.CreateShape() в H:\Svalko\DeltaEngine0.9.1\PhysicsEngines\Farseer\FarseerBody.cs:строка 434

в Delta.PhysicsEngines.Farseer.FarseerBody..ctor(FarseerPhysics physicsManager, PhysicsShape shape, Vector initialPosition) в H:\Svalko\DeltaEngine0.9.1\PhysicsEngines\Farseer\FarseerBody.cs:строка 262
в Delta.PhysicsEngines.Farseer.FarseerPhysics.CreateBody(Boolean is2D, PhysicsShape shape, Vector initialPosition) в H:\Svalko\DeltaEngine0.9.1\PhysicsEngines\Farseer\FarseerPhysics.cs:строка 149
в Delta.PhysicsEngines.Physics.lN4BuYSMr0JWeBhK5ga(Object , Boolean is2DBody, Object , Vector initialPosition)
в Delta.PhysicsEngines.Physics.Create2DBody(PhysicsShape shape, Point initialPosition)
в Delta.PhysicsEngines.Physics.CreatePolygon(Point initialPosition, IList`1 vertices, Single density)
в Shaman.GameModel.Objects.PlayerUnit.CreatePhysicsBody() в D:\My Projects\Shaman\Shaman\GameModel\Objects\PlayerUnit.cs:строка 23
в Shaman.GameObject..ctor(Rectangle boundsInMeters, GameWorld gameWorld) в D:\My Projects\Shaman\Shaman\GameModel\GameObject.cs:строка 45
в Shaman.GameModel.Objects.Unit..ctor(Rectangle boundsInMeters, GameWorld gameWorld) в D:\My Projects\Shaman\Shaman\GameModel\Objects\Unit.cs:строка 7
в Shaman.GameModel.Objects.PlayerUnit..ctor(Rectangle boundsInMeters, GameWorld gameWorld) в D:\My Projects\Shaman\Shaman\GameModel\Objects\PlayerUnit.cs:строка 11
в Shaman.Game..ctor() в D:\My Projects\Shaman\Shaman\Game.cs:строка 75
at Delta.Utilities.Log.Warning(System.String message)
at Delta.Engine.Dynamic.Factory.HKAF8tOqV5hTKqW9fx(System.Object )
at Delta.Engine.Dynamic.Factory.Create(System.Type classToCreate, System.Object argument)
at Delta.Engine.Dynamic.Factory.Create()
at Delta.Engine.Application.get_Instance()
at Delta.Engine.Application.Ca61Bxk8ucDr6GpPI7L()
at Delta.Engine.Application.Start()
D:\My Projects\Shaman\Shaman\Program.cs(26,13): at Shaman.Program.Main()

06.123 Error: Fatal Error: Unhandled exception occurred (Application is terminated, we cannot recover!): System.NullReferenceException: Ссылка на объект не указывает на экземпляр объекта.
в Delta.Engine.Application.T0uMvYkQfvK6NOkYobx(Object )
в Delta.Engine.Application.Start()
в Shaman.Program.Main() в D:\My Projects\Shaman\Shaman\Program.cs:строка 26
в System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
в System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
в Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
в System.Threading.ThreadHelper.ThreadStart_Context(Object state)
в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
в System.Threading.ThreadHelper.ThreadStart()
at Delta.Utilities.Log.Warning(System.String message)
at Delta.Engine.Application.Error(System.String message, System.Object exceptionObject)
at Delta.Engine.Application.vHtyIkkwbQ2GjSOLMV3(System.Object , System.Object )
at Delta.Engine.Application.HandleUnhandledException(System.Object sender, System.UnhandledExceptionEventArgs ex)
at Delta.Engine.Application.T0uMvYkQfvK6NOkYobx(System.Object )
at Delta.Engine.Application.Start()
D:\My Projects\Shaman\Shaman\Program.cs(26,13): at Shaman.Program.Main()


Wanna join the discussion?! Login to your forum accountregister a new account. Or Connect via Facebook Twitter Google

Offline Benjamin  
#2 Posted : Wednesday, November 23, 2011 5:53:03 PM(UTC)
Benjamin

Medals: Admin

Joined: 8/20/2011(UTC)
Posts: 1,421
Location: Hannover

Thanks: 18 times
Was thanked: 97 time(s) in 92 post(s)
Well, first of all you are still using v0.9.0, please update to v0.9.1, which has your "no modules" problem already fixed.

Then it is hard to help you because we cannot see your code in Program.cs, please write it down here or write me a PM so I can help Cool
Offline GreatVV  
#3 Posted : Wednesday, November 23, 2011 8:34:05 PM(UTC)
GreatVV

Joined: 10/29/2011(UTC)
Posts: 4

It's strange thing about v 0.9.0 - I'm sure that I use v.0.9.1 (Nightly release) I change all reference right after release.
I will try to create new project for v.0.9.1 - i will write about results

///
Update:
I create new project - problem solved.
Sorry for silly question
thx for help

Edited by user Wednesday, November 23, 2011 8:39:55 PM(UTC)  | Reason: Not specified

Offline Benjamin  
#4 Posted : Wednesday, November 23, 2011 11:51:14 PM(UTC)
Benjamin

Medals: Admin

Joined: 8/20/2011(UTC)
Posts: 1,421
Location: Hannover

Thanks: 18 times
Was thanked: 97 time(s) in 92 post(s)
Okay, whenever creating a project all references are to the version currently used. Maybe we should provide a tool to update all assembly references. Maybe the ContentManager could do this.

We had similar problems internally and we just told the teams to change the references by hand, but that could be a bit much to ask for when updating a lot with nightly releases.
Offline MSDeveloper  
#5 Posted : Wednesday, December 14, 2011 11:37:40 PM(UTC)
MSDeveloper

Joined: 11/19/2011(UTC)
Posts: 10

Thanks: 2 times
Hey there, actually I get a problem on creating a PhysicsShape. I dont know what I should pass as object[] args. The doc is very short: args = the args.

Maybe someone could give me a hint.

Passing null throws a nullexception (as expected ;-) )

Thank you in advance!
Offline Benjamin  
#6 Posted : Wednesday, December 14, 2011 11:59:28 PM(UTC)
Benjamin

Medals: Admin

Joined: 8/20/2011(UTC)
Posts: 1,421
Location: Hannover

Thanks: 18 times
Was thanked: 97 time(s) in 92 post(s)
Yes, you are right, it is a bit confusing. Actually the object values will be added to a dictionary with the PhysicsShape.PropertyType as the key and the object values (mostly float values) passed in.

Here are some examples on how to use it (Create2DBody just calls new PhysicsBody in 2D mode):

Code:

		#region CreateCircle(Static)
		/// <summary>
		/// Creates Body with a Circle shape attached to it.
		/// </summary>
		/// <param name="radius">The radius of circle.</param>
		/// <param name="density">The density of body.</param>
		/// <returns>The new created body.</returns>
		public static PhysicsBody CreateCircle(float radius,
			float density)
		{
			// First create body.
			PhysicsShape circle = Instance.CreateShape(ShapeType.Circle,
				new object[]
				{
					radius, density
				});
			PhysicsBody body = Create2DBody(circle, Point.Zero);
			return body;
		}
		#endregion

		#region CreateRectangle (Static)
		/// <summary>
		/// Creates Body with a Rectangle shape attached to it.
		/// </summary>
		/// <param name="initialPosition">The initial position of body.</param>
		/// <param name="width">The width of rectangle.</param>
		/// <param name="height">The height of rectangle.</param>
		/// <param name="density">The density of body.</param>
		/// <returns>The new created body.</returns>
		public static PhysicsBody CreateRectangle(Point initialPosition,
			float width, float height, float density)
		{
			// First create body.
			PhysicsShape rectangle = Instance.CreateShape(
				ShapeType.Rectangle,
				new object[]
				{
					width, height, density, Point.Zero
				});
			PhysicsBody body = Create2DBody(rectangle, initialPosition);
			return body;
		}
		#endregion


etc. (ask if you need more examples)

This is the method used to store the properties. Again, this will not stay this way (very ugly solution imo). You could also try to call Create2DBody, Create3DBody or even create the shapes yourself (whatever is supported in each physics implementation) for more control right now:

Code:

		#region StoreProperties
		/// <summary>
		/// Store properties in faster way.
		/// </summary>
		/// <param name="args">
		/// Array of objects containing arguments need for body creation.
		/// </param>
		private void StoreProperties(object[] args)
		{
			switch (ShapeType)
			{
					#region 2D shapes
				case ShapeType.Circle:
					Properties[PropertyType.Radius] = args[0];
					Properties[PropertyType.Density] = args[1];
					break;
				case ShapeType.Rectangle:
					Properties[PropertyType.Width] = args[0];
					Properties[PropertyType.Height] = args[1];
					Properties[PropertyType.Density] = args[2];
					Properties[PropertyType.Offset] = args[3];
					break;
				case ShapeType.Ellipse:
					Properties[PropertyType.RadiusX] = args[0];
					Properties[PropertyType.RadiusY] = args[1];
					Properties[PropertyType.Edges] = args[2];
					Properties[PropertyType.Density] = args[3];
					break;

				case ShapeType.Polygon:
					Properties[PropertyType.Vertices] = args[0];
					Properties[PropertyType.Density] = args[1];
					break;

				case ShapeType.Compound:
					Properties[PropertyType.Vertices] = args[0];
					Properties[PropertyType.Density] = args[1];
					break;

				case ShapeType.Gear:
					Properties[PropertyType.Radius] = args[0];
					Properties[PropertyType.NumberOfTeeth] = args[1];
					Properties[PropertyType.TipPercentage] = args[2];
					Properties[PropertyType.ToothHeight] = args[3];
					Properties[PropertyType.Density] = args[4];
					break;
					#endregion

					#region 3D shape
				case ShapeType.Sphere:
					Properties[PropertyType.Radius] = args[0];
					break;

				case ShapeType.Box:
					Properties[PropertyType.Size] = args[0];
					break;

				case ShapeType.Capsule:
					float radius = (float)args[1];
					Properties[PropertyType.Depth] = args[0];
					Properties[PropertyType.Radius] = radius;
					break;

				case ShapeType.Cone:
				case ShapeType.Cylinder:
					Properties[PropertyType.Height] = args[0];
					Properties[PropertyType.Radius] = args[1];
					break;

				case ShapeType.Triangle:
					Properties[PropertyType.Mesh] = args[0];
					Properties[PropertyType.LocalSpaceMatrix] = args[1];
					Properties[PropertyType.InvertTriangles] = args[2];
					break;

				case ShapeType.Terrain:
					Properties[PropertyType.Heights] = args[0];
					Properties[PropertyType.ScaleX] = args[1];
					Properties[PropertyType.ScaleY] = args[2];
					break;
					#endregion
			}
		}
		#endregion
thanks 1 user thanked Benjamin for this useful post.
MSDeveloper on 12/15/2011(UTC)
Offline MSDeveloper  
#7 Posted : Thursday, December 15, 2011 12:32:39 AM(UTC)
MSDeveloper

Joined: 11/19/2011(UTC)
Posts: 10

Thanks: 2 times
Thank you for your quick reply, Benjamin.

Awesome, thanks for the detailed post! Very Helpful!

Thanks
Rss Feed  Atom Feed
Users browsing this topic
OceanSpiders 2.0
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2018, Yet Another Forum.NET
This page was generated in 0.113 seconds.