private void PrepareGrid() { //計算用のgridを用意--------------------------------------------- Mesh mesh = new Mesh(); this.GetComponent <MeshFilter>().mesh = mesh; Vector3 cubeNums = resolution - Vector3.one; Vector3 offSet = cubeNums * 0.5f * cubeScale; for (int z = 0; z < resolution.z; z++) { for (int y = 0; y < resolution.y; y++) { for (int x = 0; x < resolution.x; x++) { int index = (int)(x + y * resolution.x + (resolution.x * resolution.y) * z); _gridIndcied.Add(index); //頂点の追加 Vector3 vertex = new Vector3(x, y, z) * cubeScale - offSet; _gridVertices.Add(vertex); //物理量の追加 _phi.Add(SphereField.CalcSpherField(vertex) / 10.0f); //phi.Add(Noise.PerlinNoise(vertex.x*2.0f, vertex.y*2.0f, vertex.z * 3.0f)); //Debug.Log("grid courner index : " + index.ToString()); //phi.Add(0.0f); } } } mesh.vertices = _gridVertices.ToArray(); mesh.SetIndices(_gridIndcied.ToArray(), MeshTopology.Points, 0); }
public override void StartAction(List <Asteroid> afflicted, bool exact) { int radius = 100; float lifeTime = 2; Color color = new Color(); color.A = 35; color.R = 80; color.G = 255; color.B = 80; field = SceneObjectFactory.CreateSphereField(SceneMgr, Owner.Device.Center - new Vector(radius, radius), radius, color); StaticFieldControl control = new StaticFieldControl(); control.Force = 140; control.LifeTime = lifeTime; control.Radius = radius; RippleEffectControl rippleControl = new RippleEffectControl(); rippleControl.Speed = 15; Owner.Device.AddControl(control); field.AddControl(rippleControl); field.AddControl(new LimitedLifeControl(lifeTime)); field.AddControl(new CenterCloneControl(Owner.Device)); SceneMgr.DelayedAttachToScene(field); }
public void CustomPropertiesSphereFieldTests(float x, float y, float z, float r, float expectedResult) { var field = new SphereField(); field.Radius = r; field.Falloff = 10; field.Center = new Vector3(x, y, z); var actualResult = field.GetValue(Vector3.zero); Assert.AreEqual(expectedResult, actualResult, 0.00001); }
public static SphereField CreateSphereField(SceneMgr mgr, Vector position, int radius, Color color) { SphereField f = new SphereField(mgr, IdMgr.GetNewId(mgr.GetCurrentPlayer().GetId())); f.Radius = radius; f.Color = color; f.Position = position; f.HeavyWeightGeometry = HeavyweightGeometryFactory.CreateConstantColorEllipseGeometry(f); SphereCollisionShape shape = new SphereCollisionShape(); shape.Radius = radius; shape.Center = f.Center; f.CollisionShape = shape; return(f); }
public static Path CreateConstantColorEllipseGeometry(SphereField s) { Path path = null; s.SceneMgr.Invoke(new Action(() => { EllipseGeometry geom = new EllipseGeometry(new Point(s.Radius, s.Radius), s.Radius, s.Radius); path = new Path(); path.Data = geom; path.Fill = new SolidColorBrush(s.Color); TransformGroup tg = new TransformGroup(); tg.Children.Add(new TranslateTransform(s.Position.X, s.Position.Y)); path.RenderTransform = tg; Canvas.SetZIndex(path, -1); })); return(path); }