jpaoneMines / csci441

CSCI441 Library Helper Functions and Classes
MIT License
5 stars 2 forks source link

Add Half Sphere & Dome to objects #33

Closed jpaoneMines closed 3 months ago

jpaoneMines commented 10 months ago

Half sphere is an open shape.

Dome is a half sphere with a closed disc bottom.

jpaoneMines commented 3 months ago

Half sphere: leverage full sphere but only draw half of it

// full sphere
glDrawArrays( GL_TRIANGLE_FAN, 0, static_cast<GLint>(slices+2) );

    for(GLuint stackNum = 1; stackNum < stacks-1; stackNum++) {
        glDrawArrays( GL_TRIANGLE_STRIP, static_cast<GLint>((slices+2) + (stackNum-1)*((slices+1)*2)), static_cast<GLint>((slices+1)*2) );
    }

    glDrawArrays( GL_TRIANGLE_FAN, static_cast<GLint>((slices+2) + (stacks-2)*(slices+1)*2), static_cast<GLint>(slices+2) );
// half sphere
//glDrawArrays( GL_TRIANGLE_FAN, 0, static_cast<GLint>(slices+2) );

    for(GLuint stackNum = 1; stackNum < (stacks-1)/2; stackNum++) {
        glDrawArrays( GL_TRIANGLE_STRIP, static_cast<GLint>((slices+2) + (stackNum-1)*((slices+1)*2)), static_cast<GLint>((slices+1)*2) );
    }

    glDrawArrays( GL_TRIANGLE_FAN, static_cast<GLint>((slices+2) + (stacks-2)*(slices+1)*2), static_cast<GLint>(slices+2) );
jpaoneMines commented 3 months ago

Flip definitions - half sphere has a cap, dome is open. dome can sit on top of a cylinder and be open all the way through

jpaoneMines commented 3 months ago

Done, ready for commit.

image image
jpaoneMines commented 3 months ago

Commited.