Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Crazy Polygons?

  1. #1
    Member Newbie
    Join Date
    May 2009
    Location
    Portugal
    Posts
    45

    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

    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.
    "If you can't be a good example, you'll have to serve as a good warning..."

  2. #2
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    14

    Re: Crazy Polygons?

    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

  3. #3
    Member Newbie
    Join Date
    May 2009
    Location
    Portugal
    Posts
    45

    Re: Crazy Polygons?

    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.
    "If you can't be a good example, you'll have to serve as a good warning..."

  4. #4
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    14

    Re: Crazy Polygons?

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

  5. #5
    Member Newbie
    Join Date
    May 2009
    Location
    Portugal
    Posts
    45

    Re: Crazy Polygons?

    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...
    "If you can't be a good example, you'll have to serve as a good warning..."

  6. #6
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    14

    Re: Crazy Polygons?

    could you show me your paint() method?

  7. #7
    Member Newbie
    Join Date
    May 2009
    Location
    Portugal
    Posts
    45

    Re: Crazy Polygons?

    Code :
    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
    "If you can't be a good example, you'll have to serve as a good warning..."

  8. #8
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    14

    Re: Crazy Polygons?

    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.

  9. #9
    Member Newbie
    Join Date
    May 2009
    Location
    Portugal
    Posts
    45

    Re: Crazy Polygons?

    Hmmmmm, I think that you want this:

    Code :
    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();
    }
    "If you can't be a good example, you'll have to serve as a good warning..."

  10. #10
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    14

    Re: Crazy Polygons?

    what does Camera.Render()?

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

Page 1 of 2 12 LastLast

Similar Threads

  1. NDC goes crazy
    By PadMad in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-26-2016, 03:23 PM
  2. Crazy 3d texture!!
    By Tomy in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 03-29-2005, 06:04 AM
  3. To display of concave polygons, polygons containing holes
    By deepa in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-13-2004, 09:22 PM
  4. CraZy OpenGL!!!!
    By rafael990 in forum OpenGL: User Software
    Replies: 1
    Last Post: 03-21-2004, 03:08 AM
  5. Glsetup.com down! help! going crazy.
    By Jlong in forum OpenGL: User Software
    Replies: 4
    Last Post: 01-25-2004, 12:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean