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

Fix #3 #4 #10

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2,350 changes: 1,176 additions & 1,174 deletions Assets/LeapMotionModules/InteractionEngine/Scripts/InteractionManager.cs

Large diffs are not rendered by default.

Binary file added Assets/Materials/Blue.mat
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Materials/Green.mat
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Materials/PlayerColor.mat
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Assets/Materials/Red.mat
Binary file not shown.
Binary file removed Assets/Prefabs/Camera 1.prefab
Binary file not shown.
Binary file removed Assets/Prefabs/Camera 2 1.prefab
Binary file not shown.
Binary file removed Assets/Prefabs/Camera 2.prefab
Binary file not shown.
Binary file removed Assets/Prefabs/Camera.prefab
Binary file not shown.
Binary file removed Assets/Prefabs/CapsuleHand_L.prefab
Binary file not shown.
8 changes: 0 additions & 8 deletions Assets/Prefabs/CapsuleHand_L.prefab.meta

This file was deleted.

Binary file removed Assets/Prefabs/CapsuleHand_R.prefab
Binary file not shown.
8 changes: 0 additions & 8 deletions Assets/Prefabs/CapsuleHand_R.prefab.meta

This file was deleted.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file removed Assets/Prefabs/LeapPrefab.prefab
Binary file not shown.
8 changes: 0 additions & 8 deletions Assets/Prefabs/LeapPrefab.prefab.meta

This file was deleted.

Binary file modified Assets/Prefabs/Player 1.prefab
Binary file not shown.
Binary file removed Assets/Prefabs/Player.prefab
Binary file not shown.
8 changes: 0 additions & 8 deletions Assets/Prefabs/Player.prefab.meta

This file was deleted.

8 changes: 0 additions & 8 deletions Assets/Prefabs/PlayerCam.prefab.meta

This file was deleted.

Binary file removed Assets/Scenes/Game.unity
Binary file not shown.
8 changes: 0 additions & 8 deletions Assets/Scenes/Game.unity.meta

This file was deleted.

Binary file modified Assets/Scenes/Main.unity
Binary file not shown.
Binary file removed Assets/Scenes/Menu.unity
Binary file not shown.
8 changes: 0 additions & 8 deletions Assets/Scenes/Menu.unity.meta

This file was deleted.

51 changes: 51 additions & 0 deletions Assets/Scripts/CubeSpawner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using UnityEngine;
using UnityEngine.Networking;

public class CubeSpawner : NetworkBehaviour {

[SerializeField]
Vector3 spawnPosition;

[SerializeField]
GameObject prefab;

//public override void OnStartServer() {
//NetworkServer.Spawn(Instantiate(prefab, t.position, t.rotation));
//NetworkIdentity.AssignClientAuthority();
//NetworkServer.SpawnWithClientAuthority(Instantiate(prefab, t.position, t.rotation),
// NetworkServer.connections[0].
//}

void Update() {
if (isLocalPlayer && Input.GetKeyDown(KeyCode.Space)) {
CmdSpawn();
}
}

[Command]
public void CmdSpawn() {
GameObject go = (GameObject)Instantiate(prefab, transform.position + transform.forward * .25f, Quaternion.identity);
// NetworkServer.SpawnWithClientAuthority(go, connectionToClient);
NetworkServer.Spawn(go);
}

public void SetAuthority(NetworkIdentity ni) {
CmdSetAuthority(ni);
}

[Command]
void CmdSetAuthority(NetworkIdentity grabID) {
if (grabID.clientAuthorityOwner != null)
grabID.RemoveClientAuthority(grabID.clientAuthorityOwner);
grabID.AssignClientAuthority(connectionToClient);
}

public void RemoveAuthority(NetworkIdentity ni) {
CmdRemoveAuthority(ni);
}

[Command]
void CmdRemoveAuthority(NetworkIdentity grabID) {
grabID.RemoveClientAuthority(grabID.clientAuthorityOwner);
}
}
12 changes: 12 additions & 0 deletions Assets/Scripts/CubeSpawner.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 14 additions & 4 deletions Assets/Scripts/CustomHand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ public override Chirality Handedness {
set { }
}

public Color PlayerColor {
get; set;
}

public override bool SupportsEditorPersistence() {
return true;
}
Expand Down Expand Up @@ -121,7 +125,6 @@ public override void InitHand() {
BuildSpheres();
BuildCylinders();
updateArmVisibility();

_hasGeneratedMeshes = false;
}

Expand Down Expand Up @@ -249,21 +252,28 @@ private void BuildSpheres() {

Transform[] joints = GetComponentsInChildren<Transform>().Where(c => c.name == "Joint").ToArray();
int k = 0;

//PlayerColor = new Color(UnityEngine.Random.Range(0f, 1), UnityEngine.Random.Range(0f, 1), UnityEngine.Random.Range(0f, 1));
//Create spheres for finger joints
List<Finger> fingers = hand_.Fingers;
for (int i = 0; i < fingers.Count; i++) {
Finger finger = fingers[i];
for (int j = 0; j < 4; j++) {
int key = getFingerJointIndex((int)finger.Type, j);
_jointSpheres[key] = joints[k++]; /*createSphere("Joint", SPHERE_RADIUS);*/
_jointSpheres[key].GetComponent<Renderer>().material = _material;
_jointSpheres[key].GetComponent<Renderer>().material.color = PlayerColor;
}
}

mockThumbJointSphere = transform.FindChild("MockJoint");//createSphere("MockJoint", SPHERE_RADIUS);
palmPositionSphere = transform.FindChild("PalmPosition");//createSphere("PalmPosition", PALM_RADIUS);
wristPositionSphere = transform.FindChild("WristPosition");//createSphere("WristPosition", SPHERE_RADIUS);

mockThumbJointSphere.GetComponent<Renderer>().material = _material;
palmPositionSphere.GetComponent<Renderer>().material = _material;
wristPositionSphere.GetComponent<Renderer>().material = _material;
mockThumbJointSphere.GetComponent<Renderer>().material.color = PlayerColor;
palmPositionSphere.GetComponent<Renderer>().material.color = PlayerColor;
wristPositionSphere.GetComponent<Renderer>().material.color = PlayerColor;
//armFrontLeft = createSphere("ArmFrontLeft", SPHERE_RADIUS, true);
//armFrontRight = createSphere("ArmFrontRight", SPHERE_RADIUS, true);
//armBackLeft = createSphere("ArmBackLeft", SPHERE_RADIUS, true);
Expand All @@ -274,7 +284,7 @@ private void BuildCylinders() {

Transform[] fingerJoints = GetComponentsInChildren<Transform>().Where(c => c.name == "Finger Joint").ToArray();
int k = 0;

//Create cylinders between finger joints
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 3; j++) {
Expand Down
14 changes: 11 additions & 3 deletions Assets/Scripts/EnableOnLocalPlayer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
using UnityEngine.Networking;

public class EnableOnLocalPlayer : NetworkBehaviour {
Expand All @@ -9,9 +7,19 @@ public class EnableOnLocalPlayer : NetworkBehaviour {
GameObject leapController;
[SerializeField]
Camera playerCam;
[SerializeField]
GameObject[] rigidHands;
[SerializeField]
LinkHandSpheres[] linkHandSpheres;

public override void OnStartLocalPlayer() {
leapController.SetActive(true);
playerCam.enabled = true;
foreach(var rigidHand in rigidHands) {
rigidHand.SetActive(true);
}
foreach (var link in linkHandSpheres) {
link.enabled = false;
}
}
}
Loading