HanWu

06-24-2008, 09:30 AM

I have a rectangle(width == height) which was located in a very far place from origin. When I perform the zoom extend(a sequence of transformation ) I am able to project the rectangle to the center of the screen but the display of rectangle is awful(the width and the height of the rectangle is different when display in the screen). For example:

void AddRectangle(){

Point3DList temPList = new Point3DList();

temPList.Add(new Point3D(-10, -10, 0));

temPList.Add(new Point3D(10, -10, 0));

temPList.Add(new Point3D(10, 10, 0));

temPList.Add(new Point3D(-10, 10, 0));

sdPolyline poliline = AddPolyline(temPList);

// move the rectangle to very far from the origin.

poliline.Move(new Point3D(-71000000, 12000000, 0));

}

internal virtual void orthographic(int width,int height)

{

if (width <= height)

Gl.glOrtho(-tmpUser.OrthoSize, tmpUser.OrthoSize, -tmpUser.OrthoSize * (float) height / (float) width,

tmpUser.OrthoSize * (float) height / (float) width, -tmpUser.OrthoSize*DEPTH, tmpUser.OrthoSize*DEPTH);

else

Gl.glOrtho(-tmpUser.OrthoSize * (float) width / (float) height,

(tmpUser.OrthoSize)* (float) width / (float) height,-tmpUser.OrthoSize,tmpUser.OrthoSize, -tmpUser.OrthoSize*DEPTH, tmpUser.OrthoSize*DEPTH);

}

void RenderScene(){

orthographic(view.width,view.height);

Gl.glMatrixMode(Gl.GL_MODELVIEW );

Gl.glLoadIdentity();

// The final transformation matrix.

Gl.glMultMatrixd(view.object16form);

}

If you move the rectangle back to the origin then the problem will disappear. Can anyone explain about this fenomena and any solution on this problem? Your help will be appreciated. Thanks.

void AddRectangle(){

Point3DList temPList = new Point3DList();

temPList.Add(new Point3D(-10, -10, 0));

temPList.Add(new Point3D(10, -10, 0));

temPList.Add(new Point3D(10, 10, 0));

temPList.Add(new Point3D(-10, 10, 0));

sdPolyline poliline = AddPolyline(temPList);

// move the rectangle to very far from the origin.

poliline.Move(new Point3D(-71000000, 12000000, 0));

}

internal virtual void orthographic(int width,int height)

{

if (width <= height)

Gl.glOrtho(-tmpUser.OrthoSize, tmpUser.OrthoSize, -tmpUser.OrthoSize * (float) height / (float) width,

tmpUser.OrthoSize * (float) height / (float) width, -tmpUser.OrthoSize*DEPTH, tmpUser.OrthoSize*DEPTH);

else

Gl.glOrtho(-tmpUser.OrthoSize * (float) width / (float) height,

(tmpUser.OrthoSize)* (float) width / (float) height,-tmpUser.OrthoSize,tmpUser.OrthoSize, -tmpUser.OrthoSize*DEPTH, tmpUser.OrthoSize*DEPTH);

}

void RenderScene(){

orthographic(view.width,view.height);

Gl.glMatrixMode(Gl.GL_MODELVIEW );

Gl.glLoadIdentity();

// The final transformation matrix.

Gl.glMultMatrixd(view.object16form);

}

If you move the rectangle back to the origin then the problem will disappear. Can anyone explain about this fenomena and any solution on this problem? Your help will be appreciated. Thanks.