about camera Animation

May 9, 2009 at 6:08 AM
Edited May 9, 2009 at 6:44 AM

xen What a good way to achieve this camera Animation?

 

For example, a camera irregular path animation

 

In addition the possibility of key-frame animation camera support?

Coordinator
May 9, 2009 at 6:32 AM

Can you be more specific?

May 9, 2009 at 9:48 AM

Please see :

http://graphicsrunner.blogspot.com/2008/05/camera-animation-part-i.html

 

Coordinator
May 9, 2009 at 11:15 AM

That code is fairly simple, although a wee bit odd if you ask me.
All it's doing is creating a large bunch of 'Camera' objects, where Camera is probably a custom class he has made to store the data for a camera. The 'SetLens()' method is simply setting the Fov, Aspect, etc. While the 'Place()' method is acting as a LookAt() method, with a position / target / up direction (this is my guess).
My guess is he's then using one each frame (which isn't exactly an ideal solution - far better to use a single camera, and store it's data per frame - in a structure or the like).

To get that sort of thing working in xen, simply create a single Camera3D, and set the values each frame (fov, aspect, etc) and it has a LookAt() method which can position it for you.
You will need to interpolate the positions and store them. You could do it like he is - pregenerating them, or you could generate them each frame as you need them, which in my mind is the better solution.

May 12, 2009 at 9:20 AM

I would like to include some new features to Xen, but the total does not know how to combine well with xen. 

StatusUnknown can help me?


 

 public void Load()

        {

            mKeyFrames = new List<Camera3D>();

            mCameraPath = new List<Camera3D>();

            XmlDocument path = new XmlDocument();

            path.Load("path.xml");

            mKeyFrames.Clear();

            XmlElement keyFrames = (XmlElement)path.SelectSingleNode("Path/KeyFrames");

            foreach (XmlNode childNode in keyFrames.ChildNodes)

            {

                Camera3D c = new Camera3D();

                string[] fields = childNode.Attributes["Position"].Value.Split(new char[]{' '});

                c.Position=new Vector3(float.Parse(fields[0]),float.Parse(fields[1]),float.Parse(fields[2]));

                fields = childNode.Attributes["Right"].Value.Split(new char[] { ' ' });

                c.Right = new Vector3(float.Parse(fields[0]),float.Parse(fields[1]),float.Parse(fields[2]));

                fields = childNode.Attributes["Up"].Value.Split(new char[] { ' ' });

c.Up = new Vector3(float.Parse(fields[0]),float.Parse(fields[1]), float.Parse(fields[2]));

                fields = childNode.Attributes["Look"].Value.Split(new char[] { ' ' });

                c.Left = new Vector3(float.Parse(fields[0]),float.Parse(fields[1]), float.Parse(fields[2]));

                mKeyFrames.Add(c);

            }

            mCameraPath.Clear();

            for (int i = 0; i < mKeyFrames.Count - 1; i++)

            {

                for (int j = 0; j < mPathSteps; j++)

                {

                    Vector3 diff = mKeyFrames[i + 1].Position - mKeyFrames[i].Position;

                    diff = Vector3.Multiply(diff, (float)j / (float)(mPathSteps - 1));

                    Vector3 center = mKeyFrames[i].Position + diff;

 

                    diff = mKeyFrames[i + 1].Left - mKeyFrames[i].Left;

                    diff = Vector3.Multiply(diff, (float)j / (float)(mPathSteps - 1));

                    Vector3 look = mKeyFrames[i].Left + diff;

 

                    diff = (mKeyFrames[i + 1].Up - mKeyFrames[i].Up);

                    diff = Vector3.Multiply(diff, (float)j / (float)(mPathSteps - 1));

                    Vector3 up = mKeyFrames[i].Up + diff;

 

                    Vector3 r = Vector3.Cross(up, look);

                    Vector3 u = Vector3.Cross(look, r * -1f);

 

                    Camera3D cam = new Camera3D();

                    cam.Position = center;

                    cam.Left = look;

                    cam.Up = u;

                    cam.LookAt(look, center, u);

                    mCameraPath.Add(cam);

                }

            }

        }

 

        int tt = 0;

        private void RotateCamera(DrawState state)

{

            if (tt < mCameraPath.Count - 1)

            {

                tt++;

            }

            camera.LookAt(mCameraPath[tt].Left, mCameraPath[tt].Position, mCameraPath[tt].Up);

}

 

Coordinator
May 13, 2009 at 4:07 AM
Edited May 13, 2009 at 4:08 AM

I'm sorry I don't understand what your question is. Are you having problems converting the tutorial code?