Question: Start with the C + + driver provided in the assignment archive. This program has one shape using the builtin vertex coloring for that shape.

Start with the C++ driver provided in the assignment archive. This program has one shape using the builtin vertex coloring for that shape.
Change the display to four blocks, the blocks should be colored using the builtin vertex coloring.
Create a single block shape object. This will be shared by several artifacts.
There should be four artifacts, each using the block shape.
Use the world transform for the following
Each artifact should be scaled .75 in the x direction, .25 in the y direction, .5 in the z direction
There should be an artifact centered at each of the points (-.5,-.5,0),(-.5,.5,0),(.5,-.5,0),(.5,.5,0)
In the code the first artifact defined should be at (-.5,-.5,0), the second at (-5,.5,0), the third at (.5,-.5,0), and the fourth at (.5,.5,0)
These blocks should be rotated
The block at (-.5,-.5,0) should be rotated 45\deg around the x axis
The block at (-.5,.5,0) should be rotated 315\deg around the y axis
The block at (.5,-.5,0) should be rotated 90\deg around the z axis
The block at (.5,.5,0) should be rotated 270\deg around the x axis
Sou#include "GLM/gtc/type_ptr.hpp"
#include
#include "learnopengl/shader_4722.h"
#include "cs4722/artifact.h"
#include "cs4722/window.h"
#include "cs4722/buffer_utilities.h"
static std::vector artifact_list;
static Shader *shader;
void init()
{
shader = new Shader("../01-more-shapes/vertex_shader.glsl",
"../01-more-shapes/fragment_shader.glsl");
shader->use();
glEnable(GL_PROGRAM_POINT_SIZE);
glEnable(GL_DEPTH_TEST);
cs4722::Shape* b = new cs4722::Torus(.5,20,50);
auto transformation = new cs4722::TransformationAnimationRotating();
transformation->multiplyScale(.4f,.6f,.4f);
transformation->multiplyTranslation(.5,-.5,0);
auto* artf = new cs4722::Artifact(transformation);
artf->theShape = b;
artifact_list.push_back(artf);
cs4722::initBuffers(shader->ID, artifact_list, "b_position", "b_color");
}
void render()
{
for (auto artf : artifact_list){
auto model_matrix = artf->worldTransformation->getMatrix();
shader->setMat4("u_transform", model_matrix);
glDrawArrays(GL_TRIANGLES, artf->theShape->bufferStart, artf->theShape->bufferSize);
}
}
int main()
{
glfwInit();
cs4722::setOpenglVersion(3,3);
GLFWwindow* window = cs4722::setupWindow("More Shapes", .6,1);
glfwMakeContextCurrent(window);
gladLoadGL(glfwGetProcAddress);
init();
while (!glfwWindowShouldClose(window))
{
glClearBufferfv(GL_COLOR, 0, cs4722::X11::gray50.asFloatArray());
glClear(GL_DEPTH_BUFFER_BIT);
render();
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwDestroyWindow(window);
glfwTerminate();
}rce code given:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!