Hi, I’m quite new to Monogame and I’m having an issue rendering the 3D model I made in Blender and I would really appreciate any help. I exported my model as a dae file and converted it to fbx using an fbx converter. The fbx file renders fine in Microsoft’s 3D viewer and other software (albeit with the brick texture missing) but when I try to draw it in Monogame it doesn’t render properly. Thanks
Hi, when I tried to export directly to fbx I got the same issue so I used dae and converted it to see if it was a problem with the export from blender or the import into monogame
Hi, I’m sorry, I’m quite new to monogame, but I’ve managed to export as a directx file and I’ve loaded into monogame via the pipeline but when I try to draw it I’m getting an error at mesh.Draw() code (System.InvalidOperationException
HResult=0x80131509
Message=An error occurred while preparing to draw. This is probably because the current vertex declaration does not include all the elements required by the current vertex shader. The current vertex declaration includes these elements: SV_Position0.
Source=MonoGame.Framework
StackTrace:
at Microsoft.Xna.Framework.Graphics.InputLayoutCache.GetOrCreate(VertexBufferBindings vertexBuffers)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.PlatformApplyState(Boolean applyShaders)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.ApplyState(Boolean applyShaders)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.PlatformDrawIndexedPrimitives(PrimitiveType primitiveType, Int32 baseVertex, Int32 startIndex, Int32 primitiveCount)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType primitiveType, Int32 baseVertex, Int32 startIndex, Int32 primitiveCount)
at Microsoft.Xna.Framework.Graphics.ModelMesh.Draw()
at Game1.Avatar.Draw(Matrix viewMatrix, Matrix projectionMatrix) ) Does directx not work with meshes? thanks
(System.InvalidOperationException
HResult=0x80131509
Message=An error occurred while preparing to draw. This is probably because the current vertex declaration does not include all the elements required by the current vertex shader. The current vertex declaration includes these elements: SV_Position0.
Source=MonoGame.Framework
StackTrace:
at Microsoft.Xna.Framework.Graphics.InputLayoutCache.GetOrCreate(VertexBufferBindings vertexBuffers)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.PlatformApplyState(Boolean applyShaders)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.ApplyState(Boolean applyShaders)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.PlatformDrawIndexedPrimitives(PrimitiveType primitiveType, Int32 baseVertex, Int32 startIndex, Int32 primitiveCount)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType primitiveType, Int32 baseVertex, Int32 startIndex, Int32 primitiveCount)
at Microsoft.Xna.Framework.Graphics.ModelMesh.Draw()
at Game1.Avatar.Draw(Matrix viewMatrix, Matrix projectionMatrix) )
[/quote]
(System.InvalidOperationException
HResult=0x80131509
Message=An error occurred while preparing to draw. This is probably because the current vertex declaration does not include all the elements required by the current vertex shader. The current vertex declaration includes these elements: SV_Position0.
Source=MonoGame.Framework
StackTrace:
at Microsoft.Xna.Framework.Graphics.InputLayoutCache.GetOrCreate(VertexBufferBindings vertexBuffers)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.PlatformApplyState(Boolean applyShaders)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.ApplyState(Boolean applyShaders)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.PlatformDrawIndexedPrimitives(PrimitiveType primitiveType, Int32 baseVertex, Int32 startIndex, Int32 primitiveCount)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType primitiveType, Int32 baseVertex, Int32 startIndex, Int32 primitiveCount)
at Microsoft.Xna.Framework.Graphics.ModelMesh.Draw()
at Game1.Avatar.Draw(Matrix viewMatrix, Matrix projectionMatrix) )
Remember to add three backticks again at the end of the code block to close it…
EDIT
And I just found an issue in doing it right lol
BACKTICKS
CODE BLOCK
BACKTICKS
NOT
BACKTICKS
CODEBLOCK BACKTICKS
The closing backticks must be on a new line… just like the opening backticks
Ok, I’ve redone that below. Do you happen to know how to fix the error? Many thanks
System.InvalidOperationException
HResult=0x80131509
Message=An error occurred while preparing to draw. This is probably because the current vertex declaration does not include all the elements required by the current vertex shader. The current vertex declaration includes these elements: SV_Position0.
Source=MonoGame.Framework
StackTrace:
at Microsoft.Xna.Framework.Graphics.InputLayoutCache.GetOrCreate(VertexBufferBindings vertexBuffers)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.PlatformApplyState(Boolean applyShaders)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.ApplyState(Boolean applyShaders)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.PlatformDrawIndexedPrimitives(PrimitiveType primitiveType, Int32 baseVertex, Int32 startIndex, Int32 primitiveCount)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType primitiveType, Int32 baseVertex, Int32 startIndex, Int32 primitiveCount)
at Microsoft.Xna.Framework.Graphics.ModelMesh.Draw()
at Game1.Avatar.Draw(Matrix viewMatrix, Matrix projectionMatrix) in C:\Users\emmaj\OneDrive - Cardinal Newman College\Computer Science\NEA\Game1\Game1\Avatar.cs:line 49
at Game1.Game1.Draw(GameTime gameTime) in C:\Users\emmaj\OneDrive - Cardinal Newman College\Computer Science\NEA\Game1\Game1\Game1.cs:line 113
at Microsoft.Xna.Framework.Game.DoDraw(GameTime gameTime)
at Microsoft.Xna.Framework.Game.Tick()
at MonoGame.Framework.WinFormsGameWindow.TickOnIdle(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 MonoGame.Framework.WinFormsGameWindow.RunLoop()
at MonoGame.Framework.WinFormsGamePlatform.RunLoop()
at Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior)
at Microsoft.Xna.Framework.Game.Run()
at Game1.Program.Main() in C:\Users\emmaj\OneDrive - Cardinal Newman College\Computer Science\NEA\Game1\Game1\Program.cs:line 18
This exception was originally thrown at this call stack:
[External Code]
Inner Exception 1:
SharpDXException: HRESULT: [0x80070057], Module: [General], ApiCode: [E_INVALIDARG/Invalid Arguments], Message: The parameter is incorrect.
I just used the pipeline tool, I haven’t tried MGCB.
Tried using .obj and got a similar result to using .fbx
I’m wondering if its a problem with the model itself as I’ve loaded other models into the game with no issue. I used blender’s archimesh add on so I don’t know if that’s messed it up.
Thanks for your help. I remade the model without using the archimesh add on and now it works exporting with fbx. It hasn’t got the brick texture with it, I think because I used the nodes in blender’s shader tab to make that so I’m trying to figure out how to bake that and then get that into the pipeline with the model
Hi Emma, I was having similar issues with Blender models not displaying properly in monogame but working fine in 3Dviewer. For me, the issue was that I had not applied the scale in blender prior to exporting as FBX. Not sure if you are still having issues. If you are, hope this helps.