Question: Before changes the program displays two artifacts with block shape. You are to make changes related to transformations applied to the artifacts. The first artifact

Before changes the program displays two artifacts with block shape. You are to make changes related to transformations applied to the artifacts.
The first artifact
Scale by .75 in the x direction, .5 in the y direction, and .6 in the z direction
Translate by -.5 in the x direction, -.25 in the y direction, and 0 in the z direction
The center of the animation rotation should be the top of the object
The animation rotation axis should be the x-axis
The rotation rate should be \pi /2
The second artifact
Scale by 1 in the x direction, .1 in the y direction, and .1 in the z direction
Translate by .5 in the x direction, .5 in the y direction, and 0 in the z direction
Set the world transform rotation angle to \pi /4
The center of the animation rotation should be the center of the object
The animation rotation axis should be the y axis
The rotation rate should be \pi /3
The code source is the following:
#include "GLM/gtc/type_ptr.hpp"
#include
#include "learnopengl/shader_4722.h"
#include
#include
#include
#include "cs4722/buffer_utilities.h"
static Shader *shader;
static std::vector artifact_list;
void init(void)
{
shader = new Shader("../problemA/vertex_shader.glsl","../problemA/fragment_shader.glsl");
glUseProgram(shader->ID);
glEnable(GL_DEPTH_TEST);
cs4722::shape* block = new cs4722::block();
auto* artf = new cs4722::artifact_rotating();
artf->the_shape = block;
artifact_list.push_back(artf);
artf = new cs4722::artifact_rotating();
artf->the_shape = block;
artifact_list.push_back(artf);
cs4722::init_buffers(shader->ID, artifact_list, "b_position", "b_color");
}
void render()
{
static auto last_time =0.0;
auto time = glfwGetTime();
auto delta_time = time - last_time;
last_time = time;
for (auto artf : artifact_list){
artf->animate(time, delta_time);
auto model_matrix = artf->animation_transform.matrix()
* artf->world_transform.matrix();
shader->setMat4("u_transform", model_matrix);
glDrawArrays(GL_TRIANGLES, artf->the_shape->buffer_start, artf->the_shape->buffer_size);
}
}
int
main(int argc, char** argv)
{
glfwInit();
cs4722::set_opengl_version(3,3);
GLFWwindow *window = cs4722::setup_window("Problem A",.6,1);
gladLoadGL(glfwGetProcAddress);
init();
while (!glfwWindowShouldClose(window))
{
glClearBufferfv(GL_COLOR, 0, cs4722::x11::gray50.as_float_array());
glClear(GL_DEPTH_BUFFER_BIT);
render();
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwDestroyWindow(window);
glfwTerminate();
}

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 Databases Questions!