public override void Execute(ref WooState state) { if (state._Objects > 0) { state._Objects--; Vector3 val = new Vector3(0.0, 0.5, 0.0); val.y *= state._Scale.y; val.Mul(state._Rotation); Fractal newFractal = new Fractal(new Vector3(state._Position.x + val.x, state._Position.y + val.y, state._Position.z + val.z), state._Scale * 0.5, state._Rotation, state._DistanceMinimum, state._DistanceScale, state._DistanceOffset, state._DistanceIterations, state._DistanceExtents, state._StepSize, state._FractalIterations, state._FractalIterationCount, state._ColourIterationCount, state._DEMode); newFractal._Material = GenerateMaterial(state); newFractal.CreateElement(state._Preview, state._Parent); } }
public void Vector3_Mul() { Vector3 value = new Vector3(2f, 3f, 4f); Vector3 scale = new Vector3(2f, 3f, 4f); Vector3 expected = new Vector3(4f, 9f, 16f); Assert.That(value.Mul(scale), Is.EqualTo(expected)); }
public void TestMul() { var a = new Vector3(1, 2, 3); var b = 4f; var c = Vector3.Zero; _ = a.Mul(b, ref c); Assert.AreEqual(new Vector3(4, 8, 12), c); }
IEnumerator NextSceneChange(int sceneNo) { float speed = 50.0f; float scale = 0.015f; float minScale = 0.9f; Transform scene = SceneList[this.sceneNo].transform; Transform nextScene = SceneList[sceneNo].transform; nextScene.SetLocalScale(minScale); nextScene.position = screenSize.Mul((Vector3.one - nextScene.localScale) / 2); nextScene.AddPositionX(screenSize.x); while (scene.localScale.x > minScale) { scene.AddLocalScale(-scale); scene.position = screenSize.Mul((Vector3.one - scene.localScale) / 2); yield return(new WaitForEndOfFrame()); } scene.SetLocalScale(minScale); while (true) { scene.position -= Vector3.right * speed; nextScene.position -= Vector3.right * speed; if (scene.position.x <= -Screen.width + screenSize.x * (1 - scene.localScale.x) / 2) { break; } yield return(new WaitForEndOfFrame()); } nextScene.position = screenSize.Mul((Vector3.one - scene.localScale) / 2); yield return(new WaitForSeconds(0.15f)); while (nextScene.localScale.x < 1.0f) { nextScene.AddLocalScale(scale); nextScene.position = screenSize.Mul((Vector3.one - nextScene.localScale) / 2); yield return(new WaitForEndOfFrame()); } nextScene.localScale = Vector3.one; nextScene.position = Vector3.zero; Debug.Log("SceneChange Success"); this.sceneNo = sceneNo; scene.gameObject.SetActive(false); loadCompliteFlg = false; yield return(null); }
public void scaledCalc() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) scaledOffset = offset.Mul(_transform.get_lossyScale()); float num = markerZShift; Vector3 lossyScale = _transform.get_lossyScale(); scaledMarkerZShift = num * lossyScale.z; }
public override void Execute(ref WooState state) { if (state._Objects > 0) { state._Objects--; Vector3 val = new Vector3(0.0, 0.5, 0.0); val.y *= state._Scale.y; val.Mul(state._Rotation); Cube newCube = new Cube(new Vector3(state._Position.x + val.x, state._Position.y + val.y, state._Position.z + val.z), state._Scale, state._Rotation); newCube._Material = GenerateMaterial(state); newCube.CreateElement(state._Preview, state._Parent); } }
// Update is called once per frame void Update() { if (!isMoving && IsInputPressed() && canMove) { StartCoroutine(WaitForMove()); } if (isMoving) { if (!_stepSound.isPlaying && IsInputPressed()) { _stepSound.Play(); } float endTime = _stepStartTime + _stepLength; float stepPercentage = 1.0f - ((endTime - Time.time) / _stepLength); Vector3 move = moveDir.Mul(_acceleration) * _stepCurve.Evaluate(stepPercentage); _speed += move * Time.deltaTime; _NonHelmet.transform.localPosition = _NonHelmet.transform.localPosition.Y(_headYCurve.Evaluate(stepPercentage) * _headYMovement); float xOffset = _headXCurve.Evaluate(stepPercentage); if (!rightStep) { xOffset = -xOffset; } _NonHelmet.transform.localPosition = _NonHelmet.transform.localPosition.X(xOffset * _headXMovement); } if (!isMoving) { if (!IsInputPressed()) { _stepSound.Stop(); } _speed.x = _speed.x - Mathf.Lerp(_speed.x, 0, 0.1f) * Time.deltaTime; _speed.z = _speed.z - Mathf.Lerp(_speed.z, 0, 0.1f) * Time.deltaTime; } if (_speed.magnitude > _maxSpeed) { _speed = Vector3.ClampMagnitude(_speed, _maxSpeed); } controller.Move(_speed * Time.deltaTime + Physics.gravity * Time.deltaTime); }
public override void Execute(ref WooState state) { if (state._Objects > 0) { state._Objects--; Vector3 val = new Vector3(0.0, 0.5, 0.0); val.y *= state._Scale.y; val.Mul(state._Rotation); Vector3 pos = new Vector3(state._Position.x + val.x, state._Position.y + val.y, state._Position.z + val.z); SphereLight newLight = new SphereLight(state._Diff, pos, (float)(state._Scale.y * 0.5), 2); newLight.CreateElement(state._Parent, pos); } }
public static Vector3 trace(Ray ray, int depth, Random rnd) { var color = new Vector3(); bool did_hit = false; var hit = new Hit(); var sp = new Sphere(); hit.dist = 1e15f; foreach (var s in spheres) { var lh = s.Hit(ray); if (lh != null && lh.Value.dist > 0.0001f && lh.Value.dist < hit.dist) { sp = s; did_hit = true; color = s.color; hit = lh.Value; } } if (did_hit && depth < MAX_DEPTH) { if (sp.is_light != true) { var nray = new Ray( hit.point, RayBench.rnd_dome(hit.normal, rnd) ); var ncolor = RayBench.trace(nray, depth + 1, rnd); var at = nray.direction.Dot(hit.normal); color = color.Mul(ncolor.Mul(at)); } } if (did_hit == false || depth >= MAX_DEPTH) { return(new Vector3()); } return(color); }
private void Awake() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) _transform = this.get_transform(); scaledeOffset = offset.Mul(_transform.get_lossyScale()); if (autoBaseY != -1f) { float num = autoBaseY; Vector3 lossyScale = _transform.get_lossyScale(); autoBaseY = num * lossyScale.y; } up = false; }
/// <summary> /// Adds a new sample to the sample list and updates the stats. /// </summary> /// <param name="value">The new sample to add</param> public void AddSample(Vector3 value) { if (maxSamples == 0) { return; } // remove the old sample from our accumulation Vector3 oldSample = samples[currentSampleIndex]; cumulativeFrame -= oldSample; cumulativeFrameSquared -= (oldSample.Mul(oldSample)); // Add the new sample to the accumulation samples[currentSampleIndex] = value; cumulativeFrame += value; cumulativeFrameSquared += value.Mul(value); // Keep track of how many samples we have cumulativeFrameSamples++; ActualSampleCount = Mathf.Min(maxSamples, cumulativeFrameSamples); // see how many standard deviations the current sample is from the previous average Vector3 deltaFromAverage = (Average - value); float oldStandardDeviation = CurrentStandardDeviation; StandardDeviationsAwayOfLatestSample = oldStandardDeviation == 0 ? 0 : (deltaFromAverage / oldStandardDeviation).magnitude; // And calculate new averages and standard deviations // (note that calculating a standard deviation of a Vector3 might not // be done properly, but the logic is working for the gaze stabalization scenario) Average = cumulativeFrame / ActualSampleCount; float newStandardDev = Mathf.Sqrt((cumulativeFrameSquared / ActualSampleCount - Average.Mul(Average)).magnitude); StandardDeviationDeltaAfterLatestSample = oldStandardDeviation - newStandardDev; CurrentStandardDeviation = newStandardDev; // // update the next list position currentSampleIndex = (currentSampleIndex + 1) % maxSamples; }
public override void Execute(ref WooState state) { if (state._Objects > 0) { state._Objects--; Vector3 val = new Vector3(0.0, 0.5, 0.0); val.y *= state._Scale.y; val.Mul(state._Rotation); SVO newSVO = new SVO(new Vector3(state._Position.x + val.x, state._Position.y + val.y, state._Position.z + val.z), state._Scale, state._Rotation, state._DistanceFunction, state._DistanceMinimum, state._DistanceScale, state._DistanceOffset, state._StepSize, state._Depth); newSVO._Material = GenerateMaterial(state); newSVO.CreateElement(state._Preview, state._Parent); } }
private void ShotChunk(Vector3 localPosition) { var sourcePos = localPosition.Mul(Api.Enemy.transform.lossyScale); for (int i = 0; i < asset.ColumnsInChunk; i++) { for (int j = 0; j < asset.RowsInChunk; j++) { var offset = new Vector3( i - asset.ColumnsInChunk / 2, j - asset.RowsInChunk / 2, 0) * asset.OffsetSize; var offsetRandom = UnityEngine.Random.insideUnitCircle .ToVector3() * asset.RandomOffsetSize; var pixelOffset = offset + offsetRandom; var position = sourcePos + pixelOffset * Def.UnitPerPixel; Api.ShotByOffset(position, 180, asset.Speed * Def.UnitPerPixel); } } Api.PlayShootSound(); }
public static void GetContour_Rectangle(List <IntPoint> buffer, Transform tr, Vector2 rectangleSize, Vector3 center, bool useRotation) { Vector3 position = tr.position; if (useRotation) { Matrix4x4 localToWorldMatrix = tr.localToWorldMatrix; buffer.Add(V3ToIntPoint(localToWorldMatrix.MultiplyPoint3x4(center + ((Vector3)(new Vector3(-rectangleSize.x, 0f, -rectangleSize.y) * 0.5f))))); buffer.Add(V3ToIntPoint(localToWorldMatrix.MultiplyPoint3x4(center + ((Vector3)(new Vector3(rectangleSize.x, 0f, -rectangleSize.y) * 0.5f))))); buffer.Add(V3ToIntPoint(localToWorldMatrix.MultiplyPoint3x4(center + ((Vector3)(new Vector3(rectangleSize.x, 0f, rectangleSize.y) * 0.5f))))); buffer.Add(V3ToIntPoint(localToWorldMatrix.MultiplyPoint3x4(center + ((Vector3)(new Vector3(-rectangleSize.x, 0f, rectangleSize.y) * 0.5f))))); } else { float x = rectangleSize.x * tr.lossyScale.x; float z = rectangleSize.y * tr.lossyScale.y; position += center.Mul(tr.lossyScale); buffer.Add(V3ToIntPoint(position + ((Vector3)(new Vector3(-x, 0f, -z) * 0.5f)))); buffer.Add(V3ToIntPoint(position + ((Vector3)(new Vector3(x, 0f, -z) * 0.5f)))); buffer.Add(V3ToIntPoint(position + ((Vector3)(new Vector3(x, 0f, z) * 0.5f)))); buffer.Add(V3ToIntPoint(position + ((Vector3)(new Vector3(-x, 0f, z) * 0.5f)))); } }
public static void GetContour_Rectangle(List <IntPoint> buffer, Transform tr, Vector2 rectangleSize, Vector3 center, bool useRotation) { Vector3 a = tr.position; if (useRotation) { Matrix4x4 localToWorldMatrix = tr.localToWorldMatrix; buffer.Add(NavmeshCut.V3ToIntPoint(localToWorldMatrix.MultiplyPoint3x4(center + new Vector3(-rectangleSize.x, 0f, -rectangleSize.y) * 0.5f))); buffer.Add(NavmeshCut.V3ToIntPoint(localToWorldMatrix.MultiplyPoint3x4(center + new Vector3(rectangleSize.x, 0f, -rectangleSize.y) * 0.5f))); buffer.Add(NavmeshCut.V3ToIntPoint(localToWorldMatrix.MultiplyPoint3x4(center + new Vector3(rectangleSize.x, 0f, rectangleSize.y) * 0.5f))); buffer.Add(NavmeshCut.V3ToIntPoint(localToWorldMatrix.MultiplyPoint3x4(center + new Vector3(-rectangleSize.x, 0f, rectangleSize.y) * 0.5f))); } else { float num = rectangleSize.x * tr.lossyScale.x; float num2 = rectangleSize.y * tr.lossyScale.y; a += center.Mul(tr.lossyScale); buffer.Add(NavmeshCut.V3ToIntPoint(a + new Vector3(-num, 0f, -num2) * 0.5f)); buffer.Add(NavmeshCut.V3ToIntPoint(a + new Vector3(num, 0f, -num2) * 0.5f)); buffer.Add(NavmeshCut.V3ToIntPoint(a + new Vector3(num, 0f, num2) * 0.5f)); buffer.Add(NavmeshCut.V3ToIntPoint(a + new Vector3(-num, 0f, num2) * 0.5f)); } }
public static void GetContour_Circle(List <IntPoint> buffer, Transform tr, int circleResolution, float circleRadius, Vector3 center, bool useRotation) { Vector3 position = tr.position; if (useRotation) { Matrix4x4 localToWorldMatrix = tr.localToWorldMatrix; for (int i = 0; i < circleResolution; i++) { buffer.Add(V3ToIntPoint(localToWorldMatrix.MultiplyPoint3x4(center + ((Vector3)(new Vector3(Mathf.Cos(((i * 2) * 3.141593f) / ((float)circleResolution)), 0f, Mathf.Sin(((i * 2) * 3.141593f) / ((float)circleResolution))) * circleRadius))))); } } else { Vector3 zero = Vector3.zero; position += center.Mul(tr.lossyScale); for (int j = 0; j < circleResolution; j++) { zero.x = (Mathf.Cos(((j * 2) * 3.141593f) / ((float)circleResolution)) * circleRadius) * tr.lossyScale.x; zero.z = (Mathf.Sin(((j * 2) * 3.141593f) / ((float)circleResolution)) * circleRadius) * tr.lossyScale.z; buffer.Add(V3ToIntPoint(position + zero)); } } }
/// <summary> Multiplies this vector's components by (a, a, a). </summary> static public Vector3 Mul(this Vector3 t, float a) => t.Mul(a, a, a);
/// <summary> Multiplies this vector's components by (a.x, a.y, a.z). </summary> static public Vector3 Mul(this Vector3 t, Vector3 a) => t.Mul(a.x, a.y, a.z);
private void SetValue3arg(string target, Vector3 arg, bool overrideState) { string varname = target; int dotindex = target.IndexOf('.'); if (dotindex >= 0) { // target is a vector varname = target.Substring(0, dotindex); string selector = target.Substring(dotindex + 1); } if (varname.Equals("pos", StringComparison.Ordinal)) { if (overrideState) { _Position = arg; } else { Vector3 newval = arg; Vector3 vec = new Vector3(); vec.x = newval.x - _Position.x; vec.y = newval.y - _Position.y; vec.z = newval.z - _Position.z; vec.x = vec.x * _Scale.x; vec.y = vec.y * _Scale.y; vec.z = vec.z * _Scale.z; vec.Mul(_Rotation); _Position.x += vec.x; _Position.y += vec.y; _Position.z += vec.z; } } if (varname.Equals("scale", StringComparison.Ordinal)) { _Scale.x = arg.x; _Scale.y = arg.y; _Scale.z = arg.z; } if (varname.Equals("diff", StringComparison.Ordinal)) { _Diff._Red = arg.x; _Diff._Green = arg.y; _Diff._Blue = arg.z; } if (varname.Equals("refl", StringComparison.Ordinal)) { _Refl._Red = arg.x; _Refl._Green = arg.y; _Refl._Blue = arg.z; } if (varname.Equals("emi", StringComparison.Ordinal)) { _Emi._Red = arg.x; _Emi._Green = arg.y; _Emi._Blue = arg.z; } if (varname.Equals("spec", StringComparison.Ordinal)) { _Spec._Red = arg.x; _Spec._Green = arg.y; _Spec._Blue = arg.z; } if (varname.Equals("abs", StringComparison.Ordinal)) { _Abs._Red = arg.x; _Abs._Green = arg.y; _Abs._Blue = arg.z; } if (varname.Equals("v0", StringComparison.Ordinal)) { _v0.x = arg.x; _v0.y = arg.y; _v0.z = arg.z; } if (varname.Equals("v1", StringComparison.Ordinal)) { _v1.x = arg.x; _v1.y = arg.y; _v1.z = arg.z; } if (varname.Equals("v2", StringComparison.Ordinal)) { _v2.x = arg.x; _v2.y = arg.y; _v2.z = arg.z; } if (varname.Equals("v3", StringComparison.Ordinal)) { _v3.x = arg.x; _v3.y = arg.y; _v3.z = arg.z; } if (varname.Equals("distanceoffset", StringComparison.Ordinal)) { _DistanceOffset.x = arg.x; _DistanceOffset.y = arg.y; _DistanceOffset.z = arg.z; } if (varname.Equals("distanceextents", StringComparison.Ordinal)) { _DistanceExtents.x = arg.x; _DistanceExtents.y = arg.y; _DistanceExtents.z = arg.z; } if (IsVectorVariable(varname)) { SetVectorValue(varname, arg); } }
public static Vector3 trace(Ray ray, int depth) { var color = new Vector3(); bool did_hit = false; var hit = new Hit(); Sphere sp = null; hit.dist = 1e15f; foreach(var s in spheres) { var lh = s.Hit(ray); if (lh !=null && lh.dist > 0.0001f && lh.dist < hit.dist) { sp = s; did_hit = true; color = s.color; hit = lh; } } if (did_hit && depth < MAX_DEPTH) { if (sp.is_light != true) { var nray = new Ray( hit.point, RayBench.rnd_dome(hit.normal) ); var ncolor = RayBench.trace(nray, depth + 1); var at = nray.direction.Dot(hit.normal); color = color.Mul(ncolor.Mul(at)); } } if (did_hit == false || depth >= MAX_DEPTH) { color = new Vector3(); } return color; }