This page was last updated: March 14, 2018
glm::mat4 m = glm::mat4( ); // [I] m = glm::translate( m, glm::vec3(tx, ty, tz) ); // [T] m = glm::rotate( m, radians, glm::vec3(ax, ay, az) ); // [T] * [R]
The theory behind the derivation of these equations can be found here.
[M_{1/G}] | = [T_{1/G}] * [R_{Θ1}] | |
[M_{2/G}] | = [T_{1/G}] * [R_{Θ1}] * [T_{2/1}] * [R_{Θ2}] | = [M_{1/G}] * [M_{2/1}] |
[M_{3/G}] | = [T_{1/G}] * [R_{Θ1}] * [T_{2/1}] * [R_{Θ2}] * [T_{3/2}] * [R_{Θ3}] | = [M_{1/G}] * [M_{2/1}] * [M_{3/2}] |
************************************************************** layout( push_constant ) uniform arm { mat4 armMatrix; vec3 armColor; float armScale; // scale factor in x } RobotArm ************************************************************** vec3 bVertex = aVertex; // do to bVertex just what the cube needs to become a robot arm: bVertex.x += 1.; bVertex.x *= RobotArm.armScale; bVertex = vec3( RobotArm.armMatrix * vec4( bVertex, 1. ) ); // now do to bVertex what the cube needed before when it was just a cube (lighting, transformation): ??? ************************************************************** ************************************************************** struct arm { glm::mat4 armMatrix; glm::vec3 armColor; float armScale; // scale factor in x }; ************************************************************** struct arm Arm1, Arm2, Arm3; ************************************************************** Arm1.armMatrix = glm::mat4( ); Arm1.armColor = ????? Arm1.armScale = ????? Arm2.armMatrix = glm::mat4( ); Arm2.armColor = ????? Arm2.armScale = ????? Arm3.armMatrix = glm::mat4( ); Arm3.armColor = ????? Arm3.armScale = ????? ************************************************************** VkPushConstantRange vpcr[1]; vpcr[0].stageFlags = VK_PIPELINE_STAGE_VERTEX_SHADER_BIT; vpcr[0].offset = 0; vpcr[0].size = sizeof( struct arm ); // 80 bytes VkPipelineLayoutCreateInfo vplci; . . . vplci.pushConstantRangeCount = 1; vplci.pPushConstantRanges = vpcr; ************************************************************** vkCmdBeginRenderPass( CommandBuffers[nextImageIndex], IN &vrpbi, IN VK_SUBPASS_CONTENTS_INLINE ); vkCmdBindPipeline( CommandBuffers[nextImageIndex], VK_PIPELINE_BIND_POINT_GRAPHICS, GraphicsPipeline ); vkCmdBindDescriptorSets( CommandBuffers[nextImageIndex], VK_PIPELINE_BIND_POINT_GRAPHICS, GraphicsPipelineLayout, 0, 4, DescriptorSets, 0, (uint32_t *)nullptr ); vkCmdBindVertexBuffers( CommandBuffers[nextImageIndex], 0, 1, buffers, offsets ); // provide the information for Arm1: vkCmdPushConstants( CommandBuffers[nextImageIndex], GraphicsPipelineLayout, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, sizeof(struct arm), &Arm1 ); // draw the cube, which will become Arm1: vkCmdDraw( CommandBuffers[nextImageIndex], vertexCount, instanceCount, firstVertex, firstInstance ); **************************************************************
Use the Teach system to turn in your:
Feature | Points |
---|---|
Correct animation of Θ1 | 10 |
Correct animation of Θ2 | 10 |
Correct animation of Θ3 | 10 |
Correct Arm #1 X size | 10 |
Correct Arm #2 X size | 10 |
Correct Arm #3 X size | 10 |
Correct Arm #1 color | 10 |
Correct Arm #2 color | 10 |
Correct Arm #3 color | 10 |
Didn't screw anything up in the process | 10 |
Potential Total | 100 |