Results 1 to 2 of 2

Thread: Splitting Pyramid Problem

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2012
    Posts
    9

    Splitting Pyramid Problem

    Good for now: oknow.jpg
    Bad. One of the faces reappears down the middle: badlater.jpg

    I've have a pyramid on screen. I'm able to rotate it by 5 degrees on the y-axis, but at certain points one of the faces will appear straight down the middle, and will continue to increase in size until it reaches the original face size, which at that point if you continue to go in the same direction (using the left/right arrow keys) the pyramid will then rotate in the opposite direction. I am incrementing and decrementing the angle with:

    Code :
    if ( key == GLUT_KEY_LEFT )
    	{
    		rStepAngle += 0.10f;
    	}
     
    	else if ( key == GLUT_KEY_RIGHT )
    	{
    		rStepAngle -= 0.10f;
    	}
            ...

    Another question I have is, how do I make each face a solid color. I attempted to do this by:

    Code :
    VertexData data[ 12 ] = {
    		{ { 255,   0,   0, 255 }, { -0.5f, 0.0f,  0.5f } },	// front
    		{ { 255,   0,   0, 255 }, {  0.5f, 0.0f,  0.5f } },
    		{ { 255,   0,   0, 255 }, {  0.0f, 0.5f,  0.0f } },
    		{ {   0, 255,   0, 255 }, {  0.5f, 0.0f,  0.5f } },	// right
    		{ {   0, 255,   0, 255 }, {  0.5f, 0.0f, -0.5f } },
    		{ {   0, 255,   0, 255 }, {  0.0f, 0.5f,  0.0f } },
    		{ {   0,   0, 255, 255 }, {  0.5f, 0.0f, -0.5f } },	// back
    		{ {   0,   0, 255, 255 }, { -0.5f, 0.0f, -0.5f } },
    		{ {   0,   0, 255, 255 }, {  0.0f, 0.5f,  0.0f } },
    		{ { 255, 255,   0, 255 }, { -0.5f, 0.0f, -0.5f } },	// left
    		{ { 255, 255,   0, 255 }, { -0.5f, 0.0f,  0.5f } },
    		{ { 255, 255,   0, 255 }, {  0.0f, 0.5f,  0.0f } }
    	};
     
    glVertexAttribPointer( vColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof( VertexData ), BUFFER_OFFSET( 0 ) );

    Sticking that in the buffer, but the shader does gouraud and it's like the color for the vertices is random.

  2. #2
    Junior Member Newbie
    Join Date
    Dec 2012
    Posts
    9
    I was able to figure out the problem. A beginner mistake: I had not culled the back face.

Similar Threads

  1. Sierpinski pyramid - problem with clearing screen
    By konrad509 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-26-2011, 11:51 AM
  2. Splitting body problem
    By Marika in forum OpenGL: General
    Replies: 2
    Last Post: 05-13-2007, 04:45 PM
  3. Problem rendering a (hehe) rotating pyramid.
    By in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 02-28-2004, 01:28 AM
  4. best way to draw a pyramid
    By tim_ganly in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 02-01-2002, 04:54 AM
  5. pyramid
    By fox in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-18-2000, 02:09 AM

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