Converting the demos to monogame

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Peter Prins
Posts: 54
Joined: Fri Mar 11, 2011 11:44 pm

Converting the demos to monogame

Post by Peter Prins »

Hello Everyone,

After stopping playing with BEPUphysics for a while I'm looking to continue some of my old projects. I'm running into some problems getting things to work on my new machine. The problem is that XNA isn't supported anymore, which means I have to use VS 2010 to be able to get the demos running. The problem with this is that I have windows 10 on my machine and it seems that it doesn't support VS 2010. Rather then going through the trouble of trying to find a download for it (which is hard enough) and then trying to get it to work on my machine (which doesn't seem to be that easy either form what I've read online) I decided to port the demos to monogame instead.
I've started by adding to code for the BEPUphysicsDrawer to a new class library project, using a reference to the monogame dll, and this seems to be working fine for the most part. There are two errors though, both of which occur in the ModelDisplayObjectBatch class. I'm using the source code of commit 7bd277b2f999.

The first error is that the textureIndicesParameter.SetValue call in line 222 of the Draw method doesn't accept int[] as an argument. This seems to be an oversight on the part of the monogame developers, since the SetValue method has overloads to accept arrays of every other values it can accept singletons from. Would there be any way to work around this problem? (The error occurs twice on line 116, and twice on line 195.)

The second error is the conversion from VertexBuffer to VertexBufferBinding. It seems this conversion should be implicit, but I get this error:

Code: Select all

Error	CS0029	Cannot implicitly convert type 'Microsoft.Xna.Framework.Graphics.VertexBuffer' to 'Microsoft.Xna.Framework.Graphics.VertexBufferBinding'
The VertexBufferBinding does contain a constructor that takes a VertexBuffer as an argument. Can anyone verify that this is what is intended?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Converting the demos to monogame

Post by Norbo »

The first error is that the textureIndicesParameter.SetValue call in line 222 of the Draw method doesn't accept int[] as an argument.
It appears there was a PR on monogame that addressed this but which was not merged, but there seems to be something else going on in the BEPUphysicsDrawer itself: the .fx-side version of that array is of type float, not int. So it only works in XNA due to under-the-covers magic anyway. Swapping the type to float should work.
The VertexBufferBinding does contain a constructor that takes a VertexBuffer as an argument. Can anyone verify that this is what is intended?
Seems to be! This code is ancient enough that I'm about as familiar with it as you :P

I went ahead and uploaded a couple of changes to avoid these issues for future ports.

It's too bad I'm so behind on my timeline- I was hoping to have the 2.0 demos and drawer up and running by now, which would have eliminated this kind of annoyance.
Peter Prins
Posts: 54
Joined: Fri Mar 11, 2011 11:44 pm

Re: Converting the demos to monogame

Post by Peter Prins »

Hi Norbo,

I've made those changes myself. I've also changed all my projects' dot net frameworks to 4.5, to make sure they match that of my monogame version. This allows me to compile all the projects, but when I tried to run the demo I got a MissingManifestResourceException. This was fixed by removing all content related files from the BEPUphysicsDrawer. I intend to load the one resource required in the drawer directly from the BEPYphysicsDemos Game.Content.

Now the solution has stopped compiling once more, but all errors originate in the BEPUphysicsDemos project, which makes me think we are getting closer. The errors seem to be in the building of resources, so I opened the Content.mgcb file and tried to rebuild various resources. The spritefonts and images build just fine, but the fbx and fx files give an error. The fx files are easy enough to fix by updating the shader versions to vs_4_0 and ps_4_0.

With the fbx files I get this error:

Code: Select all

D:/peter/hobbies/programeren/MonoGame/BepuPhysics/BEPUphysicsDemos/Content/bepubox.fbx
D:/peter/hobbies/programeren/MonoGame/BepuPhysics/BEPUphysicsDemos/Content/bepubox.fbx: error: Importer 'FbxImporter' had unexpected failure!
Assimp.AssimpException: Error importing file: FBX-DOM unsupported, old format version, supported are only FBX 2011, FBX 2012 and FBX 2013
   at Assimp.AssimpContext.ImportFile(String file, PostProcessSteps postProcessFlags)
   at Microsoft.Xna.Framework.Content.Pipeline.OpenAssetImporter.Import(String filename, ContentImporterContext context)
   at Microsoft.Xna.Framework.Content.Pipeline.ContentImporter`1.Microsoft.Xna.Framework.Content.Pipeline.IContentImporter.Import(String filename, ContentImporterContext context)
   at MonoGame.Framework.Content.Pipeline.Builder.PipelineManager.ProcessContent(PipelineBuildEvent pipelineEvent)
Would you by chance have versions of these files lying around that are of one of these newer format versions? Or would you know how to manually update these files to newer versions?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Converting the demos to monogame

Post by Norbo »

This might work: http://usa.autodesk.com/adsk/servlet/pc ... d=22694909

If it doesn't... I don't know if I still have the character controller demo original file, but I did find the playground mesh's .obj:
playground2.zip
(522.14 KiB) Downloaded 218 times
That's unfortunate since the character controller demo one is the only one that has much of a point.

There's probably some other obscure tooling or path that could get the old fbxes updated too, but... it may be easier just to replace them with dummy meshes or outright delete the demos referencing them if the converter doesn't work out.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Converting the demos to monogame

Post by Norbo »

I also found the character controller demo mesh and reexported a binary 7.4 fbx:
Attachments
CharacterControllerTestTerrain.zip
(36.38 KiB) Downloaded 221 times
Peter Prins
Posts: 54
Joined: Fri Mar 11, 2011 11:44 pm

Re: Converting the demos to monogame

Post by Peter Prins »

Hi Norbo,

Thanks for the help! The converter fixed my problem with the .fbx files. After this I still had a weird compilation error, that turned out to be a weird glitch in Visual Studio that caused it not to rebuild the BEPUphysicsDrawer project when I rebuilt the solution. After fixing this I got the demo running.

I'm currently trying to Port one of my old projects over to MonoGame. This still has some errors with the new version of BEPUphysics. I'll post some questions as soon as I have some more time to work on it.
Post Reply