# Thread: Need help for animation

1. ## Need help for animation

I have somehow managed to find out the medial axis path of my tubular intestine model. Now I want to create animation so that the camera moves from the start of the medial path to the end of it. The path is a set of points. Could somebody give me some guideline about constantly moving from one medial axis point to another to create animation? Thanks.

2. A one second Google search immediately brought me to this exhaustive paper. You may also check out various books on computer animation, my reference being Computer Animation by Rick Parent. Also, for an essential tool regarding this topic, i.e. arc-length parameterization, you may check this paper out. Knowing arc lengths of motion curve segments helps you keep the camera speed constant while moving along a curve with differently spaced control points.

3. Thanks for the paper which is quite exhausetive. I think my work is much simpler as I already have the points along which the camera will traverse. I would like to proceed step by step. I place the camera at the beginning of the tube i.e. beginning point. I think I just need to place the camera from previous to the next point. Do I need to consider anything more?As I have never worked on camera manipulation, I need some more input to work on it. I think I only need to deal with gluLookAt function and camera position i.e. cameraX, cameraY, cameraZ. In the following equation,

gluLookAt( cameraX, cameraY, cameraZ, centerX, centerY, centerZ, upX, upY, upZ);

Do I need to consider other gluLookAt parameters?

Please help me clarify it.

4. gluLooatAt will work find but you have to conside how smoothly you want to move the camera (ie how far you move the camera along your path in a second) and what you do when you reach a corner.

As you a approach a corner you have 3 options -

you center can remain along the vector you are currently travelling and you jerk around the corner as you swap vectors when the camera reaches the cornder - this is the easiest to do

you stop the camera at the corner and smoothly rotate the center around the corner vertex to the new align along the new vector before continusing along the new vector

you have your center go around the corner onto the new vector before the camera has arrived at the corner - this may look better but you have to consider how far ahead of the camera the center is so you don't try to look through the wall of the intestine.

5. Suppose I have first two points in my path: v1 and v2. I set camera at v1 and center at v2. Next point is v3. I put camera at v2 and center at v3. Now do I need to check everytime the alignment between vector v1v2 and v2v3 before moving the camera? Please clarify a bit.

6. What you are describing is not a true animation you need to move the camera along the path; the path is not discret points but a continuous function. If your camera has a velocity of v then your camera will travel d = vt in time t. If you camera is at point p on the path your camera need to be placed at the point d units along the path from p. Note this new position need not be exactly at a vertex defining the path (in fact it almost certainly won't be). To understand how to do this you need some basic understanding of vectors. What background do you have on vector maths?

7. Actually I don't understand how to proceed. I have attached the picture of my model and the path which consists of a number of points. Now I have shown camera position and the center and I have put those values in gluLookAt function. But I can't view any thing. This is my starting point. I know about vectors. What I am trying now is to press a key and the camera will move along different points on the path, my center point will be new camera point and next vertex point will be new center. But I can't make it work. I need help. I may have some basic problem in understanding. After I finish this basic step by step key pressing movement, I shall implement the animation. I think any example code may be helpful to understand.

8. Can you post the code where you setup the first gluLookAt and the render of a frame.

9. I don't understand why I can't see anything for the following position of camera.Here is some part of the code:

voidglutReshape(int width, intheight)
{
staticconstdouble kPI =3.1415926535897932384626433832795;
staticconstdouble kFovY =40;

doublenearDist, farDist, aspect;

glViewport(0, 0, width, height);

// Compute theviewing parameters based on a fixed fov and viewing
// a canonicalbox centered at the origin.

nearDist = 2.0 / tan((kFovY / 2.0) * kPI /180.0);
farDist = nearDist + 50.0;
aspect = (double)width / height;

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(kFovY, aspect, nearDist,farDist);

// first point of the path

camera[0] = (*path)[0].vert[0];
camera[1] = (*path)[0].vert[1];
camera[2] = (*path)[0].vert[2];

// second point of the path

center[0] = (*path)[1].vert[0];
center[1] = (*path)[1].vert[1];
center[2] = (*path)[1].vert[2];

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

updateCamera();
}

voidupdateCamera()
{

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(camera[0], camera[1],camera[2], center[0], center[1],

center[2], 0, 1, 0);

glTranslatef(gCameraTranslationX,gCameraTranslatio nY, 0);
glMultMatrixd(gCameraRotation);
glScaled(gCameraScale, gCameraScale,gCameraScale);
glutPostRedisplay();
}

10. I had someproblem in my previous code with culling. After fixing it I can view some thing like this:

But output is not correct as I am not able to find correct view from camera to center. Do I need to do any thing with the up vector. I have another question, why the point where camera is set is shown in the output? It is not supposed to be visible from my understanding. Please help me clarify the thing. Thanks.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•