Mesh.World not rendered OnUpdate

Apr 26, 2010 at 8:14 AM

Hello Einar

Can you please test my code stated below. I think changes in the mesh.World-Matrix during Game.OnUpdate-Method don't have an affect anymore.
This worked bevor you did the Game.OnUpdate-Bugfix.

The code renders a box, which should rotate and scale but I only see the box, without any movements. I'm using Balder_4a541520f7a0.

Thanks,
Roland

public class RotationGame : Game
{
    private Mesh mesh;

    public override void OnLoadContent()
    {
        mesh = this.ContentManager.Load<Mesh>("finalbox.ase");// "finalBox.ase"
        Scene.AddNode(mesh);

        Camera.Position.X = 0;
        Camera.Position.Y = 0;
        Camera.Position.Z = 500;

        Camera.Target.X = 0;
        Camera.Target.Y = 0;
        Camera.Target.Z = 0;

        Camera.Up = this.up;

        mesh.World = Matrix.CreateScale(new Vector(1000, 1000, 1000)) * Matrix.CreateRotationX(90) * Matrix.CreateTranslation(0, 0, 0);

        base.OnLoadContent();
    }

    int rot = 1;
    int scale = 1000;

    public override void OnUpdate()
    {
        mesh.World = Matrix.CreateScale(scale++) * Matrix.CreateRotationX(rot % 360);
        rot = rot + 5;
        if (scale > 3000) scale = 1000;
            
        base.OnUpdate();
    }
}
Apr 26, 2010 at 8:23 AM

Update:

The method "OnUpdate" affects only the first time it is called.

 

Coordinator
Apr 26, 2010 at 11:30 PM

Hi,

I'll give it a go in a couple of minutes. Sorry for the inconvenience of this. 

 

Coordinator
Apr 27, 2010 at 12:25 AM

Thanks for pointing this one out, this explained a problem I had with something else. 

Anyways, it was related to something entirely different - a dirty check for matrices for Nodes which was not functioning as it should.

 

I've checked in a new version.

 

On a second note; you could use the Scale property on the object instead - I'm very glad you didn't, otherwise it would have taken longer to find this bug. :)