Points disappear when glScaling....

Hi,

I’m writing a modeling program, in this program I draw points to display fe. selected points.

This works fine on my machine and some others but when I tested it on a PII Linux machine and on a portable with W98 the drawing gets messed-up when zooming.

For this zooming I always use glScale( );

What could be the problem here ?

Is this purely related to the video-drivers or did I forget something ?

Code to draw points :

for (int i=0; i < nrPoints; ++i )
{
if(!data[ ss->directIndex[i] ]->isFlag(a_iFlag))
continue;
}

  glBegin( GL_POINTS );

  glVertex3d( data[ ss-&gt;directIndex[i] ]-&gt;x,
	  data[ ss-&gt;directIndex[i] ]-&gt;y,
	  data[ ss-&gt;directIndex[i] ]-&gt;z  );
  
  glEnd();
  
}

Code to zoom :

glScalef( viewer->zf, viewer->zf, viewer->zf );

Maybe they are disappearing behind your far clip plane.

I’m not using clipping planes at this moment…

Could it be that clipping plane defaults are different on different OpenGL implementations ???

Originally posted by Uther_Pendragon:
[b]I’m not using clipping planes at this moment…

Could it be that clipping plane defaults are different on different OpenGL implementations ???[/b]

Yes, OpenGL defaults a near clipping plane (for integrity purposes) but I’m not sure it enforces the far clipping plane. I imagine that is does, but the point is to control your points so that they inhabit your view frustrum.

You can either change the far clipping plane in your projection functions (e.g. glOrtho, glFrustrum) or reduce the size of your units (i.e. 1unit=1m to 1unit=10m).

Originally posted by Uther_Pendragon:
[b]I’m not using clipping planes at this moment…

Could it be that clipping plane defaults are different on different OpenGL implementations ???[/b]

Not using clipping planes?!? You are saying you don’t use ANYTHING to setup your projection matrix? (gluPerspective, glFrustum, glOrtho, etc.)

If that is the case, I would definitely setup your projection matrix before doing anything else.

Sorry, I meanth no ‘additional’ clipping planes :wink:

I’ve set the clipping planes to :

near = 0.001f;
far = 10000.0f;

… still the same problem…

Originally posted by Uther_Pendragon:
[b]
I’ve set the clipping planes to :

near = 0.001f;
far = 10000.0f;

… still the same problem…[/b]

Are you able to see them without using glScalef() ?

When do you call the glScale function? Do you use anything like gluLookAt, glRotate, or glTranslate? If so, in what order are all these in relation to your glScale?

shot in the dark
perhaps u have lighting enabled, and scaling is causing your normals to go haywire.
note im not to sure if points have normals but its worth a shot

Hi !

First of all : thanx for all your replies !!!

But…problem still not solved :

To answer a few questions :

  • Points ar visible without the scaling

  • Lighting is enabled, my normals are always of lenth 1 and I’m using glEnable(GL_NORMALIZE); to keep them of length one.

This is a part of my render -loop :

// 1.translate the camera to the eye.
glTranslatef( viewer->eyex, viewer->eyey, -viewer->eyez );

  // 2.rotate in a way we can view it

  glRotatef(-viewer-&gt;turAngle, 0.0, 0.0, 1.0);
  glRotatef(viewer-&gt;eleAngle, 1.0, 0.0, 0.0);
  glRotatef(-viewer-&gt;rotAngle, 0.0, 1.0, 0.0);

// Zoom
glScalef( viewer->zf, -viewer->zf, -viewer->zf );

  // Translate to the center of mass
  glTranslatef( -viewer-&gt;cenx, -viewer-&gt;ceny, -viewer-&gt;cenz );

Another IMPORTANT remark is that my mesh itself is ALWAYS visible… only the points I draw to indicate selection disappear !!!

The order looks basically correct. I assume that last translate is to make sure the center of the model is at the origin?

One more question, what values are you using for glScale? For instance, if you use glScale(1,1,1); You shouldn’t see any difference. If you are thinking that glScale(0,0,0) is what you would use for no change in scale, you are not going to get what you think…

Be very careful where you put your glScalef call. That will most certainly screw things up otherwise.

glScale is not a proper means of zooming. If you want a zoom, change your projection matrix to use a tighter fov angle.

Scaling will multiply your points by the values you set. So if you have a point at (1, 1, 1) and you call glScalef(500, 500, 500) before you draw them, then the points will really be at (500, 500, 500). When you used the scale, you probably sent the points off-screen somewhere.

One more thought regarding your remark about the model always showing. When you say your points are disappearing, are you “zooming” the model as well? Are you displaying the model when you try and see the points? Perhaps your points are ending up inside the model if the same matrices aren’t being applied to them for some reason. If you draw just the points, no model, do they show up? (Assuming you aren’t already doing this.)

Korval is right that setting the projection matrix to a tighter fov is probably a better way to zoom. It still might be helpful for you to find out why your method isn’t working, though. (It should, even if it isn’t the best way of doing it.) If nothing else, it’d be gained knowledge for next time…

[This message has been edited by Deiussum (edited 05-11-2001).]

Originally posted by Uther_Pendragon:
[b]
Another IMPORTANT remark is that my mesh itself is ALWAYS visible… only the points I draw to indicate selection disappear !!!

[/b]

The cause for removing points could be that they have the same z coordinate as the polygons vertices z coordinaates. So because of the precision of the z buffer they disappear sometimes. Thibnk about using glPolygonOffset(); to shift all points a little bit towards the viewer.

I’ve encountered a similar problem. I tried to calculate the shadow of a man standing under a street light be scaling all of the objects in the y-direction. I was going to scale them all to 0 in that direction because I didn’t want the shadow to have a thickness. This didn’t work as you couldn’t actually see the shadow.

To solve the problem I had to scale the shadow by 0.01 in the y direction and this worked. Perhaps you should put a lower limit value on the amount that you scale?


Fleejay

Hi guys !

Again thanx for all you replys…

I tested several sollution but still no difference.

This weekend I tested it on a new Linux machine with a Creative G-Force2 card.
On this machine I don’t have this problem.

I suspect the problem on the other Linux and the Sony Vayo are driver related ?!