Crazy Polygons?

Hi everyone,

I have a project in wich I have to draw many polygons and in wich I have to move around the “world”…

The strange part is that when I “move the camera” the polygons act weird and I don’t know why :o

I’ll upload some images so you can see what I’m talking about…

(The imagens look empty, but they aren’t xD)

Any help would be apreciated!

Thanks in advance,

Makinis.

Why are the polygons acting weird? What behavior do you want?

Do you want when “moving around the world”, that the center (where red and blue lines are crossing) is fixed?

If so, show us some code.

Hurgh

No, not the intersection… The coordinates that I use to draw the polygons are the same in the common points, so supposedly the vertex would match… At least, that’s what I want them to do :stuck_out_tongue:

What code do you want me to show?

Thanks for the reply,

Makinis.

Sorry but i have no clue what you want to archive, sry :slight_smile:

I want to achieve this:

And I do achieve it ^^ The only problem is that when I move my “camera” the vertex of the polygons seem to “move from their original coordinates” in different directions…

could you show me your paint() method?

GLuint CreateMap()
{
	cout << "
Creating Map...
";
	GLuint index = glGenLists(1);
	cout << (int) index;
	glNewList(index, GL_COMPILE_AND_EXECUTE);
		glPushMatrix();
		glClear (GL_COLOR_BUFFER_BIT);
		glColor3f (0.0, 0.0, 1.0);
		int i;

		//Render Polygon Shapefile
		if (minkSumFinal.empty()==0){
			glColor3f(1.0,0.0, 0.0);
			glEnable(GL_BLEND);
			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
			glDepthMask(GL_FALSE);
			glDepthFunc(GL_LEQUAL);
			glHint(GL_POLYGON_SMOOTH, GL_NICEST);
			glEnable(GL_POLYGON_SMOOTH);
			glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
			for( i=0;i<(int)minkSumFinal.size();i++)
			{
				if (i%2)
				glColor3f(1.0,0.0,0.0);
				else glColor3f(0.0,0.0,1.0);
				for(int j=0;j<(int)minkSumFinal[i].vMinkSum.size();j++)
				{
					glBegin(GL_POLYGON);
					for(int k=0;k<(int)minkSumFinal[i].vMinkSum[j].pointList.vPointList.size();k++)
					{
						glVertex3f(minkSumFinal[i].vMinkSum[j].pointList.vPointList[k].dX,0.0,minkSumFinal[i].vMinkSum[j].pointList.vPointList[k].dY);
					}
					glEnd();
					//j++;
				}
			}
		}
		glPopMatrix();
	glEndList();
	cout << "
Map Created...
";
	return index;
}

Anything else you need, just ask :wink:

That´s not your paint method, that´s just a part of it. I need to see what you are doing with your modelview matrix.

Hmmmmm, I think that you want this:

void DrawMap(){
	glCallList(id);
}

void Display(void)
{
	glLoadIdentity();
	Camera.Render();
	glClear(GL_COLOR_BUFFER_BIT);
	glColor3f(0.0,0.0,1.0);
	glShadeModel(GL_FLAT);
	glPushMatrix();
		glTranslatef(-(GLfloat)(sBoundingBox.fMaxX-((sBoundingBox.fMaxX-sBoundingBox.fMinX)/2)),0.0,
			-(GLfloat)(sBoundingBox.fMaxY-((sBoundingBox.fMaxY-sBoundingBox.fMinY)/2)));
		DrawMap();
	glPopMatrix();
	glFlush();  
	glutSwapBuffers();
}

what does Camera.Render()?

wild guess: change the sign to + in glTranslate for the z coordinate. (before the cast)

Camera.Render() sets the eye position and the direction where it is looking…

That glTranslate only moves the “world” (the whole block of polygons) center to the (0,0,0) point… So changing the sign won’t make any difference…

@ Bump - Any help would be apreciated :o