Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final Project done! #507

Open
wants to merge 49 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
5b4287f
Add files via upload
NaveenMuthusamy94 Sep 12, 2022
c4a15e1
Delete Naveen_CS460_Assignment_01.pdf
NaveenMuthusamy94 Sep 12, 2022
9a755be
Add files via upload
NaveenMuthusamy94 Sep 12, 2022
b79b18f
Add files via upload
NaveenMuthusamy94 Sep 20, 2022
20a8811
Add files via upload
NaveenMuthusamy94 Sep 20, 2022
32843e7
Delete index.html
NaveenMuthusamy94 Sep 20, 2022
a56a05d
Add files via upload
NaveenMuthusamy94 Sep 20, 2022
e56983c
Delete index.html
NaveenMuthusamy94 Sep 20, 2022
ba0ff04
Add files via upload
NaveenMuthusamy94 Sep 20, 2022
04a5db0
Delete index.html
NaveenMuthusamy94 Sep 20, 2022
3cbf44d
Add files via upload
NaveenMuthusamy94 Sep 20, 2022
0c60a9b
Add files via upload
NaveenMuthusamy94 Sep 20, 2022
a909980
Add files via upload
NaveenMuthusamy94 Sep 20, 2022
dc5ef2d
Add files via upload
NaveenMuthusamy94 Sep 27, 2022
827de08
Add files via upload
NaveenMuthusamy94 Sep 27, 2022
037c06e
Add files via upload
NaveenMuthusamy94 Oct 9, 2022
d69c1a3
Add files via upload
NaveenMuthusamy94 Oct 11, 2022
4e5b5ea
Add files via upload
NaveenMuthusamy94 Oct 11, 2022
383c32f
Add files via upload
NaveenMuthusamy94 Oct 11, 2022
f4e7523
Add files via upload
NaveenMuthusamy94 Oct 11, 2022
151f014
Add files via upload
NaveenMuthusamy94 Oct 18, 2022
f66251a
Add files via upload
NaveenMuthusamy94 Oct 18, 2022
36ad63f
Merge branch 'bostongfx:main' into main
NaveenMuthusamy94 Oct 27, 2022
2fe9e32
Add files via upload
NaveenMuthusamy94 Oct 27, 2022
14bc0d3
Add files via upload
NaveenMuthusamy94 Oct 27, 2022
1a93096
Add files via upload
NaveenMuthusamy94 Oct 27, 2022
55abe67
Add files via upload
NaveenMuthusamy94 Oct 27, 2022
c8204d0
Merge branch 'bostongfx:main' into main
NaveenMuthusamy94 Nov 8, 2022
a1e032f
Add files via upload
NaveenMuthusamy94 Nov 8, 2022
03417ba
Add files via upload
NaveenMuthusamy94 Nov 8, 2022
bae5c65
Add files via upload
NaveenMuthusamy94 Nov 8, 2022
57b2dc4
Delete dhoom2.mp3
NaveenMuthusamy94 Nov 8, 2022
cdecd23
Add files via upload
NaveenMuthusamy94 Nov 8, 2022
b175328
Delete face.jfif
NaveenMuthusamy94 Nov 8, 2022
e0a5ff4
Create 08
NaveenMuthusamy94 Nov 22, 2022
ce9f07b
Delete 08
NaveenMuthusamy94 Nov 22, 2022
5374070
Add files via upload
NaveenMuthusamy94 Nov 22, 2022
a037dac
Add files via upload
NaveenMuthusamy94 Nov 22, 2022
95f05d8
Merge branch 'bostongfx:main' into main
NaveenMuthusamy94 Nov 28, 2022
c539326
Add files via upload
NaveenMuthusamy94 Nov 29, 2022
4b8e8fb
Add files via upload
NaveenMuthusamy94 Nov 29, 2022
9bd6ea5
Merge branch 'bostongfx:main' into main
NaveenMuthusamy94 Dec 9, 2022
8a484c8
Add files via upload
NaveenMuthusamy94 Dec 9, 2022
b3b9b96
Add files via upload
NaveenMuthusamy94 Dec 9, 2022
7a660a2
Final Project
Robertkevin96 Dec 22, 2022
f07ceaa
Delete Final Project directory
NaveenMuthusamy94 Dec 22, 2022
03a620c
Final Project
Robertkevin96 Dec 22, 2022
dcfdffa
Final Project
NaveenMuthusamy94 Dec 22, 2022
1146189
Report
NaveenMuthusamy94 Dec 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add files via upload
NaveenMuthusamy94 authored Oct 27, 2022
commit 2fe9e32b9eadda0faf4e51e2330d269606b74645
Binary file modified 06/board.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
223 changes: 136 additions & 87 deletions 06/index.html
Original file line number Diff line number Diff line change
@@ -1,88 +1,137 @@
<html>
<head>
<meta charset="UTF-8" />
<style>
html, body {
background-color:#000;
margin: 0;
padding: 0;
height: 100%;
overflow: hidden !important;

background-image: url(sky.jpg);
background-repeat: no-repeat;
background-size: 100% 100%;
}
</style>

