@Jens_Eckervogt wrote:
Hello everyone,
I have tried to understand but why does it happen? box doesn't see in MonoGame.
I am sorry because I still learn more more.....
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; namespace MonoCrraft { /// <summary> /// This is the main type for your game. /// </summary> public class Game1 : Game { GraphicsDeviceManager graphics; SpriteBatch spriteBatch; Model model; BasicEffect effect; public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; } protected override void Initialize() { base.Initialize(); } protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); model = Content.Load<Model>("box"); effect = new BasicEffect(GraphicsDevice); effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, GraphicsDevice.Viewport.AspectRatio, 1.0f, 100.0f); effect.View = Matrix.CreateLookAt(new Vector3(2, 3, 2), Vector3.Zero, Vector3.Up); } protected override void UnloadContent() { } protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) Exit(); base.Update(gameTime); } /** * Model and matrix */ private Matrix GetParentTransform(Model m, ModelBone mb) { return (mb == m.Root) ? mb.Transform : mb.Transform * GetParentTransform(m, mb.Parent); } private void DrawModel(Model m, Matrix world, BasicEffect be) { foreach(ModelMesh mm in model.Meshes) { foreach(ModelMeshPart mmp in mm.MeshParts) { be.World = GetParentTransform(m, mm.ParentBone) * world; GraphicsDevice.SetVertexBuffer(mmp.VertexBuffer, mmp.VertexOffset); GraphicsDevice.Indices = mmp.IndexBuffer; be.CurrentTechnique.Passes[0].Apply(); GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, mmp.NumVertices, mmp.StartIndex, mmp.PrimitiveCount); } } } protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); DrawModel(model, Matrix.Identity, effect); base.Draw(gameTime); } } }
I already exported box.fbx from Blender 2.79x
Result: box doesn't show up.
I have tried to understand with tutorial
How do I fix if model doesn't show in Game.
// EDIT
It seems problem with MonoGame 3.7 because ContentException of fbx, dae, obj etc don't work.
I go back MonoGame 3.6 and it works fine.
Thanks!
Posts: 1
Participants: 1