public getPointOnPath ( float t ) : Vector3 | ||
t | float | |
Résultat | Vector3 |
public override void tick(float totalElapsedTime) { float t = _easeFunction(totalElapsedTime, 0f, 1f, _ownerTween.duration); Vector3 vector = _path.getPointOnPath(t); if (_isRelative) { vector += _startValue; } switch (_lookAtType) { case GoLookAtType.NextPathNode: _smoothedRotation.smoothValue = ((!vector.Equals(_target.position)) ? Quaternion.LookRotation(vector - _target.position) : Quaternion.identity); _target.rotation = _smoothedRotation.smoothValue; break; case GoLookAtType.TargetTransform: _target.LookAt(_lookTarget, Vector3.up); break; } if (_useLocalPosition) { _target.localPosition = vector; } else { _target.position = vector; } }
private void BakeRoutine(BakedPathInfo info) { GoSpline spline = info.path.Spline(); while (info.progress < 1.0f) { Vector3 pos = spline.getPointOnPath(info.progress); info.bakedNodes.Add(pos); info.progress += info.step; } }
public override void tick(float totalElapsedTime) { float t = _easeFunction(totalElapsedTime, 0f, 1f, _ownerTween.duration); Vector3 vector = _path.getPointOnPath(t); if (_isRelative) { vector += _startValue; } _setter(vector); }
protected void LookupSpline(GoSpline spline) { float tStep = 1f / splineLookupCount; float t = tStep; for (int i = 0; i < splineLookupCount; i++) { spline.getPointOnPath(t); t += tStep; } }
public override void tick(float totalElapsedTime) { var easedTime = _easeFunction(totalElapsedTime, 0, 1, _ownerTween.duration); var vec = _path.getPointOnPath(easedTime); // if we are relative, add the vec to our startValue if (_isRelative) { vec += _startValue; } _setter(vec); }
static public int getPointOnPath(IntPtr l) { try { GoSpline self = (GoSpline)checkSelf(l); System.Single a1; checkType(l, 2, out a1); var ret = self.getPointOnPath(a1); pushValue(l, ret); return(1); } catch (Exception e) { return(error(l, e)); } }
//Worker thread to do the baking IEnumerator Worker(TrafficPath path) { Debug.Log("Start Worker"); //open folder to create new file //System.IO.FileStream fstream = Ultilities.OpenFile(path.gameObject.name, System.IO.FileMode.OpenOrCreate); string workerName = "Worker: " + path.gameObject.name; GameObject trafficBaker = new GameObject(workerName); trafficBaker.transform.SetParent(transform); float progress = 0; GoSpline spline = path.Spline(); float speed = path.bakedResolution; float duration = path.Spline().pathLength; List <Vector3> pathNodes = new List <Vector3>(); string pathName = path.gameObject.name; //baking while (progress <= 1.0f) { yield return(new WaitForFixedUpdate()); progress += Time.fixedDeltaTime / (duration / (speed * 0.44704f)); Vector3 pos = spline.getPointOnPath(progress); trafficBaker.transform.position = pos; pathNodes.Add(pos); trafficBaker.name = workerName + ": " + progress * 100 + "%"; } //done baking Debug.Log(workerName + ": Done"); Debug.Log("Nodes Count: " + pathNodes.Count); /* * BakedTrafficPath bakedPath = ScriptableObject.CreateInstance<BakedTrafficPath>(); * bakedPath.Init(pathNodes, pathName, path.pathType, path.pathSpeedMPH, path.bakedResolution, path.splitChance, path.smartTraffic, path.phaseTypes, path.notes); * bakedPath.CreateAndSave(savedLocation); */ yield return(null); }
public override void tick(float totalElapsedTime) { var easedTime = _easeFunction(totalElapsedTime, 0, 1, _ownerTween.duration); var vec = _path.getPointOnPath(easedTime); // if we are relative, add the vec to our startValue if (_isRelative) { vec += _startValue; } // handle look types switch (_lookAtType) { case LookAtType.NextPathNode: { _smoothedRotation.smoothValue = vec.Equals(_target.position) ? Quaternion.identity : Quaternion.LookRotation(vec - _target.position); _target.rotation = _smoothedRotation.smoothValue; //var lookAtNode = ( _ownerTween.isReversed || _ownerTween.isLoopoingBackOnPingPong ) ? _path.getPreviousNode() : _path.getNextNode(); //_target.LookAt( lookAtNode, Vector3.up ); break; } case LookAtType.TargetTransform: { _target.LookAt(_lookTarget, Vector3.up); break; } } // assign the position if (_useLocalPosition) { _target.localPosition = vec; } else { _target.position = vec; } }
protected void LookupSpline(GoSpline spline) { float tStep = 1f / splineLookupCount; float t = tStep; for (int i=0; i<splineLookupCount; i++) { spline.getPointOnPath(t); t += tStep; } }