Results 1 to 3 of 3

Thread: Rotation to form a pyramid

  1. #1
    Junior Member
    Join Date
    Sep 2010
    Posts
    21

    Rotation to form a pyramid

    Hi,

    I have an idea and want to implement it in WebGL. Normally, we have to create many vertex to form a pyramid (at least four triangle and three vertex for each triangle).

    However, I want to use only one triangle to form a pyramid. The method is that I rotate the screen 90 degree after drawing one triangle. Then, I can rotate it again and drawing the second triangle and so on. Therefore, if I change the size of the triangle, I only change one time without extra effort.

    But, I fail to implement it with the following coding:
    Code :
    for (var j = 0; j < n; j++) {
            mvPushMatrix();
            mvRotate(1, [0, 1, 0]);
            setMatrixUniforms();
            gl.drawElements(gl.TRIANGLES, pyramidVertexIndexBuffer.numItems, gl.UNSIGNED_SHORT, 0);
            mvPopMatrix();
        }

    It only show me one triangle. Is there any mistakes I made?

  2. #2
    Junior Member
    Join Date
    Aug 2010
    Posts
    17

    Re: Rotation to form a pyramid

    Yes, you use the same rotation for every triangle.
    Rotation angle should depend on j value.
    Try something like:
    Code :
    var deltaAngle = Math.PI * 2 / n;
    for (var j = 0; j < n; j++) {
            mvPushMatrix();
            mvRotate(j * deltaAngle, [0, 1, 0]);
            setMatrixUniforms();
            gl.drawElements(gl.TRIANGLES, pyramidVertexIndexBuffer.numItems, gl.UNSIGNED_SHORT, 0);
            mvPopMatrix();
        }

    (not tested!)

  3. #3
    Junior Member
    Join Date
    May 2011
    Posts
    1

    Re: Rotation to form a pyramid

    How do you figure out the volume of a segmented pyramid? Let's say there's a pyramid, and you're given the base length (16) and height (10). If we were to cut off the top 4 inches of the pyramid, how can you calculate the volume of just that segment of the pyramid?

Similar Threads

  1. Mipmaps and Image Pyramid
    By yoavhacohen in forum OpenCL
    Replies: 3
    Last Post: 01-26-2011, 05:04 PM
  2. problem with rotation
    By himanshu405 in forum OpenGL ES general technical discussions
    Replies: 4
    Last Post: 07-15-2009, 06:14 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
  •