fehaar / FFWD-Templates

This is a supporting project for FFWD that provide templates for getting started with using FFWD
Microsoft Public License
11 stars 9 forks source link

Exception error in Mesh.cs #8

Closed CodeHelix closed 12 years ago

CodeHelix commented 12 years ago

I tried to see if I can export a tutorial project called Evac-City and am getting an exception error:

System.IndexOutOfRangeException was unhandled HResult=-2146233080 Message=Index was outside the bounds of the array. Source=PressPlay.FFWD StackTrace: at PressPlay.FFWD.Mesh.GetTriangles(Int32 subMeshIndex) in C:\Users\dwc2987@msn.com\FFWD\Framework\PressPlay.FFWD\Mesh.cs:line 251 at PressPlay.FFWD.Components.RenderItem1.AddMesh(Mesh mesh, Matrix matrix, Int32 subMeshIndex) in C:\Users\dwc2987@msn.com\FFWD\Framework\PressPlay.FFWD\Components\Renderers\RenderItem.cs:line 163 at PressPlay.FFWD.Components.RenderItem.Create(Material material, Mesh mesh, Int32 subMeshIndex, Transform t) in C:\Users\dwc2987@msn.com\FFWD\Framework\PressPlay.FFWD\Components\Renderers\RenderItem.cs:line 41 at PressPlay.FFWD.Components.MeshRenderer.Initialize(AssetHelper assets) in C:\Users\dwc2987@msn.com\FFWD\Framework\PressPlay.FFWD\Components\Renderers\MeshRenderer.cs:line 35 at PressPlay.FFWD.Application.RegisterComponent(Component cmp) in C:\Users\dwc2987@msn.com\FFWD\Framework\PressPlay.FFWD\Application.cs:line 681 at PressPlay.FFWD.Application.RegisterComponents(Queue1 components) in C:\Users\dwc2987@msn.com\FFWD\Framework\PressPlay.FFWD\Application.cs:line 709 at PressPlay.FFWD.Scene.Initialize(Boolean doGarbageCollectAfterAwake) in C:\Users\dwc2987@msn.com\FFWD\Framework\PressPlay.FFWD\Scene.cs:line 78 at PressPlay.FFWD.Application.SceneLoadComplete() in C:\Users\dwc2987@msn.com\FFWD\Framework\PressPlay.FFWD\Application.cs:line 526 at PressPlay.FFWD.Application.Update(GameTime gameTime) in C:\Users\dwc2987@msn.com\FFWD\Framework\PressPlay.FFWD\Application.cs:line 222 at Microsoft.Xna.Framework.Game.Update(GameTime gameTime) at FFWD.Unity.Tests.Game1.Update(GameTime gameTime) in C:\Users\Public\Documents\Unity Projects\Walkers\XNA\Walkers\Game1.cs:line 85 at Microsoft.Xna.Framework.Game.Tick() at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e) at Microsoft.Xna.Framework.GameHost.OnIdle() at Microsoft.Xna.Framework.WindowsGameHost.RunOneFrame() at Microsoft.Xna.Framework.WindowsGameHost.ApplicationIdle(Object sender, EventArgs e) at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at Microsoft.Xna.Framework.WindowsGameHost.Run() at Microsoft.Xna.Framework.Game.RunGame(Boolean useBlockingRun) at Microsoft.Xna.Framework.Game.Run() at FFWD.Unity.Tests.Program.Main(String[] args) in C:\Users\Public\Documents\Unity Projects\Walkers\XNA\Walkers\Program.cs:line 15 InnerException:

I'm guessing the mesh that is used which is a plane didn't export correctly. The plane mesh was used to display the sprites in Unity so will it still need to be used in XNA?

fehaar commented 12 years ago

Is it possible to give me access to the project? Then I can probably see what is going on. I fiddled with the Mesh code yesterday to make it run on 360 - and maybe I have broken something for some types of Meshes.

CodeHelix commented 12 years ago

Yeah here is the link to the online tutorial which has the links to the example projects. I was trying out example project part 6.

http://www.rebelplanetcreations.com/downloads/Other/Tutorials/EVAC-City/How%20To%20Make%20A%20Game%20In%20Unity3D.pdf

fehaar commented 12 years ago

I will take a look.

CodeHelix commented 12 years ago

I think the issue is with the plane that was used in the Evac-City project as its a plane that was created in Maya or 3DS Max as its a .fbx file. I'm just guessing as I went and created another project created a plane in Unity and was able to get the sprite to show but only by using the HiDef profile as when I try using the Reach profile I get an exception error that says XNA Framework Reach profile requires TextureAddressMode to be Clamp when using texture sizes that are not powers of two. Could this be due to the tiling of the sprite which is set to -0.2 and -0.25?

CodeHelix commented 12 years ago

Figured out how to get the sprite to show using the Reach profile as had to go to the texture properties and set it to clamp and use 0.2 and 0.25 for the tiling as it won't show when using negative numbers. I'll keep messing with it and will update if I'm able to get everything working.

CodeHelix commented 12 years ago

Well, I tried changing the plane to one created in Unity in the Evac-City project and still ended up getting the same error so guess I was wrong about it being the plane.

fehaar commented 12 years ago

All right. I just took it for a spin. Actually there are a lot of things here that are not really working that good. Fist of all - the error you received was due to the fact that the floor had two materials, but only one submesh. This was not supported. I have fixed the error so it doesn't crash. There is still something off with the new rendering support though. For that reason I made a setting that can disable the new rendering system that is in progress and fall back to the batched one that we used in Tentacles.

So in your Game1 file in XNA add the following line in the Initialize method: ApplicationSettings.UseFallbackRendering = true;

With this on, the level will be shown.

Furthermore, due to Issue #18 in the FFWD project, you have to change like 179 of AIscript to not do objPlayer == null but (bool)objPlayer.

Lastly - update FFWD from source as I have fixed some miscellaneous bugs brought up by the scripts.

When you have done that, you should be able to get the game up and running. Sort of. There are some things that you will encounter that needs looking at:

But with these few changes you should be able to get something up and running.

fehaar commented 12 years ago

BTW - I have also fixed the texture Clamp issue so it will automatically clamp if you are using a non power of two texture.

fehaar commented 12 years ago

Found out what is going on with the rendering of the floor. What you see is the bump mapped floor in a non bump mapped state. The "matFloorOverlay" is drawn first and then drawn over by the matFloor material. Combining the two materials into one is not supported right now, and will probably not work reasonably on the phone. So if it should look like in Unity you would have to do something different.