<script src="https://threejs.org/build/three.min.js" type="text/javascript"></script>
<script src="https://threejs.org/examples/js/controls/TrackballControls.js" type="text/javascript"></script>
<script src="https://threejs.org/examples/js/effects/AnaglyphEffect.js" type="text/javascript"></script>


<script>

var scene, camera, renderer, ambientLight, light, controls;
var floor;

window.onload = function() {

scene = new THREE.Scene();

var fov = 60;
var ratio = window.innerWidth / window.innerHeight;
var zNear = 1;
var zFar = 10000;
camera = new THREE.PerspectiveCamera(fov, ratio, zNear, zFar);
camera.position.set( 0, 0, 500);

renderer = new THREE.WebGLRenderer({ alpha: true });
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );

ambientLight = new THREE.AmbientLight();
scene.add( ambientLight );

light = new THREE.DirectionalLight( 0xffffff, 5.0 );
light.position.set( 10, 100, 10 );
scene.add( light );


var floorTexture = new THREE.TextureLoader().load( 'board.jpg' );
var floorGeometry = new THREE.PlaneBufferGeometry( 1000, 1000 );
var floorMaterial = new THREE.MeshBasicMaterial( {
map: floorTexture,
side: THREE.DoubleSide
} );
floor = new THREE.Mesh( floorGeometry, floorMaterial );
floor.position.y = -100;
floor.rotateX(-30);
scene.add( floor );

controls = new THREE.TrackballControls( camera, renderer.domElement );


// ROBOT GOES HERE!



animate();


};

function animate() {

requestAnimationFrame( animate );

// TODO

controls.update();
renderer.render( scene, camera );

};

</script>
</head>
<body></body>
<html>
<head>
<meta charset="UTF-8" />
<style>
html,
body {
background-color: #000;
margin: 0;
padding: 0;
height: 100%;
overflow: hidden !important;

background-image: url(sky.jpg);
background-repeat: no-repeat;
background-size: 100% 100%;
}
</style>

<script
src="https://threejs.org/build/three.min.js"
type="text/javascript"
></script>
<script
src="https://threejs.org/examples/js/controls/TrackballControls.js"
type="text/javascript"
></script>
<script
src="https://threejs.org/examples/js/effects/AnaglyphEffect.js"
type="text/javascript"
></script>
<script
src="https://unpkg.com/[email protected]/build/dat.gui.min.js"
type="text/javascript"
></script>

<script src="robot.js"></script>

<script>
var scene, camera, renderer, ambientLight, light, controls;
var floor, r;

