Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this is how it looks when i run the code but i want to add three fingers and a thumb to the robot so it

this is how it looks when i run the code but i want to add three fingers and a thumb to the
robot so it will look like this
\(2\)
Show Transcribed Text
and here is the code that you need to modify so it will be just like i want i mean just like the final photo.
"use strict";
var gl;
var shapes ={
wireCube: { points: [], colors: [], start: 0, size: 0, type: 0},
solidCube: { points: [], colors: [], start: 0, size: 0, type: 0},
axes: { points: [], colors: [], start: 0, size: 0, type: 0},
};
var mv = new mat4();
var p = new mat4();
var mvLoc, projLoc;
var shoulder =0,
elbow =0;
var wireframeMode = false; // Variable to toggle wireframe mode
var perspectiveMode = true; // Variable to toggle perspective mode
var red = vec4(1.0,0.0,0.0,1.0);
var green = vec4(0.0,1.0,0.0,1.0);
var blue = vec4(0.0,0.0,1.0,1.0);
var lightred = vec4(1.0,0.5,0.5,1.0);
var lightgreen = vec4(0.5,1.0,0.5,1.0);
var lightblue = vec4(0.5,0.5,1.0,1.0);
var white = vec4(1.0,1.0,1.0,1.0);
shapes.axes.points =[
vec4(2.0,0.0,0.0,1.0),
vec4(-2.0,0.0,0.0,1.0),
vec4(0.0,2.0,0.0,1.0),
vec4(0.0,-2.0,0.0,1.0),
vec4(0.0,0.0,2.0,1.0),
vec4(0.0,0.0,-2.0,1.0),
];
shapes.axes.colors =[green, green, red, red, blue, blue];
var cubeVerts =[
vec4(0.5,0.5,0.5,1),
vec4(0.5,0.5,-0.5,1),
vec4(0.5,-0.5,0.5,1),
vec4(0.5,-0.5,-0.5,1),
vec4(-0.5,0.5,0.5,1),
vec4(-0.5,0.5,-0.5,1),
vec4(-0.5,-0.5,0.5,1),
vec4(-0.5,-0.5,-0.5,1),
];
var wireCubeLookups =[0,4,6,2,0,1,0,2,3,1,5,1,3,7,5,4,5,7,6,4,4,0,1,5,4,6,2,0];
var solidCubeLookups =[
0,4,6,0,6,2,1,0,2,1,2,3,5,1,3,5,3,7,4,5,7,4,7,6,4,0,1,4,1,5,6,7,3,6,3,2,
];
for (var i =0; i < wireCubeLookups.length; i++){
shapes.wireCube.points.push(cubeVerts[wireCubeLookups[i]]);
shapes.wireCube.colors.push(white);
}
var colorNum =0;
var colorList =[lightblue, lightgreen, lightred, blue, red, green];
for (var i =0; i < solidCubeLookups.length; i++){
shapes.solidCube.points.push(cubeVerts[solidCubeLookups[i]]);
shapes.solidCube.colors.push(colorList[colorNum]);
if (i %6==5) colorNum++;
}
var points =[];
var colors =[];
function loadShape(myShape, type){
myShape.start = points.length;
points = points.concat(myShape.points);
colors = colors.concat(myShape.colors);
myShape.size = points.length - myShape.start;
myShape.type = type;
}
window.onload = function init(){
var canvas = document.getElementById("gl-canvas");
gl = canvas.getContext("webgl2");
if (!gl){
canvas.parentNode.innerHTML("Cannot get WebGL2 Rendering Context");
}
gl.viewport(0,0, gl.drawingBufferWidth, gl.drawingBufferHeight);
gl.enable(gl.DEPTH_TEST);
gl.clearColor(0.0,0.0,0.0,1.0);
gl.enable(gl.CULL_FACE);
var program = initShaders(gl, "shader.vert", "shader.frag");
gl.useProgram(program);
loadShape(shapes.wireCube, gl.LINE_STRIP);
loadShape(shapes.solidCube, gl.TRIANGLES);
loadShape(shapes.axes, gl.LINES);
var vertexBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer);
gl.bufferData(gl.ARRAY_BUFFER, flatten(points), gl.STATIC_DRAW);
program.vPosition = gl.getAttribLocation(program, "vPosition");
gl.vertexAttribPointer(program.vPosition, 4, gl.FLOAT, gl.FALSE, 0,0);
gl.enableVertexAttribArray(program.vPosition);
var colorBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, colorBuffer);
gl.bufferData(gl.ARRAY_BUFFER, flatten(colors), gl.STATIC_DRAW);
program.vColor = gl.getAttribLocation(program, "vColor");
gl.vertexAttribPointer(program.vColor, 4, gl.FLOAT, gl.FALSE, 0,0);
gl.enableVertexAttribArray(program.vColor);
projLoc = gl.getUniformLocation(program,"p");
mvLoc = gl.getUniformLocation(program,"mv");
updateProjection(); // Set initial projection matrix
var eye = vec3(0.0,1.0,10.0);
var at = vec3(0.0,0.0,0.0);
var up = vec3(0.0,1.0,0.0);
mv = lookAt(eye, at, up);
requestAnimationFrame(animate);
};
var prevTime =0;
function animate(){
requestAnimationFrame(animate);
var curTime = new Date().getTime();
if (prevTime !=0){
var timePassed =(curTime - prevTime)/1000.0;
handleKeys(timePassed);
}
prevTime = curTime;
render();
}
function render(){

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Murach's SQL Server 2012 For Developers

Authors: Bryan Syverson, Joel Murach, Mike Murach

1st Edition

1890774693, 9781890774691

More Books

Students also viewed these Databases questions

Question

98. For a compound random variable S = N i=1 Xi , find Cov(N, S).

Answered: 1 week ago

Question

Did you cite the sources of the statistics?

Answered: 1 week ago