Conflicts:
	Assets/Tests/SphereSR.cs
This commit is contained in:
Sophie 2015-08-13 19:58:52 -04:00
commit 22c60b3af4
26 changed files with 2197 additions and 243 deletions

View File

@ -1,7 +1,7 @@
fileFormatVersion: 2
guid: 0fe2d64981912a545a084438d8089f68
guid: bd865f25edf545140a9ed3797bb1b4cb
folderAsset: yes
timeCreated: 1439307965
timeCreated: 1439489157
licenseType: Free
DefaultImporter:
userData:

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: b1b9631be327682448348726b233cda1
folderAsset: yes
timeCreated: 1439496361
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -0,0 +1,55 @@
fileFormatVersion: 2
guid: 0c813218655d0a1468d7269b69deb9d5
timeCreated: 1439496409
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 8
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: 16
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 8
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -6,7 +6,7 @@ Material:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: laserPic
m_Name: LinkBeam
m_Shader: {fileID: 200, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 5

View File

@ -0,0 +1,109 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &182606
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 433422}
- 33: {fileID: 3303090}
- 23: {fileID: 2322642}
- 114: {fileID: 11432906}
- 54: {fileID: 5423250}
m_Layer: 0
m_Name: NetworkingSphere
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &433422
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 182606}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 5.96046448e-08, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!23 &2322642
MeshRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 182606}
m_Enabled: 0
m_CastShadows: 1
m_ReceiveShadows: 1
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_SubsetIndices:
m_StaticBatchRoot: {fileID: 0}
m_UseLightProbes: 1
m_ReflectionProbeUsage: 1
m_ProbeAnchor: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 1
m_ImportantGI: 0
m_AutoUVMaxDistance: .5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingOrder: 0
--- !u!33 &3303090
MeshFilter:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 182606}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!54 &5423250
Rigidbody:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 182606}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: .800000012
m_UseGravity: 0
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!114 &11432906
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 182606}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0907c1567bad554c8b995de3459e517, type: 3}
m_Name:
m_EditorClassIdentifier:
LinkObj: {fileID: 11495142, guid: fab430cecad80ad4391987a06b550cb7, type: 2}
PersonObj: {fileID: 11406500, guid: d4b0e683ea5ec974987ea1f6741b333c, type: 2}
NumPeople: 100
AvgNumFriends: 10
FriendshipLikeliness: .300000012
SphereRadius: 7
rotationSpeed: .699999988
torqueForce: 1
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 182606}
m_IsPrefabParent: 1

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 136ea38d5deb4c9418beb879167d9b03
timeCreated: 1439489411
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -258,7 +258,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
LinkObj: {fileID: 11495142, guid: fab430cecad80ad4391987a06b550cb7, type: 2}
PersonObj: {fileID: 11406500, guid: 646dd6566f9e1374caa3af8ad37c43d3, type: 2}
PersonObj: {fileID: 11406500, guid: d4b0e683ea5ec974987ea1f6741b333c, type: 2}
NumPeople: 100
AvgNumFriends: 10
FriendshipLikeliness: .300000012
@ -311,7 +311,7 @@ Light:
m_SpotAngle: 30
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Type: 0
m_Resolution: -1
m_Strength: 1
m_Bias: .0500000007

File diff suppressed because it is too large Load Diff

View File

@ -27,6 +27,12 @@ namespace DeathBook.Model
{
List<Person> people = new List<Person>(numPeople);
/* Sphere uniform distribution using the spiral method with the golden angle
* ~2.39996323 rad, the golden angle (the most irrational angle)
* is used here to make sure that the sin and cos functions
* dont end up drawing clusters of points and the spirals are way
* less visible.
*/
float dlong = Mathf.PI * (3 - Mathf.Sqrt(5)); //~2.39996323
float dz = (2f / numPeople) * radius;
@ -73,7 +79,7 @@ namespace DeathBook.Model
missing = avgConnections - p1.numFriends; // TODO Add randomness
if (missing <= 0)
break;
continue;
list.Clear();
@ -93,13 +99,16 @@ namespace DeathBook.Model
float prob = Mathf.Lerp(probability, 1, missing / list.Count);
foreach (DistanceNode node in list)
{
if (node.dist < smallest.dist && Random.value < prob)
if (node.dist < smallest.dist)
smallest = node;
}
//TODO Code/use a heap instead
if (Random.value < prob)
{
friendships.Add(CreateFriendship(p1, smallest.p));
missing--;
}
list.Remove(smallest);
}
}

View File