window.onload = function () {
scene = new THREE.Scene();

var fov = 60;
var ratio = window.innerWidth / window.innerHeight;
var zNear = 1;
var zFar = 10000;
camera = new THREE.PerspectiveCamera(fov, ratio, zNear, zFar);
camera.position.set(0, 0, 300);

renderer = new THREE.WebGLRenderer({ alpha: true });
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

ambientLight = new THREE.AmbientLight();
scene.add(ambientLight);

light = new THREE.DirectionalLight(0xffffff, 5.0);
light.position.set(10, 100, 10);
scene.add(light);

var floorTexture = new THREE.TextureLoader().load("board.jpg");
var floorGeometry = new THREE.PlaneBufferGeometry(1000, 1000);
var floorMaterial = new THREE.MeshBasicMaterial({
map: floorTexture,
side: THREE.DoubleSide,
});
floor = new THREE.Mesh(floorGeometry, floorMaterial);
floor.position.y = -100;
floor.rotateX(-30);
scene.add(floor);

controls = new THREE.TrackballControls(camera, renderer.domElement);
// controls = new THREE.TrackballControls(camera, renderer.domElement);

// ROBOT GOES HERE!
r = new Robot(0, -55, 0); // any position works
r.show(scene);

//Anaglyph effect
effect = new THREE.AnaglyphEffect(renderer);
effect.setSize(window.innerWidth, window.innerHeight);

controller = {
anaglyph: false,
"raise left arm": function () {
r.raise_left_arm();
},
"lower left arm": function () {
r.lower_left_arm();
},
kick: function () {
r.kick();
},
dance: function () {
r.dance();
},
};
var gui = new dat.GUI();
var rendering = gui.addFolder("Rendering");
rendering.add(controller, "anaglyph");
rendering.open();

var moving = gui.addFolder("Movement");
moving.add(r.head.position, "x", -1000, 1000);
moving.add(r.head.position, "y", -1000, 1000);
moving.add(r.head.position, "z", -1000, 1000);
moving.add(controller, "raise left arm");
moving.add(controller, "lower left arm");
moving.add(controller, "kick");
moving.add(controller, "dance");
moving.open();

animate();
};

