public override RefStructure Build(Matrix4x4 toWorld) { var s = RefStructure.CreateNew(); var origin = _branchParticleBuilder.Add(s, Vector2.zero); _tempBaseBranchLength = _baseBranchLength.random; MakeBranch(s, _maxDepth.randomInt, origin, 90f, _tempBaseBranchLength); s.TranslateParticles(toWorld); return(s); }
public override RefStructure Build(Matrix4x4 toWorld) { var s = RefStructure.CreateNew(); var stepSize = Mathf.PI * 2f / _resolution; //パーティクルを配置 var p = new RefParticle[_resolution]; for (var i = 0; i < _resolution; ++i) { var t = stepSize * i; var x = Mathf.Cos(t) * _radius; var y = Mathf.Sin(t) * _radius; p[i] = _particleBuilder.Add(s, new Vector2(x, y)); } // エッジを配置 for (var i = 0; i < _resolution; ++i) { _edgeBuilder.Add(s, p[i], p[(i + 1) % _resolution]); for (var j = 0; j < _supportIntervals.Length; ++j) { _supportEdgeBuilder.Add(s, p[i], p[(i + _supportIntervals[j]) % _resolution]); } } s.TranslateParticles(toWorld); return(s); }
/// <summary> /// パーティクルの追加処理 /// </summary> void HandleAddParticle() { if (_structure) { var wpos = Camera.main.ScreenToWorldPoint(Input.mousePosition); var hitten = RefStructure.HitParticle(_structure, wpos); if (hitten == null) { _particleBuilder.Add(_structure, wpos); AddEditHistory(); SetDirty(); } } }