-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path3d-object-modelling-industrial-automated-robotic-hand.html
298 lines (254 loc) · 10.1 KB
/
3d-object-modelling-industrial-automated-robotic-hand.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
<!-- FCT NOVA | FCT-UNL (Faculty of Sciences and Technology of New University of Lisbon) -->
<!-- Integrated Master (BSc./MSc.) of Computer Engineering -->
<!-- Computer Graphics and Interfaces (2016-2017) -->
<!-- Lab Work 3 - 3D Object Modelling - Industrial Automated Robotic Hand -->
<!-- Daniel Filipe Pimenta - no. 45404 - d.pimenta@campus.fct.unl.pt -->
<!-- Ruben André Barreiro - no. 42648 - r.barreiro@campus.fct.unl.pt -->
<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<head>
<link rel="shortcut icon" type="image/x-icon" href="https://raw.githubusercontent.com/rubenandrebarreiro/rubenandrebarreiro.github.io/master/assets/images/javascript-logo-1.png"/>
<script id="vertex-shader-2" type="x-shader/x-vertex">
const vec4 lightPosition = vec4(0.0, 0.0, 10.0, 1.0); // in WC
attribute vec4 vPosition; // vertex position in modelling coordinates
attribute vec4 vNormal; // vertex normal in modelling coordinates
uniform mat4 mView; // view transformation matrix (for points)
uniform mat4 mViewVectors; // view transformation matrix (for vectors)
uniform mat4 mModelView; // model-view transformation (for points)
uniform mat4 mNormals; // model-view transformation (for vectors/normals)
uniform mat4 mProjection; // projection matrix
varying vec3 fNormal; // normal vector in camera space (to be interpolated)
varying vec3 fLight;
varying vec3 fViewer;
void main(){
// compute position in camera frame
vec3 posC = (mModelView * vPosition).xyz;
// compute normal in camera frame
fNormal = (mNormals * vNormal).xyz;
// compute light vector in camera frame
if(lightPosition.w == 0.0)
fLight = normalize((mViewVectors * lightPosition).xyz);
else
fLight = normalize((mView*lightPosition).xyz - posC);
// Compute the view vector
// fViewer = -fPosition; // Perspective projection
fViewer = vec3(0,0,1); // Parallel projection only
// Compute vertex position in clip coordinates (as usual)
gl_Position = mProjection * mModelView * vPosition;
// make correction for left handed system of clip space
//gl_Position.z = -gl_Position.z;
}
</script>
<script id="fragment-shader-2" type="x-shader/x-fragment">
precision mediump float;
varying vec3 fPosition;
varying vec3 fNormal;
uniform vec3 color;
const float shininess = 60.0;
const vec3 lightAmb = vec3(0.2, 0.2, 0.2);
const vec3 lightDif = vec3(0.5, 0.5, 0.5);
const vec3 lightSpe = vec3(1.0, 1.0, 1.0);
vec3 ambientColor = lightAmb * color;
vec3 diffuseColor = lightDif * color;
vec3 specularColor = lightSpe * vec3(1.0, 1.0, 1.0);
varying vec3 fLight;
varying vec3 fViewer;
void main() {
vec3 L = normalize(fLight);
vec3 V = normalize(fViewer);
vec3 N = normalize(fNormal);
// Compute the halfway vector for Phong-Blinn model
vec3 H = normalize(L+V);
// compute diffuse reflection, don't let the vertex be illuminated from behind...
float diffuseFactor = max( dot(L,N), 0.0 );
vec3 diffuse = diffuseFactor * diffuseColor;
// compute specular reflection
float specularFactor = pow(max(dot(N,H), 0.0), shininess);
vec3 specular = specularFactor * specularColor;
// specular reflection should be 0 if normal is pointing away from light source
if( dot(L,N) < 0.0 ) {
specular = vec3(0.0, 0.0, 0.0);
}
// add all 3 components from the illumination model (ambient, diffuse and specular)
gl_FragColor = vec4(ambientColor + diffuse + specular, 1.0);
}
</script>
<script type="text/javascript" src="common/webgl-utils.js"></script>
<script type="text/javascript" src="common/initShaders.js"></script>
<script type="text/javascript" src="common/MV.js"></script>
<script type="text/javascript" src="common/cube.js"></script>
<script type="text/javascript" src="common/sphere.js"></script>
<script type="text/javascript" src="common/cylinder.js"></script>
<script type="text/javascript" src="3d-object-modelling-industrial-automated-robotic-hand.js"></script>
<style>
body {
color: #000;
font-family:Tahoma;
font-size:13px;
font-weight: bold;
background-color: #000000;
background-image: url("imgs/JPGs/background.jpg");
}
#container {
position: absolute;
border-radius: 5px;
}
#workDescription {
background:#eeeeee;
position: absolute;
left: 960px; top: 8px;
padding:0;
margin:0;
overflow:hidden;
width: 600px;
border-radius: 5px;
text-align: center;
}
#authorsInfo {
background:#eeeeee;
position: absolute;
left: 960px; top: 248px;
padding:0;
margin:0;
overflow:hidden;
width: 600px;
border-radius: 5px;
text-align: center;
}
#instructions {
background:#eeeeee;
position: absolute;
left: 960px; top: 448px;
padding:0;
margin:0;
overflow:hidden;
width: 600px;
border-radius: 5px;
text-align: center;
}
#settings {
background:#eeeeee;
position: absolute;
left: 960px; top: 702px;
padding:0;
margin:0;
overflow:hidden;
width: 600px;
border-radius: 5px;
text-align: center;
}
a {
color: #35b0ab;
}
</style>
</head>
<body id ="mainbody">
<title>3D Object Modelling - Industrial Automated Robotic Hand</title>
<div id="container" style="display: inline-block">
<canvas id="gl-canvas" width="946" height="946" style="border-radius: 5px;"> Oops... your browser doesn't support the HTML5 canvas element"
</canvas>
</div>
<br/>
<br/>
<div id="workDescription">
<h2>
<a href="https://www.fct.unl.pt/en/education/course/integrated-master-computer-science">
Computer Science and Engineering
<br/>
Integrated Master
</a>
</h2>
<h3>
@ <a href="https://www.fct.unl.pt/en"><i>FCT NOVA | FCT/UNL
<br/>
(Faculty of Sciences and Technology of New University of Lisbon)</i></a>
</h3>
<h3>
<a href="http://www.unl.pt/guia/2018/fct/UNLGI_getUC?uc=8150">
Computer Graphics and Interfaces
</a>
<br/>
(2016/2017)
</h3>
<h4>
Lab Work 3
<br/>
(3D Object Modelling - Industrial Automated Robotic Hand)
</h4>
</div>
<div id="authorsInfo">
<h2>
Authors/Contributors
</h2>
<h3>
<u><i>Rúben André Barreiro</i></u>
</h3>
<h4>
no. 42648 (<a href="mailto:r.barreiro@campus.fct.unl.pt">r.barreiro@campus.fct.unl.pt</a>)
</h4>
<h3>
<u><i>Daniel Filipe Pimenta</i></u>
</h3>
<h4>
no. 45404 (<a href="mailto:d.pimenta@campus.fct.unl.pt">d.pimenta@campus.fct.unl.pt</a>)
</h4>
</div>
<div id="instructions">
<h2>
Instructions
</h2>
<font size="2">
- Use <i>'Q'</i> and <i>'W'</i> keys to rotate the <i>Robotic Hand</i>'s arm;
<br/>
- Use <i>'A'</i> and <i>'S'</i> keys to rotate the <i>Robotic Hand</i>'s upper joint;
<br/>
- Use <i>'Z'</i> and <i>'X'</i> keys to rotate the <i>Robotic Hand</i>'s lower joint;
<br/>
- Use <i>'O'</i> and <i>'P'</i> keys to move the <i>Robotic Hand</i>'s claws;
<br/>
- Use <i>'K'</i> and <i>'L'</i> keys to rotate the <i>Robotic Hand</i>;
<br/>
- Use <i>Left Arrow (←)</i> key to move the <i>Robotic Hand</i>'s base to the left;
<br/>
- Use <i>Right Arrow (→)</i> key to move the <i>Robotic Hand</i>'s base to the right;
<br/>
- Use <i>Up Arrow (↑)</i> key to move the <i>Robotic Hand</i>'s base forward;
<br/>
- Use <i>Down Arrow (↓)</i> key to move <i>Robotic Hand</i>'s base backward;
<br/>
- Choose the pretended <i>Angles Factors</i> (<i>Theta</i> and <i>Gamma</i> <i>Angles</i>)
<br/>
for adjust the settings for the <i>Axonometric Projection</i>;
<br/>
<br/>
</font>
</div>
<div id="settings">
<h2>
Settings/Adjustments
</h2>
<u><i>Axonometric Projection</i></u>
<br/>
<br/>
Gamma Angle
<br/>
<input id="gamma" type="range" min="0" max="90" step="1" value="19.4205368891236">
<br/>
Theta Angle
<br/>
<input id="theta" type="range" min="0" max="360" step="1" value="339.731932804673">
<br/>
<hr/>
<u><i>Render Mode</i></u>
<br/>
<br/>
<select id="render">
<option> Filled </option>
<option> Wire Frame </option>
</select>
<br/>
<br/>
</div>
</body>
</html>