CS 419v/519v -- Winter Quarter 2023

Project #5

100 Points

Due: February 28

Push Constants for Robot Animation


This page was last updated: December 31, 2022



Project Description

Keyboard Keys

'l' (ell)Toggle lighting on and off
Esc, 'q'Exit the program

Feel free to add more keyboard inputs if you want.

Robot Arm Transformations

The theory behind the derivation of these equations can be found here.

[M1/G] = [T1/G] * [RΘ1]  
[M2/G] = [T1/G] * [RΘ1] * [T2/1] * [RΘ2] = [M1/G] * [M2/1]
[M3/G] = [T1/G] * [RΘ1] * [T2/1] * [RΘ2] * [T3/2] * [RΘ3] = [M1/G] * [M2/1] * [M3/2]

Example Code

**************************************************************

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( 1. );
Arm1.armColor  = ?????
Arm1.armScale  = ?????

Arm2.armMatrix = glm::mat4( 1. );
Arm2.armColor  = ?????
Arm2.armScale  = ?????

Arm3.armMatrix = glm::mat4( 1. );
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 );



// provide the information for Arm2:
vkCmdPushConstants( CommandBuffers[nextImageIndex], GraphicsPipelineLayout, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0,
			sizeof(struct arm), &Arm2 );

// draw the cube, which will become Arm2:
vkCmdDraw( CommandBuffers[nextImageIndex], vertexCount, instanceCount, firstVertex, firstInstance );



// provide the information for Arm3:
vkCmdPushConstants( CommandBuffers[nextImageIndex], GraphicsPipelineLayout, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0,
			sizeof(struct arm), &Arm3 );

// draw the cube, which will become Arm3:
vkCmdDraw( CommandBuffers[nextImageIndex], vertexCount, instanceCount, firstVertex, firstInstance );


**************************************************************

Turn-in:

Use the Teach to turn in your:

  1. A one-page PDF with a title, your name, your email address, nice screen shots from your program, and the link to the Kaltura video demonstrating that your project does what the requirements ask for. If you can, I'd like you to narrate your video so that you can tell me what you did.

Grading:

FeaturePoints
Correct animation of Θ110
Correct animation of Θ210
Correct animation of Θ310
Correct Arm #1 X size10
Correct Arm #2 X size10
Correct Arm #3 X size10
Correct Arm #1 color10
Correct Arm #2 color10
Correct Arm #3 color10
Didn't screw anything up in the process10
Potential Total100