@ -0,0 +1,114 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using DeathBook.Model;
public class NetworkingSphere : MonoBehaviour
{
public FriendshipLink LinkObj;
public PersonTest PersonObj;
public int NumPeople = 50;
public int AvgNumFriends = 20;
public float FriendshipLikeliness = 0.4f;
public float SphereRadius = 1f;
public float rotationSpeed = 0.7f;
public float torqueForce = 50f;
private bool dragging = false;
private Vector3 delta = new Vector3();
private Rigidbody rb;
private PersonTest[] peopleNodes;
//TODO private Friendship[] friendships;
private GameObject[] nodes;
void Awake()
{
LevelGenerator lGen = new LevelGenerator();
Level lvl = lGen.GenerateLevel(NumPeople, AvgNumFriends, FriendshipLikeliness, SphereRadius);
InstantiateNodes(lvl);
AssignLinks(lvl);
rb = GetComponent<Rigidbody>();
}
void Update()
{
Vector3 screenMousePos = Input.mousePosition;
screenMousePos.z = transform.position.z - Camera.main.transform.position.z;
Vector3 worldMousePos = Camera.main.ScreenToWorldPoint(screenMousePos);
// If the world position of the mouse is greater than the radius of the sphere, we are outside
if (Mathf.Sqrt(worldMousePos.x * worldMousePos.x + worldMousePos.y * worldMousePos.y) > SphereRadius + 1f)
{
transform.Rotate(Vector3.one * Time.deltaTime * rotationSpeed);
}
//when right btn clicked, call the chnge rotation
if (Input.GetMouseButtonDown(1))
{
dragging = true;
}
else if (Input.GetMouseButtonUp(1))
{
dragging = false;
delta = new Vector3();
}
if (dragging)
{
MoveSphere();
}
}
void MoveSphere()
{
float deltaX = Input.GetAxis("Mouse X");
float deltaY = Input.GetAxis("Mouse Y");
if (deltaX == 0 && deltaY == 0)
{
delta = new Vector3();
rb.angularVelocity *= 0.8f;
}
delta += new Vector3(deltaX, deltaY, 0);
//rigidbody.AddTorque();
rb.AddTorque(Vector3.down * delta.x * torqueForce * Time.deltaTime, ForceMode.Impulse);
rb.AddTorque(Vector3.right * delta.y * torqueForce * Time.deltaTime, ForceMode.Impulse);
Debug.Log(delta.x + ", " + delta.y);
}
private void InstantiateNodes(Level lvl)
{
peopleNodes = new PersonTest[lvl.people.Count];
int ctr = 0;
foreach (Person p in lvl.people)
{
PersonTest pInst = Instantiate(PersonObj, p.initialPosition, Quaternion.identity) as PersonTest;
pInst.transform.parent = this.transform;
peopleNodes[ctr++] = pInst;
}
}
private void AssignLinks(Level lvl)
{
foreach (Friendship f in lvl.friendships)
{
FriendshipLink link = Instantiate(LinkObj) as FriendshipLink;
int id1 = f.friend1.id;
int id2 = f.friend2.id;
link.AttachToObjects(peopleNodes[id1].gameObject, peopleNodes[id2].gameObject);
// Temporary stuff, for testing
peopleNodes[id1].AddLink(link);
peopleNodes[id2].AddLink(link);
}
}
}

View File

