PDA

View Full Version : Crazy Polygons?



Makinis
06-25-2009, 02:28 AM
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...

http://img261.imageshack.us/img261/7329/forum1t.th.jpg (http://img261.imageshack.us/i/forum1t.jpg/)

http://img55.imageshack.us/img55/7827/forum2w.th.jpg (http://img55.imageshack.us/i/forum2w.jpg/)

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

Any help would be apreciated!

Thanks in advance,

Makinis.

Hurgh
06-25-2009, 02:45 AM
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

Makinis
06-25-2009, 02:54 AM
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 :P

What code do you want me to show?

Thanks for the reply,

Makinis.

Hurgh
06-25-2009, 03:10 AM
Sorry but i have no clue what you want to archive, sry :)

Makinis
06-25-2009, 03:29 AM
I want to achieve this:

http://img530.imageshack.us/img530/3000/forum3s.th.jpg (http://img530.imageshack.us/i/forum3s.jpg/)

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

Hurgh
06-25-2009, 03:55 AM
could you show me your paint() method?

Makinis
06-25-2009, 04:09 AM
GLuint CreateMap()
{
cout << "\nCreating Map...\n";
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 << "\nMap Created...\n";
return index;
}


Anything else you need, just ask ;)

Hurgh
06-25-2009, 04:21 AM
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.

Makinis
06-25-2009, 04:25 AM
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();
}

Hurgh
06-25-2009, 04:50 AM
what does Camera.Render()?

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

Makinis
06-25-2009, 06:36 AM
what does Camera.Render()?
Camera.Render() sets the eye position and the direction where it is looking...


wild guess: change the sign to + in glTranslate for the z coordinate. (before the cast)
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...

Makinis
06-26-2009, 01:51 AM
@ Bump - Any help would be apreciated :o