-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnilamp_GLEventListener.java
599 lines (544 loc) · 22.1 KB
/
Anilamp_GLEventListener.java
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
/* I declare that this code is my own work */
/* Author <Junxiang Chen> <jchen115@sheffield.ac.uk> */
/*
the event listener
*/
import com.jogamp.opengl.*;
import gmaths.Mat4;
import gmaths.Mat4Transform;
import gmaths.Vec3;
public class Anilamp_GLEventListener implements GLEventListener {
private Camera camera;
private Model floor, env, testCube1;
private Material light1Material, light2Material, lightBulbMaterial, nullMaterial;
private Light light1, light2;
private MovingLight lightBulb;
private Mat4 lightBulbSelfTranslate;
private Table table;
private TableObject object01, object02, object03;
private Wall wall;
private Lamp lamp;
private Animator animator;
private double startTime = 0;
public boolean LIGHT1_ON = true;
public boolean LIGHT2_ON = true;
public boolean LAMP_ON = true;
/**
* generate current time in the format of second
*
* @return time
*/
private double getStartSecond() {
return System.currentTimeMillis() / 1000.0;
}
/**
* constructor
*
* @param camera the camera from Anilamp class
*/
public Anilamp_GLEventListener(Camera camera) {
this.camera = camera;
this.camera.setPosition(new Vec3(0f, 4f, 30f));
this.camera.setTarget(new Vec3(0f, 2.5f, 0f));
}
@Override
public void init(GLAutoDrawable glAutoDrawable) {
GL3 gl3 = glAutoDrawable.getGL().getGL3();
System.err.println("Chosen glCapabilities: " + glAutoDrawable.getChosenGLCapabilities());
gl3.glClearColor(0.1f, 0.2f, 0.4f, 1.0f);
gl3.glClearDepth(1.0f);
gl3.glEnable(GL.GL_DEPTH_TEST);
gl3.glDepthFunc(GL.GL_LESS);
// gl3.glPolygonMode(GL.GL_FRONT_AND_BACK, GL2.GL_LINE);
gl3.glFrontFace(GL.GL_CCW); // default is 'CCW'
gl3.glEnable(GL.GL_CULL_FACE); // default is 'not enabled'
gl3.glCullFace(GL.GL_BACK); // default is 'back', assuming CCW
initialise(gl3);
}
@Override
public void dispose(GLAutoDrawable glAutoDrawable) {
GL3 gl3 = glAutoDrawable.getGL().getGL3();
Light[] lights = new Light[]{
light1, light2
};
for (Light light : lights) {
light.dispose(gl3);
}
lightBulb.dispose(gl3);
floor.dispose(gl3);
env.dispose(gl3);
SceneGraphObject[] sceneGraphObjects = new SceneGraphObject[]{
table, wall, lamp
};
for (SceneGraphObject sceneGraphObject : sceneGraphObjects) {
sceneGraphObject.dispose(gl3);
}
}
@Override
public void display(GLAutoDrawable glAutoDrawable) {
GL3 gl3 = glAutoDrawable.getGL().getGL3();
render(gl3);
}
@Override
public void reshape(GLAutoDrawable glAutoDrawable, int i, int i1, int i2, int i3) {
GL3 gl3 = glAutoDrawable.getGL().getGL3();
gl3.glViewport(i, i1, i2, i3);
float aspect = (float) i2 / (float) i3;
camera.setPerspectiveMatrix(Mat4Transform.perspective(45, aspect));
}
/**
* initialise objects in the scene,
* call some other classes to build some objects: Table, TableObject, Wall, Lamp, MovingLight
* call Animator class to initialise animation
*
* @param gl3 GL3 variable
*/
private void initialise(GL3 gl3) {
// ***************************************************
int[] textureId0 = TextureLibrary.loadTexture(gl3, "textures/chequerboard.jpg");
nullMaterial = new Material();
nullMaterial.setAmbient(0, 0, 0);
nullMaterial.setDiffuse(0, 0, 0);
nullMaterial.setSpecular(0, 0, 0);
// ***************************************************
/*
* static lights
*/
/*
light1
*/
light1Material = new Material();
light1Material.setAmbient(0.5f, 0.6f, 0.65f);
light1Material.setDiffuse(0.6f, 0.6f, 0.6f);
light1Material.setSpecular(0.6f, 0.6f, 0.6f);
light1 = new Light(gl3);
light1.setPosition(new Vec3(-10f, 10f, 4f));
light1.setCamera(camera);
/*
light2
*/
light2Material = new Material();
light2Material.setAmbient(0.6f, 0.55f, 0.5f);
light2Material.setDiffuse(0.8f, 0.8f, 0.8f);
light2Material.setSpecular(0.9f, 0.9f, 0.9f);
light2 = new Light(gl3);
light2.setCamera(camera);
light2.setPosition(new Vec3(6f, 4f, 8f));
// ***************************************************
/*
* moving light
*/
Vec3 lightBulbLocalPosition = new Vec3(0.5f, -0.5f, 0);
lightBulbSelfTranslate = Mat4Transform.translate(new Vec3(0.25f, -0.5f, 0));
Vec3 lightBulbLocalDirection = new Vec3(-0.1f, -4f, 0f);
lightBulbMaterial = new Material();
lightBulbMaterial.setAmbient(0.5f, 0.5f, 0.5f);
lightBulbMaterial.setDiffuse(0.8f, 0.75f, 0.6f);
lightBulbMaterial.setSpecular(0.8f, 0.75f, 0.6f);
lightBulb = new MovingLight(gl3, lightBulbLocalPosition, lightBulbSelfTranslate, lightBulbLocalDirection);
lightBulb.setWorldPosition();
lightBulb.setWorldDirection();
lightBulb.setCamera(camera);
lightBulb.setConstant(1.0f);
lightBulb.setLinear(0.09f);
lightBulb.setQuadratic(0.032f);
lightBulb.setCutOff(12.5f);
lightBulb.setOuterCutOff(20f);
// ***************************************************
/*
* floor
*/
float floor_Y = -8.328f;
float floor_Z = 8f;
Mesh floorMesh = new Mesh(gl3, TwoTriangles.vertices.clone(), TwoTriangles.indices.clone());
Shader floorShader = new Shader(gl3, "shader/vs_floor.txt", "shader/fs_floor.txt");
Material floorMaterial = new Material(
new Vec3(0.2f, 0.2f, 0.2f),
new Vec3(0.85f, 0.8f, 0.75f),
new Vec3(0.2f, 0.2f, 0.2f), 16.0f
);
int[] textureId_Floor = TextureLibrary.loadTexture(gl3, "textures/floor_resize.jpg");
Mat4 floorModelMatrix = Mat4Transform.scale(60f, 1f, 30f);
floorModelMatrix = Mat4.multiply(Mat4Transform.translate(0, floor_Y, floor_Z), floorModelMatrix);
floor = new Model(
gl3, camera, light1, light2, lightBulb,
floorShader, floorMaterial, floorModelMatrix, floorMesh, textureId_Floor
);
// ***************************************************
/*
* parameters of table
*/
float TABLE_X_POSITION = 0;
float TABLE_Y_POSITION = -0.328f;
float TABLE_Z_POSITION = 0;
/*
parameters of table body
*/
float TABLE_BODY_LENGTH = 20;
float TABLE_BODY_WIDTH = 10;
float TABLE_BODY_HEIGHT = 0.4f;
int[] textureId_TableBody01 = TextureLibrary.loadTexture(gl3, "textures/table_body.jpg");
/*
parameters of table legs
*/
float TABLE_LEG_LENGTH = 0.6f;
float TABLE_LEG_WIDTH = TABLE_LEG_LENGTH;
float TABLE_LEG_HEIGHT = 8;
int[] textureId_TableLeg01 = TextureLibrary.loadTexture(gl3, "textures/table_leg.jpg");
/*
instantiate the Table class, which is a subclass of the abstract class, SceneGraphObject, to build a table
*/
table = new Table(gl3, camera, light1, light2, lightBulb,
TABLE_X_POSITION, TABLE_Y_POSITION, TABLE_Z_POSITION,
TABLE_BODY_LENGTH, TABLE_BODY_WIDTH, TABLE_BODY_HEIGHT,
TABLE_LEG_LENGTH, TABLE_LEG_WIDTH, TABLE_LEG_HEIGHT,
textureId_TableBody01, textureId_TableLeg01
);
table.execute();
// ***************************************************
/*
parameters of 1st objects on the table
*/
float TABLE_OBJ_Y_POS = TABLE_BODY_HEIGHT / 2 + TABLE_Y_POSITION;
float OBJ_1_X_POS = 6;
float OBJ_1_Z_POS = -2.5f;
float OBJ_1_SCALE_X = 2;
float OBJ_1_SCALE_Y = 0.15f;
float OBJ_1_SCALE_Z = 2.87f;
Material material01 = new Material(
new Vec3(0.25f, 0.25f, 0.25f),
new Vec3(0.95f, 0.82f, 0.75f),
new Vec3(0.01f, 0.01f, 0.01f), 16.0f
);
Shader shader01 = new Shader(gl3, "shader/vs_table_obj.txt", "shader/fs_table_obj.txt");
int[] textureId_Obj1_01 = TextureLibrary.loadTexture(
gl3, "textures/Disney Animation Studios will present 'Cycles' , its first virtual reality (VR) short, at ACM SIGGRAPH 2018.jpg"
);
/*
instantiate the TableObject class to build three objects (other than lamp) on the table
*/
object01 = new TableObject(
OBJ_1_SCALE_X, OBJ_1_SCALE_Y, OBJ_1_SCALE_Z, OBJ_1_X_POS, OBJ_1_Z_POS,
TABLE_OBJ_Y_POS + OBJ_1_SCALE_Y / 2,
camera, light1, light2, lightBulb, material01, shader01, textureId_Obj1_01, null
);
object01.generateModel(gl3, "cube");
/*
parameters of 2nd objects on the table
*/
float OBJ_2_X_POS = 8;
float OBJ_2_Z_POS = -4;
float OBJ_2_SCALE_X = 2f;
float OBJ_2_SCALE_Y = 2f;
float OBJ_2_SCALE_Z = 2f;
Material material02 = new Material(
new Vec3(0.15f, 0.15f, 0.15f),
new Vec3(0.8f, 0.8f, 0.8f),
new Vec3(1.0f, 1.0f, 1.0f), 128.0f
);
Shader shader02 = new Shader(gl3, "shader/vs_table_obj.txt", "shader/fs_table_obj.txt");
int[] textureId_Obj2_01 = TextureLibrary.loadTexture(gl3, "textures/flat-world-map-paint-acrylic.jpg");
/*
instantiate the TableObject class to build three objects (other than lamp) on the table
*/
object02 = new TableObject(
OBJ_2_SCALE_X, OBJ_2_SCALE_Y, OBJ_2_SCALE_Z, OBJ_2_X_POS, OBJ_2_Z_POS,
TABLE_OBJ_Y_POS + OBJ_2_SCALE_Y / 2,
camera, light1, light2, lightBulb, material02, shader02, textureId_Obj2_01, null
);
object02.generateModel(gl3, "sphere");
/*
parameters of 3rd objects on the table
*/
float OBJ_3_X_POS = -6;
float OBJ_3_Z_POS = 2;
float OBJ_3_SCALE_X = 1.292f;
float OBJ_3_SCALE_Y = 0.15f;
float OBJ_3_SCALE_Z = 2.66f;
Material material03 = new Material(
new Vec3(0.32f, 0.32f, 0.32f),
new Vec3(0.85f, 0.82f, 0.8f),
new Vec3(10.0f, 10.0f, 10.0f), 4.0f
);
Shader shader03 = new Shader(gl3, "shader/vs_table_obj.txt", "shader/fs_table_obj_spec.txt");
int[] textureId_Obj3_01 = TextureLibrary.loadTexture(gl3, "textures/mobile.jpg");
int[] textureId_Obj3_02 = TextureLibrary.loadTexture(gl3, "textures/mobile_highlight.jpg");
/*
note: the moving texture function is implemented in Model class
*/
/*
instantiate the TableObject class to build three objects (other than lamp) on the table
*/
object03 = new TableObject(
OBJ_3_SCALE_X, OBJ_3_SCALE_Y, OBJ_3_SCALE_Z, OBJ_3_X_POS, OBJ_3_Z_POS,
TABLE_OBJ_Y_POS + OBJ_3_SCALE_Y / 2,
camera, light1, light2, lightBulb, material03, shader03, textureId_Obj3_01, textureId_Obj3_02
);
object03.generateModel(gl3, "cube");
// ***************************************************
/*
* wall
*/
/*
parameters of wall
*/
float WALL_LENGTH = 16;
float WALL_HEIGHT = 0.6f + TABLE_LEG_HEIGHT + TABLE_BODY_HEIGHT;
float WALL_WIDTH = 0.8f;
float WALL_X_POSITION = 0;
float WALL_Y_POSITION = floor_Y + WALL_HEIGHT / 2;
float WALL_Z_POSITION = -(TABLE_BODY_WIDTH / 2 + WALL_WIDTH / 2);
int[] textureId_Wall01 = TextureLibrary.loadTexture(gl3, "textures/wall.jpg");
/*
instantiate Wall class, which is a subclass of the abstract class, SceneGraphObject, to build a table
*/
wall = new Wall(
gl3, camera, light1, light2, lightBulb,
WALL_LENGTH, WALL_HEIGHT, WALL_WIDTH, WALL_X_POSITION, WALL_Y_POSITION, WALL_Z_POSITION,
textureId_Wall01
);
wall.execute();
// ***************************************************
/*
* outside environment
*/
float env_Z = -200f;
Mesh envMesh = new Mesh(gl3, TwoTriangles.vertices.clone(), TwoTriangles.indices.clone());
Shader envShader = new Shader(gl3, "shader/vs_env.txt", "shader/fs_env.txt");
Material envMaterial = new Material(
new Vec3(0.0f, 0.0f, 0.0f),
new Vec3(1.0f, 1.0f, 1.0f),
new Vec3(0.0f, 0.0f, 0.0f), 32.0f
);
Mat4 envModelMatrix = Mat4Transform.scale(300f, 1f, 200f);
envModelMatrix = Mat4.multiply(Mat4Transform.rotateAroundX(90), envModelMatrix);
envModelMatrix = Mat4.multiply(Mat4Transform.translate(0, -5f, env_Z), envModelMatrix);
int[] textureId_Env = TextureLibrary.loadTexture(gl3, "textures/fog_bg.jpg");
int[] textureId_Fog = TextureLibrary.loadTexture(gl3, "textures/fog.jpg");
env = new Model(
gl3, camera, light1, light2, lightBulb,
envShader, envMaterial, envModelMatrix, envMesh, textureId_Env, textureId_Fog
);
// ***************************************************
/*
* lamp
*/
/*
parameters of lamp
*/
float LAMP_POSITION_X = 0;
float LAMP_POSITION_Y = 0;
float LAMP_POSITION_Z = 0;
double lowerPressZInitialDegree = 30;
double upperPressZInitialDegree = -75;
double lowerPressYInitialDegree = 0;
double upperPressYInitialDegree = 0;
double headJointZInitialDegree = 50;
double headJointYInitialDegree = 0;
/*
parameters of lamp base
*/
float LAMP_BASE_LENGTH = 1.25f;
float LAMP_BASE_WIDTH = LAMP_BASE_LENGTH;
float LAMP_BASE_HEIGHT = 0.25f;
int[] textureId_LampBase01 = TextureLibrary.loadTexture(gl3, "textures/lamp_base.jpg");
/*
parameters of lamp joints
*/
float LAMP_JOINT_DIAMETER = 0.6f;
int[] textureId_LampJoint01 = TextureLibrary.loadTexture(gl3, "textures/lamp_joint.jpg");
/*
parameters of lamp arms
*/
float LAMP_ARM_LENGTH = LAMP_JOINT_DIAMETER * 0.5f;
float LAMP_ARM_WIDTH = LAMP_ARM_LENGTH;
float LAMP_ARM_HEIGHT = 3.5f;
int[] textureId_LampArm01 = TextureLibrary.loadTexture(gl3, "textures/arm_metal.jpg");
/*
parameters of lamp head
*/
float LAMP_HEAD_JOINT_DIAMETER = 0.65f;
float LAMP_HEAD_XZ_SCALE = 2.8f;
float LAMP_HEAD_Y_SCALE = 1f;
int[] textureId_LampHeadJoint01 = TextureLibrary.loadTexture(gl3, "textures/lamp_head_joint.jpg");
int[] textureId_LampHead01 = TextureLibrary.loadTexture(gl3, "textures/lamp_head.jpg");
/*
parameters of lamp tail
*/
float LAMP_TAIL_SCALE_X = 0.65f;
float LAMP_TAIL_SCALE_Y = 0.25f;
float LAMP_TAIL_SCALE_Z = 0.25f;
int[] textureId_LampTail01 = TextureLibrary.loadTexture(gl3, "textures/lamp_tail.jpg");
/*
parameters of lamp head decoration
*/
float LAMP_HEAD_BACK_DIAMETER = 1.15f;
float LAMP_HEAD_BACK_Y_SCALE = 0.6f;
float LAMP_HEAD_EAR_X_SCALE = 2.5f;
float LAMP_HEAD_EAR_Y_SCALE = 0.5f;
float LAMP_HEAD_EAR_Z_SCALE = 1;
float LAMP_HEAD_EAR_X_POSITION = 1.5f;
float LAMP_HEAD_EAR_Y_POSITION = 0.35f;
float LAMP_HEAD_EAR_Z_POSITION = 0.8f;
int[] textureId_LampHeadBack01 = TextureLibrary.loadTexture(gl3, "textures/lamp_head_joint.jpg");
int[] textureId_LampHeadEar01 = TextureLibrary.loadTexture(gl3, "textures/lamp_head_ear.jpg");
/*
instantiate Lamp class, which is a subclass of the abstract class, SceneGraphObject, to build a table
*/
lamp = new Lamp(
gl3, camera, light1, light2, lightBulb,
LAMP_POSITION_X, LAMP_POSITION_Y, LAMP_POSITION_Z,
LAMP_ARM_HEIGHT
);
lamp.initialise();
lamp.generateLampBase(LAMP_BASE_LENGTH, LAMP_BASE_HEIGHT, LAMP_BASE_WIDTH, textureId_LampBase01);
lamp.generateLampJoints(
LAMP_JOINT_DIAMETER, lowerPressYInitialDegree, lowerPressZInitialDegree,
upperPressYInitialDegree, upperPressZInitialDegree, textureId_LampJoint01
);
lamp.generateArms(LAMP_ARM_LENGTH, LAMP_ARM_WIDTH, textureId_LampArm01);
lamp.generateHead(
LAMP_HEAD_JOINT_DIAMETER, LAMP_HEAD_XZ_SCALE, LAMP_HEAD_Y_SCALE,
headJointYInitialDegree, headJointZInitialDegree, textureId_LampHeadJoint01, textureId_LampHead01
);
lamp.generateTail(LAMP_TAIL_SCALE_X, LAMP_TAIL_SCALE_Y, LAMP_TAIL_SCALE_Z, textureId_LampTail01);
lamp.generateDecoration(
LAMP_HEAD_BACK_DIAMETER, LAMP_HEAD_BACK_Y_SCALE,
LAMP_HEAD_EAR_X_SCALE, LAMP_HEAD_EAR_Y_SCALE, LAMP_HEAD_EAR_Z_SCALE,
LAMP_HEAD_EAR_X_POSITION, LAMP_HEAD_EAR_Y_POSITION, LAMP_HEAD_EAR_Z_POSITION,
textureId_LampHeadBack01, textureId_LampHeadEar01
);
lamp.buildTree();
lamp.update();
// ***************************************************
/*
* test/reference cube
*/
Mesh testCubeMesh = new Mesh(gl3, Cube.vertices.clone(), Cube.indices.clone());
Mat4 testCube1ModelMatrix = Mat4Transform.translate(-TABLE_BODY_LENGTH / 2, 0, -TABLE_BODY_WIDTH / 2);
testCube1 = new Model(
gl3, camera, light1, light2, lightBulb,
floorShader, floorMaterial, testCube1ModelMatrix, testCubeMesh, textureId0
);
// ***************************************************
/*
animation
*/
animator = new Animator(
TABLE_BODY_LENGTH, TABLE_BODY_WIDTH,
lowerPressZInitialDegree, upperPressZInitialDegree, lowerPressYInitialDegree,
upperPressYInitialDegree, headJointZInitialDegree, headJointYInitialDegree,
LAMP_BASE_LENGTH,
object01.range, object02.range, object03.range
);
}
/**
* control the appearance of the light when they are turned on or off
*/
private void setLightOnOff() {
if (LIGHT1_ON) {
light1.setMaterial(light1Material);
} else {
light1.setMaterial(nullMaterial);
}
if (LIGHT2_ON) {
light2.setMaterial(light2Material);
} else {
light2.setMaterial(nullMaterial);
}
if (LAMP_ON) {
lightBulb.setMaterial(lightBulbMaterial);
} else {
lightBulb.setMaterial(nullMaterial);
}
}
/**
* set the begin state of random pose
*/
public void setRandomPoseBegin() {
animator.ANIMATION_RANDOM_GENERATE = true;
}
/**
* control the reset of lamp pose
*/
public void resetPose() {
animator.resetRandomPose();
}
/**
* set the begin state of jump animation
*/
public void setAnimationBegin() {
resetPose();
animator.ANIMATION_GENERATION = true;
startTime = getStartSecond();
}
/**
* update parameters of lamp and light bulb to ensure they can animate in the scene
*/
private void updateMotion() {
animator.generateRandomTargetAngle();
testCube1.setModelMatrix(animator.currentTranslateMatrix);
animator.updateLowerJointYRotateDegree(startTime);
lamp.lampLowerJointYRotate.setTransform(Mat4Transform.rotateAroundY(
(float) (animator.lowerJointYCurrentRotateDegree))
);
animator.updateJointJumpZRotateDegree();
lamp.lampLowerJointZRotate.setTransform(Mat4Transform.rotateAroundZ(
(float) (animator.lowerJointZCurrentRotateDegree))
);
lamp.lampUpperJointZRotate.setTransform(Mat4Transform.rotateAroundZ(
(float) (animator.upperJointZCurrentRotateDegree))
);
animator.updateJump();
lamp.lampTranslate.setTransform(animator.previousTranslateMatrix);
animator.generateRandomPose();
animator.generateLowerJointRandomMotion();
lamp.lampUpperJointYRotate.setTransform(Mat4Transform.rotateAroundY(
(float) (animator.upperJointYCurrentRotateDegree))
);
lamp.lampHeadJointZRotate.setTransform(Mat4Transform.rotateAroundZ(
(float) (animator.headJointZCurrentRotateDegree))
);
lamp.lampHeadJointYRotate.setTransform(Mat4Transform.rotateAroundY(
(float) (animator.headJointYCurrentRotateDegree))
);
lamp.lampTailYRotate.setTransform(Mat4Transform.rotateAroundY(
10 * (float) Math.sin(20 * getStartSecond()))
);
lamp.lampTailZRotate.setTransform(Mat4Transform.rotateAroundZ(
5 * (float) Math.sin(20 * getStartSecond()))
);
lightBulb.setWorldMatrix(Mat4.multiply(lamp.lampHeadName.worldTransform, lightBulbSelfTranslate));
// System.out.println("light bulb world position" + lightBulb.getWorldPosition());
// System.out.println("light bulb world direction" + lightBulb.getWorldDirection());
lamp.update();
}
/**
* render the scene, which will execute 60 times a second
*
* @param gl3 GL3 type parameter
*/
private void render(GL3 gl3) {
gl3.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
setLightOnOff();
if (LIGHT1_ON) {
light1.render(gl3);
}
if (LIGHT2_ON) {
light2.render(gl3);
}
floor.render(gl3);
table.draw(gl3);
object01.render(gl3);
object02.render(gl3);
object03.render(gl3);
wall.draw(gl3);
env.render(gl3);
updateMotion();
lamp.draw(gl3);
if (LAMP_ON) {
lightBulb.render(gl3);
}
// testCube1.render(gl3);
}
}