Click here to Skip to main content
15,891,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I wrote a code to update the position of one of the bones in XNA.

Mycode consists of three parts

First part is Loadcontent()
C#
firstmodel = Content.Load<Model>("Models\\second-sample-");
  worldtransforms = new Matrix[firstmodel.Bones.Count];
  originalbonetransforms = new Matrix[firstmodel.Bones.Count];
  bonetransforms = new Matrix[firstmodel.Bones.Count];
  firstmodel.CopyAbsoluteBoneTransformsTo(originalbonetransforms);
  firstmodel.CopyAbsoluteBoneTransformsTo(bonetransforms);
  aspectratio = graphics.GraphicsDevice.Viewport.AspectRatio;

Second part consists of just updating the position of the bone and updating in worldtransform.
Update.

C#
bonetransforms[Index] =  originalbonetransforms[Index]* Matrix.CreateRotationX(50.5f) ;
worldtransforms[0] = bonetransforms[0];

           for (int bone = 1; bone < worldtransforms.Length; bone++)
           {
               int parentbone = firstmodel.Bones[bone].Parent.Index;
               worldtransforms[bone] = bonetransforms[bone] * worldtransforms[parentbone];
           }

and finally Draw() method is as usual.

But control is directly going to
C#
protected override void Initialize()
        {
            base.Initialize();
        }

I defined all my methods as protected.
My question is that as soon as i run the code control moves from Lodecontent() to Initialize() and the model is displayed on screen, why it is not moving in to Update()
Posted

1 solution

I think you have formulated a good and valid question. But anyway, for this kind of "mind bugs" I'd always try to read the docu first (even more if I use a specific technology (API)).

so have a look at http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.update.aspx[^]

Read also about Initialize and Draw - I think it's well explained there - and the sequence (or interval) the methods get called (in short: don't count on Updated beeing called during initialization phase).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900