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.

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.

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.

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.

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.

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?

[ATTACH=CONFIG]344[/ATTACH]
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.

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

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)
{
static const double kPI =3.1415926535897932384626433832795;
static const double 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);
  [COLOR=green][/COLOR]
glTranslatef(gCameraTranslationX,gCameraTranslationY, 0);
glMultMatrixd(gCameraRotation); 
glScaled(gCameraScale, gCameraScale,gCameraScale);
glutPostRedisplay();

}

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

[ATTACH=CONFIG]345[/ATTACH]

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.

Why are you doing this?


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

You have already placed your camera in the world with the gluLookAt, now you are moving the world.

Now I am getting some output by setting camera at v0 and center at v2 by adjusting near and far plane in gluPerspective (last time it was too away from camera). I have attached the output. The matrix transformation is unit. So it is actually not making any change in the output. I kept it for mouse based interaction.

[ATTACH=CONFIG]349[/ATTACH]
But the result is not ok, I want to see the image centered, but I am getting it partially. As I keep on moving by pressing a key making the center point as camera and center as the next vertex, the output is worse. sometimes ou of the model. I understand I need to finetune the alignment between v0v1 and v1v2 and so on. Please give me some suggestion. Thank you for cooperation from the beginning.

Your probelms now are probably fine tuning. If is possible that the direct line from the camera vertex to the center vertex is actually cutting through the model. Also you image on the screen will not be square if the window is not square - that is a circle will look like an oval. This can be fixed but I would ignore it for the moment and just make the window square. Try adjusting the FOV in the perspective camera .

I have made the window square. Now when I move, I find the camera in the middle of the screen, by adjusting fovY and near plane. But most of time I could see side, roof or floor of the tunnel as shown in my first picture, very few times, I can see the whole boundary as shown in the second picture. How can that be adjusted?

[ATTACH=CONFIG]350[/ATTACH] [ATTACH=CONFIG]351[/ATTACH]

I have managed to get better output by adjusting the FOV. Thanks for the suggestion.

I need some suggestion about creating animation. i.e. how to process camera with time, and how to modify the path if necessary when the camera traverses a particular distance. Thanks in advance.

Ok to move the camera for an animation you need to know the scale of your model; that is, is 1 unit on mesh equal to 1 cm, or 1 m etc. Once you know that you have to think about how far you want the camera to move in 1 second - say 1cm (might be too slow) or 1m (probably to fast).

Lets say we have a scale of 1 mesh unit = 1 cm. and we want to move the camera 5 cm in a second; then the new camera = old camera + 5 * ||direction||. See my earlier post on how to choose a direction.

Hi,
In previous posting, there were following three options:
1.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

2.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

  1. 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.

I think the third option is the best one. Suppose each secnd I travel 5 unit along the look at vector. Now my new point is:
new_point = camera + lookatvector*5;
This new point is supposed be the next camera point and is most likely not on the path; Then my question is :
how can I choose next camera and center? How can the new vector be found?

I think I can go around the corner by checking the next vector and the angle between two consecutive vectors. But again my new point may not on the line. Then how to keep on proceeding along the path?

Now this way my original path lmay not be maintained. Then what would be the end condition of traversal?

Help me clarify the above issues.

Thw third option is clearly the hardest. You have to choose a distance the center point is ahead of the camera. If you make it too far you will try to look through the sides of your model. You also have to follow that path across a vertex. If you path is simple set of lines this is quite straight forward.
Here is the pseudo code

assume path is V1,V2,V3; camera is at E and center is at C both somewhere along V1-V2

the distance to move of D = time * velocity.

new center is
if D > ( V2-C)
C = ||V3-V2|| * (D - (V2-C))
else
C = ||V2-V1|| * D

new camera is
if D > (V2-E)
E = ||V3-V2|| * (D - (V2-E))
else
E = ||V2-V1|| * D

Note that you should allow for D > (V2-C)+(V3-V2) etc

If you are using a curved path you approximate it with a set of line vectors

Thanks. At first I need to find the whole path length and the traversal time which I need to fix by myself. Then traverse the path at a const. velocity. And for each pair of vertices, I need to check the above algorithm. But I didn’t understand why I need to have D > (V2 - C) + (V3 - V2). Could you clarify a bit.