PDA

View Full Version : Points disappear when glScaling....



Uther_Pendragon
05-09-2001, 11:10 PM
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->directIndex[i] ]->x,
data[ ss->directIndex[i] ]->y,
data[ ss->directIndex[i] ]->z );

glEnd();

}

Code to zoom :
======================
glScalef( viewer->zf, viewer->zf, viewer->zf );

Deiussum
05-10-2001, 05:43 AM
Maybe they are disappearing behind your far clip plane.

Uther_Pendragon
05-10-2001, 05:54 AM
I'm not using clipping planes at this moment...

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

NeoTuri
05-10-2001, 06:01 AM
Originally posted by Uther_Pendragon:
I'm not using clipping planes at this moment...

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

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

Deiussum
05-10-2001, 06:07 AM
Originally posted by Uther_Pendragon:
I'm not using clipping planes at this moment...

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

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.

Uther_Pendragon
05-10-2001, 06:19 AM
Sorry, I meanth no 'additional' clipping planes ;-)

Uther_Pendragon
05-10-2001, 06:54 AM
I've set the clipping planes to :

near = 0.001f;
far = 10000.0f;

... still the same problem....

NeoTuri
05-10-2001, 09:05 AM
Originally posted by Uther_Pendragon:

I've set the clipping planes to :

near = 0.001f;
far = 10000.0f;

... still the same problem....

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

Deiussum
05-10-2001, 09:49 AM
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?

zed
05-10-2001, 11:35 AM
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

Uther_Pendragon
05-10-2001, 09:48 PM
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->turAngle, 0.0, 0.0, 1.0);
glRotatef(viewer->eleAngle, 1.0, 0.0, 0.0);
glRotatef(-viewer->rotAngle, 0.0, 1.0, 0.0);
// Zoom
glScalef( viewer->zf, -viewer->zf, -viewer->zf );

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


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

Deiussum
05-11-2001, 05:55 AM
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...

NeoTuri
05-11-2001, 10:26 AM
Be very careful where you put your glScalef call. That will most certainly screw things up otherwise.

Korval
05-11-2001, 11:02 AM
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.

Deiussum
05-11-2001, 11:05 AM
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.)

Deiussum
05-11-2001, 11:08 AM
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... http://www.opengl.org/discussion_boards/ubb/smile.gif

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

ScottManDeath
05-12-2001, 07:23 AM
Originally posted by Uther_Pendragon:

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


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.

fleejay
05-13-2001, 12:48 PM
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

Uther_Pendragon
05-13-2001, 10:37 PM
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 ?!