Model error

May 7, 2010 at 7:46 PM

I've been trying to use my own model in place of the animated model that comes with the scene editor. I've tested the model itself, it works fine. Im wondering how to use it in the scene editor, Ive tried using the skinned model filename dropbox, but i get the error

"Property value is not valid"

"Value cannot be null.
Parameter name: assetName"

Can anyone shed light on what I've done wrong here?

 

May 8, 2010 at 8:56 PM

Ok I got the model into the scene editor, saved my xml and loaded it. The scene appears as it should, except for the model. In it's place the standard marine model appears, despite the fact that I changed the model in the editor before saving. Does anyone know why this happens? I'm still getting my head around the Ox engine, hence the noob questions :) Hopefully my experiences will be useful to someone else later.

Editor
May 8, 2010 at 11:14 PM

if you are refering to the scene editor.  you need to include the model and compile ANY project to create the .xnb compiled resource file. then you need to copy that to the content/models folder in the scene editor with the other models. then in the scene editor you will need to change the model file name to correspond with the name of your model.

if the problem is with the engine / code, we will need to see it :)

 

-bubzy

May 9, 2010 at 2:18 AM

I compile the model, got the .xnb file like you said, and it works with the scene editor ok.

The original .fbx and texture files are included in my project, as is the xml scene document. Does it need special draw code for a custom model? im familiar with how to do that from older projects, it's just that im not sure what Ox requires.

Editor
May 9, 2010 at 8:34 AM

can u post ur gamescript.cs? could be something simple like a missing "using"statement or something more complicated that i cant think of right now :D

 

-bubzy.

May 9, 2010 at 7:10 PM

using Microsoft.Xna.Framework;
using Ox.Engine;
using Ox.Engine.Component;
using Ox.Engine.Utility;
using Ox.Scene;
using Ox.Scene.Component;

namespace OxSceneLoader
{
    /// <summary>
    /// GameScript implements your Ox Game Engine game.
    /// </summary>
    public class GameScript : ComponentScript<OxComponent>
    {
        public GameScript(OxEngine engine, Transfer<OxComponent> component)
            : base(engine, component)
        {
            // create a domain to manage the current level
            Engine.CreateDomain("CurrentLevel");
            // load the level
            Engine.LoadDocument("MyScene2.xml", SceneConfiguration.SceneDocumentType, "CurrentLevel");
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                // unload the current level
                Engine.DestroyDomain("CurrentLevel");
            }
            base.Dispose(disposing);
        }

        protected override void UpdateHook(GameTime gameTime)
        {
            base.UpdateHook(gameTime);
           
        }
    }
}


As I said, I'm not really sure how to approach drawing a custom model.

Editor
May 10, 2010 at 7:41 AM
Edited May 10, 2010 at 7:44 AM

well. theres certainly no problem there.

 

you can try and load it manually

a bit of fiddling but useful to know anyway

 

using Microsoft.Xna.Framework;
using Ox.Engine;
using Ox.Engine.Component;
using Ox.Engine.Utility;
using Ox.Engine.Primitive;
using Ox.Scene;
using Ox.Scene.Component;
using Ox.Scene.LightNamespace;

namespace OxSceneLoader
{
    /// <summary>
    /// GameScript implements your Ox Game Engine game.
    /// </summary>
    /// private
    /// 
    
    public class GameScript : ComponentScript<OxComponent>
    {
        private AnimatedModel testModel;


        public GameScript(OxEngine engine, Transfer<OxComponent> component)
            : base(engine, component)
        {
            // TODO: Put your game's initialization code here
            engine.CreateDomain("CurrentLevel");
            engine.LoadDocument("MyScene2.xml", SceneConfiguration.SceneDocumentType, DomainName);
            testModel = new AnimatedModel(engine, DomainName, true, "ox/models/PlayerMarine", new BoxPrimitive()); // you can add your own model file name here.
            testModel.Parent = engine.Root;
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                // TODO: Put your game's disposal code here
                Engine.DestroyDomain("CurrentLevel");
            }
            base.Dispose(disposing);
        }

        protected override void UpdateHook(GameTime gameTime)
        {
            base.UpdateHook(gameTime);
 Engine.Camera.SetTransformByLookTarget(new Vector3(0,140,-70), Vector3.Up, testModel.Position);
            // TODO: Put your game's update code here
        }
    }
}

May 10, 2010 at 9:46 PM
Edited May 10, 2010 at 9:48 PM

I created a new scene, with no animated model token, to test the code you gave me. When it's loaded my model appears, albeit warped, while the 'dude' model appears some distance behind it. Ive also noticed that the scene displays a skybox that I did not add. Could this be a mistake I made with the scene editor? As i said, I created a new scene, one that contains only terrain and an ambient light.

Editor
May 10, 2010 at 10:54 PM

looks like a mistake you have made mate, tried several times now but none of them have made a skybox without one being created in the scene editor.

keep at it. :)

 

bubzy