PDA

View Full Version : In glScaled() funciton, Z axis does not working



Wei
03-05-2002, 06:34 AM
I am trying to scale my 3d object by using glScaled()function, but only x and y axis work and z axis does not...can anyone tell me why? or is there some other function I should call before calling glScale()...? Thanks alot

nexusone
03-05-2002, 07:27 AM
How are you setting up the view?
It maybe just how you are looking at the scene?
It is hard to say without seeing your code?
Maybe post your view settings and part of the drawing code.

No there is not other function needed to make the z scaling work.


Originally posted by Wei:
I am trying to scale my 3d object by using glScaled()function, but only x and y axis work and z axis does not...can anyone tell me why? or is there some other function I should call before calling glScale()...? Thanks alot



[This message has been edited by nexusone (edited 03-05-2002).]

Wei
03-05-2002, 08:03 AM
Hi, Nex., Thanks for responding...Here is my code:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-XMax, XMax, -YMax, YMax,
-100.0*ZMax,100.0*ZMax);

glViewport(mRectDataScrn.left, mRectDataScrn.top, mRectDataScrn.Width(), mRectDataScrn.Height());

gluLookAt(0.0, 0.0, 15.0,0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
// Setup Model Coordiante System
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glScaled(1.0, 1.0, 0.3);
glRotated(Angle, 1.0, 0.0, 0.0);

// Draw Surface
{glLineWidth(2.0);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glBegin(GL_QUAD_STRIP);
{for (GridXIndex=0; GridXIndex<GridNumX-1; GridXIndex++)
{
for (GridYIndex=0; GridYIndex<GridNumY-1; GridYIndex++)
{
PlotColors(ColorDataValZ*81.0, r, g, b);
glColor3d(r, g, b);
glVertex3d(DataValX1, DataValY, DataValZ);

PlotColors(ColorDataValZ*81.0, r, g, b);
glColor3d(r, g, b);
glVertex3d(DataValX2, DataValY,DataValZ);
}
}
glEnd();

nexusone
03-05-2002, 09:21 AM
I think part of your problem is the glOrtho,
try using gluPerspective. Ortho is used when writing 2D application, since the scene is draw like you are looking down it it. Sort of like if you close one eye and look down a straw, it looks like a circle without depth. In Ortho the whole scene is drawn like that.... So I am thinking it only looks like the Z scale has no effect.



Originally posted by Wei:
Hi, Nex., Thanks for responding...Here is my code:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-XMax, XMax, -YMax, YMax,
-100.0*ZMax,100.0*ZMax);

glViewport(mRectDataScrn.left, mRectDataScrn.top, mRectDataScrn.Width(), mRectDataScrn.Height());

gluLookAt(0.0, 0.0, 15.0,0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
// Setup Model Coordiante System
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glScaled(1.0, 1.0, 0.3);
glRotated(Angle, 1.0, 0.0, 0.0);

// Draw Surface
{glLineWidth(2.0);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glBegin(GL_QUAD_STRIP);
{for (GridXIndex=0; GridXIndex<GridNumX-1; GridXIndex++)
{
for (GridYIndex=0; GridYIndex<GridNumY-1; GridYIndex++)
{
PlotColors(ColorDataValZ*81.0, r, g, b);
glColor3d(r, g, b);
glVertex3d(DataValX1, DataValY, DataValZ);

PlotColors(ColorDataValZ*81.0, r, g, b);
glColor3d(r, g, b);
glVertex3d(DataValX2, DataValY,DataValZ);
}
}
glEnd();

zeckensack
03-05-2002, 09:25 AM
I don't quite understand why you are applying gluLookAt to the projection matrix. Throw that thing away.