@ -0,0 +1,13 @@
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class PersonDetailsPanel : MonoBehaviour
{
public Image ProfilePicture;
public Text Name;
public GameObject FriendsPanel;
public Button KillButton;
public Button WatchButton;
public Button XButton;
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 88fb1885d6f8fd6409e3866b7707a12a
timeCreated: 1439492090
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,146 +0,0 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Center : MonoBehaviour
{
//public float fov = Camera.main.fieldOfView;
public Vector3 nextPosition;
public float moveSpeed = 0;
public FriendshipLink Link;
public PersonTest Person;
public int PointsAmount = 50;
public float SphereRadius = 1f;
public float rotationSpeed = 0.7f;
public float torqueForce = 50f;
private bool dragging = false;
private Vector3 delta = new Vector3();
private Rigidbody rb;
private PersonTest[] people;
private GameObject[] nodes;
void Awake()
{
InstantiateNodes();
AssignLinks();
rb = GetComponent<Rigidbody>();
}
void Update()
{
Vector3 screenMousePos = Input.mousePosition;
screenMousePos.z = transform.position.z - Camera.main.transform.position.z;
Vector3 worldMousePos = Camera.main.ScreenToWorldPoint(screenMousePos);
// If the world position of the mouse is greater than the radius of the sphere, we are outside
if (Mathf.Sqrt(worldMousePos.x * worldMousePos.x + worldMousePos.y * worldMousePos.y) > SphereRadius + 1f)
{
transform.Rotate(Vector3.one * Time.deltaTime * rotationSpeed);
}
//when right btn clicked, call the chnge rotation
if (Input.GetMouseButtonDown(1))
{
dragging = true;
}
else if (Input.GetMouseButtonUp(1))
{
dragging = false;
delta = new Vector3();
}
//camera zoom
if (Input.GetAxis("Mouse ScrollWheel") != 0)
{
Debug.Log("Pressed middle click.");
//Camera.main.transform.position.z += (moveSpeed * Time.deltaTime);
//transform.position = Vector3.Lerp(transform.position, nextPosition, Time.deltaTime * moveSpeed);
//Camera.main.fieldOfView += Input.GetAxis("Mouse ScrollWheel") * 10f;
//Camera.main.transform
}
}
void FixedUpdate()
{
if (dragging)
{
MoveSphere();
}
}
void MoveSphere()
{
float deltaX = Input.GetAxis("Mouse X");
float deltaY = Input.GetAxis("Mouse Y");
if (deltaX == 0 && deltaY == 0)
{
delta = new Vector3();
rb.angularVelocity *= 0.8f;
}
delta += new Vector3(deltaX, deltaY, 0);
rb.AddTorque(Vector3.down * delta.x * torqueForce * Time.fixedDeltaTime, ForceMode.Impulse);
rb.AddTorque(Vector3.right * delta.y * torqueForce * Time.fixedDeltaTime, ForceMode.Impulse);
Debug.Log(delta.x + ", " + delta.y);
}
private void InstantiateNodes()
{
/* Sphere uniform distribution using the spiral method with the golden angle
* ~2.39996323 rad, the golden angle (the most irrational angle)
* is used here to make sure that the sin and cos functions
* dont end up drawing clusters of points and the spirals are way
* less visible.
*/
people = new PersonTest[PointsAmount];
float goldenAngle = Mathf.PI * (3 - Mathf.Sqrt(5));
float zDistance = (2f / PointsAmount) * SphereRadius;
float longitude = 0f;
float z = SphereRadius;
for (int i = 0; i < PointsAmount; i++)
{
float r = Mathf.Sqrt(SphereRadius * SphereRadius - z * z);
float x = Mathf.Sin(longitude) * r;
float y = Mathf.Cos(longitude) * r;
PersonTest simon = Instantiate(Person, new Vector3(x, y, z), Quaternion.identity) as PersonTest;
simon.transform.parent = this.transform;
people[i] = simon;
z -= zDistance;
longitude += goldenAngle;
}
}
private void AssignLinks()
{
for (int i = 0; i < people.Length / 4; i++)
{
FriendshipLink link = Instantiate(Link) as FriendshipLink;
int destinationIndex = Random.Range(people.Length / 2, people.Length - 1);
link.AttachToObjects(people[i].gameObject, people[destinationIndex].gameObject);
// Temporary stuff, for testing
people[i].AddLink(link);
people[destinationIndex].AddLink(link);
}
}
}

View File

@ -5,6 +5,8 @@ using System.Collections.Generic;
[RequireComponent(typeof(Collider))]
public class PersonTest : MonoBehaviour
{
public PersonDetailsPanel DetailsPanel;
// Temporary, for test
private List<FriendshipLink> _links;
private bool _highlighted = false;
@ -21,7 +23,6 @@ public class PersonTest : MonoBehaviour
void OnMouseOver()
{
Debug.Log("abc");
if (!_highlighted)
{
_highlighted = true;

View File

@ -1,6 +1,6 @@
fileFormatVersion: 2
guid: 646dd6566f9e1374caa3af8ad37c43d3
timeCreated: 1439361747
guid: d4b0e683ea5ec974987ea1f6741b333c
timeCreated: 1439489111
licenseType: Free
NativeFormatImporter:
userData:

View File

@ -83,12 +83,6 @@ public class SphereSR : MonoBehaviour
private void InstantiateNodes(Level lvl)
{
/* Sphere uniform distribution using the spiral method with the golden angle
* ~2.39996323 rad, the golden angle (the most irrational angle)
* is used here to make sure that the sin and cos functions
* dont end up drawing clusters of points and the spirals are way
* less visible.
*/
peopleNodes = new PersonTest[lvl.people.Count];
int ctr = 0;