diff --git a/Assets/Materials/ArcMat.mat b/Assets/Materials/ArcMat.mat new file mode 100644 index 0000000..932c82e --- /dev/null +++ b/Assets/Materials/ArcMat.mat @@ -0,0 +1,138 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: ArcMat + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 5 + m_CustomRenderQueue: -1 + stringTagMap: {} + m_SavedProperties: + serializedVersion: 2 + m_TexEnvs: + data: + first: + name: _MainTex + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _BumpMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _DetailNormalMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _ParallaxMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _OcclusionMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _EmissionMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _DetailMask + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _DetailAlbedoMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _MetallicGlossMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + data: + first: + name: _SrcBlend + second: 1 + data: + first: + name: _DstBlend + second: 0 + data: + first: + name: _Cutoff + second: 0.5 + data: + first: + name: _Parallax + second: 0.02 + data: + first: + name: _ZWrite + second: 1 + data: + first: + name: _Glossiness + second: 0.5 + data: + first: + name: _BumpScale + second: 1 + data: + first: + name: _OcclusionStrength + second: 1 + data: + first: + name: _DetailNormalMapScale + second: 1 + data: + first: + name: _UVSec + second: 0 + data: + first: + name: _Mode + second: 0 + data: + first: + name: _Metallic + second: 0 + m_Colors: + data: + first: + name: _EmissionColor + second: {r: 0, g: 0, b: 0, a: 1} + data: + first: + name: _Color + second: {r: 1, g: 1, b: 1, a: 1} diff --git a/Assets/Materials/ArcMat.mat.meta b/Assets/Materials/ArcMat.mat.meta new file mode 100644 index 0000000..898ec89 --- /dev/null +++ b/Assets/Materials/ArcMat.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b331bc2808e0744f888777de7a5d955e +timeCreated: 1454113178 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/ArcViz.cs b/Assets/Scripts/ArcViz.cs index 607390a..29e15dd 100644 --- a/Assets/Scripts/ArcViz.cs +++ b/Assets/Scripts/ArcViz.cs @@ -1,28 +1,43 @@ using UnityEngine; +[ExecuteInEditMode] [RequireComponent(typeof(LineRenderer))] public class ArcViz : MonoBehaviour { private LineRenderer _renderer; - [Range(0f, 100f)] + [Header("Debug Vars:")] [Range(0f, 100f)] [SerializeField] private float _power = 30f; + [SerializeField] private bool _debug; + + [Header("Settings:")] [Range(0.01f, 1f)] [SerializeField] private float _timeStep = 0.5f; [SerializeField] private float _maxTime = 10f; + public float TimeStep { + get { return _timeStep; } + set { _timeStep = value; } + } + + public float MaxTime { + get { return _maxTime; } + set { _maxTime = value; } + } + private void Awake() { _renderer = GetComponent(); } private void Update() { - PlotTrajectory(Vector3.zero, transform.forward * _power, _timeStep, _maxTime); + if (_debug) + DrawTrajectory(transform.position, transform.forward, _power); } - public Vector3 PlotTrajectoryAtTime(Vector3 start, Vector3 startVelocity, float time) { + private Vector3 PlotTrajectoryAtTime(Vector3 start, Vector3 startVelocity, float time) { return start + startVelocity * time + Physics.gravity * time * time * 0.5f; } - public void PlotTrajectory(Vector3 start, Vector3 StartVelocity, float timeStep, float maxTime) { + private void PlotTrajectory(Vector3 start, Vector3 StartVelocity, float timeStep, float maxTime) { var length = Mathf.RoundToInt(maxTime / timeStep); _renderer.SetVertexCount(length + 1); @@ -32,15 +47,19 @@ public void PlotTrajectory(Vector3 start, Vector3 StartVelocity, float timeStep, float t = timeStep * i; if (t > maxTime) break; - var pos = PlotTrajectoryAtTime(start, StartVelocity, t); - - if (Physics.Linecast(prev, pos)) - break; - Debug.DrawLine(prev, pos, Color.red); _renderer.SetPosition(i, pos); prev = pos; } } + + public void DrawTrajectory(Vector3 start, Vector3 startVelocity, float power) { + _renderer.enabled = true; + PlotTrajectory(start, startVelocity * power, TimeStep, MaxTime); + } + + public void ClearTrajectory() { + _renderer.enabled = false; + } } diff --git a/Assets/Shaders.meta b/Assets/Shaders.meta new file mode 100644 index 0000000..2cb8718 --- /dev/null +++ b/Assets/Shaders.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 7106dc0c7bcdd46028f6556f157269b3 +folderAsset: yes +timeCreated: 1454113158 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: