Jump to content
  • Advertisement
Sign in to follow this  
jdub

Matrix Inversion XNA

This topic is 3774 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have two functions for setting rendering transformations in my scene graph that are called before every scene node is rendered:

 public virtual void PreRender(Scene scene)
        {
            // push a copy of the top matrix onto the stack
            scene.MatrixStack.Push ();
            
            // multiply that matrix with the one that
            // is already there and replace it with the result
            scene.MatrixStack.MultMatrix ( this.sceneProps.ParentSpaceMatrix );
            
            
            Matrix WorldTrans = scene.MatrixStack.Peek();

            //translate world space into screen space
            Matrix ScreenMat = scene.Camera.TransformToScreen(WorldTrans);

            // now this node is the root of whatever is drawn after it
            scene.Transform *= ScreenMat;
        }

        public virtual void PostRender(Scene scene)
        {
            // Pop the top matrix off of the stack and get us back up the tree
            scene.MatrixStack.Pop ();
            
            // ***Now here is the trouble spot***
            // I need to undo the transformation I just did in prerender
            // so I invert the matrix
            Matrix TransMat = Matrix.Invert ( scene.Transform );

            
        }



I would think that finding the inverse of a matrix each time I rendered a scene node would make my game incredibly slow. I have heard that it could be done quickly for transformation matrices by swapping their rows and collumns or something like that. My questions are: Does XNA take advantage of what I just mentioned and make finding the inverse of a transformation matrix speedy? Is this the right way to go about un doing transformations?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!