Vlad Svoka avatar Vlad Svoka committed cbc5a9b

initial commit

Comments (0)

Files changed (23)

Add a comment to this file

Assets/New Terrain.asset

Binary file added.

Add a comment to this file

Assets/RenderTextures/r1.renderTexture

Binary file added.

Add a comment to this file

Assets/RenderTextures/r2.renderTexture

Binary file added.

+using UnityEngine;
+using System.Collections;
+
+public class Seeker : MonoBehaviour {
+	
+	public Camera le;
+	public Camera re;
+	
+	Texture2D l2d;
+	Texture2D r2d;
+	
+	// Use this for initialization
+	void Start () {
+		l2d = new Texture2D(le.targetTexture.width, le.targetTexture.height, TextureFormat.RGB24, false);
+		r2d = new Texture2D(re.targetTexture.width, re.targetTexture.height, TextureFormat.RGB24, false);
+		
+	}
+	
+		
+	// Update is called once per frame
+	void Update () {
+		RendText(le, l2d);
+		RendText(re, r2d);
+		
+		l2d.SetPixels(Filter(l2d.GetPixels(), l2d.width));
+		l2d.Apply();
+		
+	}
+	
+	Color[] Filter(Color[] px, int w)
+	{
+		Color[] ret = new Color[px.Length];
+		for(int i=0; i<px.Length; i++)
+		{
+			float h = .5f;
+			if(i-1>0)
+			{
+				float pi = (px[i].r+px[i].g+px[i].b)/3;
+				float pi1 = (px[i-1].r+px[i-1].g+px[i-1].b)/3;
+				h = (int)( (pi-pi1)*5 +0.5f);
+			}
+			
+			float v = .5f;
+			if(i+w<px.Length)
+			{
+				float vi = (px[i].r+px[i].g+px[i].b)/3;
+				float vi1 = (px[i+w].r+px[i+w].g+px[i+w].b)/3;
+				v = (int)( (vi-vi1)*5 +0.5f);
+			}
+			
+			float r = (int)((h+v)/2+0.5);
+			ret[i] = new Color(r,r,r);
+		}
+		return ret;
+	}
+	
+	void RendText(Camera cm, Texture2D tex)
+	{
+		RenderTexture.active = cm.targetTexture;
+		cm.Render();
+		tex.ReadPixels(new Rect(0,0, tex.width, tex.height), 0,0);
+		tex.Apply();
+		RenderTexture.active = null;
+	}
+
+	
+	void OnGUI()
+	{
+		GUI.Box(new Rect(0,0, l2d.width, l2d.height), l2d);
+		GUI.Box(new Rect(Screen.width - r2d.width, 0, r2d.width, r2d.height), r2d);
+	}
+	
+}

Assets/SimpleController.cs

+using UnityEngine;
+using System.Collections;
+
+public class SimpleController : MonoBehaviour {
+	public float move = 8;
+	public float turn = 4.5f;
+	// Use this for initialization
+	void Start () {
+	
+	}
+	
+	// Update is called once per frame
+	void FixedUpdate () {
+		rigidbody.AddTorque(turn*transform.up*Input.GetAxis("Horizontal"));
+		rigidbody.AddForce(move*transform.forward*Input.GetAxis("Vertical"));
+	}
+}

Assets/Standard Assets/Scripts/Camera Scripts/SmoothFollow.js

+/*
+This camera smoothes out rotation around the y-axis and height.
+Horizontal Distance to the target is always fixed.
+
+There are many different ways to smooth the rotation but doing it this way gives you a lot of control over how the camera behaves.
+
+For every of those smoothed values we calculate the wanted value and the current value.
+Then we smooth it using the Lerp function.
+Then we apply the smoothed values to the transform's position.
+*/
+
+// The target we are following
+var target : Transform;
+// The distance in the x-z plane to the target
+var distance = 10.0;
+// the height we want the camera to be above the target
+var height = 5.0;
+// How much we 
+var heightDamping = 2.0;
+var rotationDamping = 3.0;
+
+// Place the script in the Camera-Control group in the component menu
+@script AddComponentMenu("Camera-Control/Smooth Follow")
+
+
+function LateUpdate () {
+	// Early out if we don't have a target
+	if (!target)
+		return;
+	
+	// Calculate the current rotation angles
+	var wantedRotationAngle = target.eulerAngles.y;
+	var wantedHeight = target.position.y + height;
+		
+	var currentRotationAngle = transform.eulerAngles.y;
+	var currentHeight = transform.position.y;
+	
+	// Damp the rotation around the y-axis
+	currentRotationAngle = Mathf.LerpAngle (currentRotationAngle, wantedRotationAngle, rotationDamping * Time.deltaTime);
+
+	// Damp the height
+	currentHeight = Mathf.Lerp (currentHeight, wantedHeight, heightDamping * Time.deltaTime);
+
+	// Convert the angle into a rotation
+	var currentRotation = Quaternion.Euler (0, currentRotationAngle, 0);
+	
+	// Set the position of the camera on the x-z plane to:
+	// distance meters behind the target
+	transform.position = target.position;
+	transform.position -= currentRotation * Vector3.forward * distance;
+
+	// Set the height of the camera
+	transform.position.y = currentHeight;
+	
+	// Always look at the target
+	transform.LookAt (target);
+}

