Need urgent help for camera traversal

Started by
6 comments, last by jenny_wui 11 years, 3 months ago

Hello, I need urgent help. I have extracted medial axis of intestine model. Now I need view the inside of the intestine. I have a number of points which form the path. Now for camera I choose the first point of the path and second point as the center for gluLookAt function. But I cannot see any thing, I only see black background. How can I view the inside of my model. Please help me. I have attached picture of both the model and the traverse path. I have showed the camera and center position. Thanks in advance.

Advertisement

You need to disable culling. It's doing either CCW or CW culling but if you want to see both sides it needs to be disabled.

-Aeramor

CTO at Conjecture, Inc.

Culling is already disabled in my code. Here is a part of my initGL code:

/***************************************************/

void initGL(){

static const GLfloat light_model_ambient[] = {0.3f, 0.3f, 0.3f, 1.0f};

static const GLfloat light0_diffuse[] = {0.9f, 0.9f, 0.9f, 0.9f};

static const GLfloat light0_direction[] = {0.0f, -0.4f, 1.0f, 0.0f};


// Enable depth buffering for hidden surface removal.

glDepthFunc(GL_LEQUAL);

glEnable(GL_DEPTH_TEST);

// Cull back faces.

glCullFace(GL_BACK);

glDisable(GL_CULL_FACE);

// Setup other misc features.

glEnable(GL_LIGHTING);

glEnable(GL_NORMALIZE);

glShadeModel(GL_SMOOTH);

// Setup lighting model.

glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);

glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);

glLightModelfv(GL_LIGHT_MODEL_AMBIENT, light_model_ambient);

glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse);

glLightfv(GL_LIGHT0, GL_POSITION, light0_direction);

glEnable(GL_LIGHT0);

}

/************************************************************/

I don't understand where the problem is. Please help me identify it. Thanks

I made some mistake. I can see something like theattached picture when I correct my coding:

// Cull back faces.

glCullFace(GL_FRONT_AND_BACK);

glDisable(GL_CULL_FACE);

But I would like to see the only things along the direction from camera to center as shown my earliest posting i.e. inside the organ.

Do I need to do some thing with up vector in my gluLookAt function?

Also I have question: my camera is at the begining of the path as shown in the picture of my earliest posting. Why do I see that point when my camera is already set there? Please help me clarify it.

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.

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.[attachment=13221:model3.png]

I think you'll want to keep messing with the frustum a bit. The intestine model is still piercing the near plane. There are basically two parameters that you can play with (assuming you're using gluPerspective or something similar): your fovy and your near plane distance. If your intestines have a radius of r, then you'll want to make sure that:

a * n * tan(fovy) < r

Where n is your near plane value, and a is your aspect ratio. You may also want to give yourself a buffer of 10% or so, just in case. So, either your n or your fovy (or both) need to be smaller. It may help to play with these two parameters until you like what you see. Making the fovy smaller will create a "zoom in" effect that you may or may not like. Making the near plane distance smaller will keep the same view, more or less, but you may eventually run into depth-buffer-precision issues if you make it small enough (if so, it's easy to fix...just bring your far plane closer).

As far as why it is off-center, since you are using a symmetrical frustum, it's likely that your eye and center points are off. If your "center" point were accurate, then we should see the medial axis run right through the center of the screen. Since we don't do that, there may be a problem with the method you are using to calculate points on this axis.

Edit: Although, I'm assuming here that the "center" point isn't being clipped by the near plane. Try making your near plane way smaller to fix your clipping issues, and then see if that solves your centering issues. Also, make sure that your viewport correctly matches the size of your window; if your viewport is too large, it can cause things to look off-center. If you know that your eye/center points are accurate and that your viewport is correct, then the last thing I would try is using a "center" point that is much closer to your "eye" point, albeit still on your median axis curve, so as to create a better approximation of the curve's tangent.

Edit5: Typos (it's late).

Thank you very much for the help.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?

I have managed to get better output varying the fov angle. Thanks for the help.

This topic is closed to new replies.

Advertisement