• Advertisement
Sign in to follow this  

Why RotationMatrix keeps its value? xna

This topic is 3825 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

when I call SetTriggerMatrix() function, the object scales and rotates (it keeps rotating it does not hold the angle) It should only scale, T_Angle does not change. rotationMatrix value stays the same with each loop, I dont see why the object is turning. When I change T_Angle to 360 it does not rotate if T_Angle is 90 it iterates by 90

if (newState.IsKeyDown(Keys.Right))
                        {
// setscale can be commented out, the object still rotates
                     MyTriggers[MyTriggers.Count - 1].SetScale += 2.0f;
                            MyTriggers[MyTriggers.Count - 1].SetTriggerMatrix();
                        }

public void SetTriggerMatrix()
        {
            List<Vector3> TmpList = new List<Vector3>();
             

            TmpList = TList; // TList always stays the same

            // make an angle in degrees
            float angle = MathHelper.ToRadians(T_Angle);
//***************************************************************************
//************************Problem Area**************************************

            // make a rotation matrix
            Matrix rotationMatrix = Matrix.CreateRotationZ(angle);
            
            // Transform your line
            for (int i = 0; i < TmpList.Count; i++)
                TmpList = Vector3.Transform(TmpList, rotationMatrix);
//***************************************************************************
//***************************************************************************
       






//this code below is not important, it just finishes off the above function // I was getting xml erros is the reason for posting this outside of the code. // scale first then add location TListVec2.Clear(); for (int i = 0; i < TmpList.Count; i++) { TListVec2.Add(new Vector2(TmpList.X * Scale + TriggerLocation.X, TmpList.Y * Scale + TriggerLocation.Y)); } } [Edited by - pascalosti on November 4, 2007 9:57:43 PM]

Share this post


Link to post
Share on other sites
Advertisement
Every time through the loop, you re-apply the matrix transformation. The matrix transformation rotates the vectors. What's surprising? Also, why would you want that to happen? If the user holds the key, he will expect to keep turning.

Share this post


Link to post
Share on other sites
How can I apply transformation only once? My thought was that every vector has to be rotated or transformed. then scaled then set to its location.


// these are the vectors im going through, they always stay the same
TList.Add(new Vector3(0, 0, 0));
TList.Add(new Vector3(0, 0.5f, 0));
TList.Add(new Vector3(1, 0, 0));
TList.Add(new Vector3(-1, 0, 0));

// and what my screen looks like (45angle)
Image Hosted by ImageShack.us

Share this post


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

  • Advertisement