Assets/Standard Assets/Scripts/General Scripts/DragRigidbody.js

+var spring = 50.0;
+var damper = 5.0;
+var drag = 10.0;
+var angularDrag = 5.0;
+var distance = 0.2;
+var attachToCenterOfMass = false;
+
+private var springJoint : SpringJoint;
+
+function Update ()
+{
+	// Make sure the user pressed the mouse down
+	if (!Input.GetMouseButtonDown (0))
+		return;
+
+	var mainCamera = FindCamera();
+		
+	// We need to actually hit an object
+	var hit : RaycastHit;
+	if (!Physics.Raycast(mainCamera.ScreenPointToRay(Input.mousePosition),  hit, 100))
+		return;
+	// We need to hit a rigidbody that is not kinematic
+	if (!hit.rigidbody || hit.rigidbody.isKinematic)
+		return;
+	
+	if (!springJoint)
+	{
+		var go = new GameObject("Rigidbody dragger");
+		var body : Rigidbody = go.AddComponent ("Rigidbody") as Rigidbody;
+		springJoint = go.AddComponent ("SpringJoint");
+		body.isKinematic = true;
+	}
+	
+	springJoint.transform.position = hit.point;
+	if (attachToCenterOfMass)
+	{
+		var anchor = transform.TransformDirection(hit.rigidbody.centerOfMass) + hit.rigidbody.transform.position;
+		anchor = springJoint.transform.InverseTransformPoint(anchor);
+		springJoint.anchor = anchor;
+	}
+	else
+	{
+		springJoint.anchor = Vector3.zero;
+	}
+	
+	springJoint.spring = spring;
+	springJoint.damper = damper;
+	springJoint.maxDistance = distance;
+	springJoint.connectedBody = hit.rigidbody;
+	
+	StartCoroutine ("DragObject", hit.distance);
+}
+
+function DragObject (distance : float)
+{
+	var oldDrag = springJoint.connectedBody.drag;
+	var oldAngularDrag = springJoint.connectedBody.angularDrag;
+	springJoint.connectedBody.drag = drag;
+	springJoint.connectedBody.angularDrag = angularDrag;
+	var mainCamera = FindCamera();
+	while (Input.GetMouseButton (0))
+	{
+		var ray = mainCamera.ScreenPointToRay (Input.mousePosition);
+		springJoint.transform.position = ray.GetPoint(distance);
+		yield;
+	}
+	if (springJoint.connectedBody)
+	{
+		springJoint.connectedBody.drag = oldDrag;
+		springJoint.connectedBody.angularDrag = oldAngularDrag;
+		springJoint.connectedBody = null;
+	}
+}
+
+function FindCamera ()
+{
+	if (camera)
+		return camera;
+	else
+		return Camera.main;
+}
Add a comment to this file

Assets/Standard Assets/Terrain Assets/Terrain Textures/Cliff (Layered Rock).psd

Added
New image
Add a comment to this file

Assets/Standard Assets/Terrain Assets/Terrain Textures/GoodDirt.psd

Added
New image
Add a comment to this file

Assets/Standard Assets/Terrain Assets/Terrain Textures/Grass (Hill).psd

Added
New image
Add a comment to this file

Assets/Standard Assets/Terrain Assets/Terrain Textures/Grass&Rock.psd

Added
New image

Binary file added.

Add a comment to this file

ProjectSettings/AudioManager.asset

Binary file added.

Add a comment to this file

ProjectSettings/DynamicsManager.asset

Binary file added.

Add a comment to this file

ProjectSettings/EditorBuildSettings.asset

Binary file added.

Add a comment to this file

ProjectSettings/EditorSettings.asset

Binary file added.

Add a comment to this file

ProjectSettings/InputManager.asset

Binary file added.

Add a comment to this file

ProjectSettings/NavMeshLayers.asset

Binary file added.

Add a comment to this file

ProjectSettings/NetworkManager.asset

Binary file added.

Add a comment to this file

ProjectSettings/ProjectSettings.asset

Binary file added.

Add a comment to this file

ProjectSettings/QualitySettings.asset

Binary file added.

Add a comment to this file

ProjectSettings/TagManager.asset

Binary file added.

Add a comment to this file

ProjectSettings/TimeManager.asset

Binary file added.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.