function animate() {
requestAnimationFrame(animate);

// TODO
r.onAnimate();

controls.update();

if (controller.anaglyph) {
renderer.setClearAlpha(1);
effect.render(scene, camera);
} else {
renderer.setClearAlpha(0);
renderer.render(scene, camera);
}
}
</script>
</head>
<body></body>
</html>
215 changes: 215 additions & 0 deletions 06/robot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
class Robot{

constructor (x, y, z) {

// Body

this.head = new THREE.Bone();
this.neck = new THREE.Bone();
this.torso = new THREE.Bone();

this.head.position.set( x, y, z );

this.neck.position.y = -10;
this.torso.position.y = -30;

this.head.add(this.neck);
this.neck.add(this.torso);

// Arms

// Left
this.leftUpperArm = new THREE.Bone();
this.leftLowerArm = new THREE.Bone();
this.leftHand = new THREE.Bone();

this.leftUpperArm.position.y = -5;
this.leftUpperArm.position.x = 5;

this.leftLowerArm.position.y = -15;
this.leftLowerArm.position.x = 5;

this.leftHand.position.y = -5;
this.leftHand.position.x = 5;

this.neck.add(this.leftUpperArm);
this.leftUpperArm.add(this.leftLowerArm);
this.leftLowerArm.add(this.leftHand);

// Right
this.rightUpperArm = new THREE.Bone();
this.rightLowerArm = new THREE.Bone();
this.rightHand = new THREE.Bone();

this.rightUpperArm.position.y = -5;
this.rightUpperArm.position.x = -5;

this.rightLowerArm.position.y = -15;
this.rightLowerArm.position.x = -5;

this.rightHand.position.y = -5;
this.rightHand.position.x = -5;

this.neck.add(this.rightUpperArm);
this.rightUpperArm.add(this.rightLowerArm);
this.rightLowerArm.add(this.rightHand);

// Legs

// Left
this.leftUpperLeg = new THREE.Bone();
this.leftLowerLeg = new THREE.Bone();
this.leftFoot = new THREE.Bone();

this.leftUpperLeg.position.y = -5;
this.leftUpperLeg.position.x = 5;

this.leftLowerLeg.position.y = -15;
this.leftLowerLeg.position.x = 5;

this.leftFoot.position.y = -5;
this.leftFoot.position.x = 5;

this.torso.add(this.leftUpperLeg);
this.leftUpperLeg.add(this.leftLowerLeg);
this.leftLowerLeg.add(this.leftFoot);

// Right
this.rightUpperLeg = new THREE.Bone();
this.rightLowerLeg = new THREE.Bone();
this.rightFoot = new THREE.Bone();

this.rightUpperLeg.position.y = -5;
this.rightUpperLeg.position.x = -5;

this.rightLowerLeg.position.y = -15;
this.rightLowerLeg.position.x = -5;

this.rightFoot.position.y = -5;
this.rightFoot.position.x = -5;

this.torso.add(this.rightUpperLeg);
this.rightUpperLeg.add(this.rightLowerLeg);
this.rightLowerLeg.add(this.rightFoot);

}

show(scene) {
var rGroup = new THREE.Group();
rGroup.add( this.head );
var helper = new THREE.SkeletonHelper( rGroup );
helper.material.linewidth = 3; // make the skeleton thick
scene.add(rGroup);
scene.add(helper);
}

raise_left_arm() {
this.movement = 'raise left arm';
}

lower_left_arm() {
this.movement = 'lower left arm';
}

kick() {
this.movement = 'kick';
}

dance() {

this.movement = 'dance';

}

onAnimate() {

var T, x, y, z, w, quat;

const parts = [this.leftUpperArm, this.rightUpperArm, this.rightUpperLeg,
this.leftUpperLeg, this.head];

var part = null;

if (this.movement == 'raise left arm') {

T = Math.PI;
x = Math.sin(T/2);
y = 0;
z = 0;
w = Math.cos(T/2);
quat = new THREE.Quaternion(x, y, z, w);

this.leftUpperArm.quaternion.slerp(quat, 0.05);

}
else if (this.movement == 'lower left arm') {

quat = new THREE.Quaternion(0, 0, 0, 1);
this.leftUpperArm.quaternion.slerp(quat, 0.05);

}
else if (this.movement == 'kick') {

if (this.rightUpperLeg.quaternion.x >= 0.69) {

this.movement = 'kicked';

}
else {

T = Math.PI/2;
x = Math.sin(T/2);
y = 0;
z = 0;
w = Math.cos(T/2);
quat = new THREE.Quaternion(x, y, z, w);

this.rightUpperLeg.quaternion.slerp(quat, 0.05);

}

}
else if (this.movement == 'kicked') {

quat = new THREE.Quaternion(0, 0, 0, 1);
this.rightUpperLeg.quaternion.slerp(quat, 0.05);

}
else if (this.movement == 'dance') {

var idx = Math.floor(Math.random()*parts.length);

part = parts[idx];

if (part.quaternion.w <= 0.90) {

this.movement = 'danced';

}
else {

T = Math.PI/2;
x = Math.sin(T/2);
y = 0;
z = 0;
w = Math.cos(T/2);
quat = new THREE.Quaternion(x, y, z, w);

part.quaternion.slerp(quat, 0.05);
}

}
else if (this.movement == 'danced') {

quat = new THREE.Quaternion(0, 0, 0, 1);
this.leftUpperArm.quaternion.slerp(quat, 0.05);
this.rightUpperArm.quaternion.slerp(quat, 0.05);
this.rightUpperLeg.quaternion.slerp(quat, 0.05);
this.leftUpperLeg.quaternion.slerp(quat, 0.05);
this.head.quaternion.slerp(quat, 0.05);

}

}

}
Binary file modified 06/sky.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.