public void AddFluidContainer(FluidContainerMain fluidContainerMain) { double x = Convert.ToDouble(fluidContainerMain.VisualElement.GetValue(Canvas.LeftProperty)); double y = Convert.ToDouble(fluidContainerMain.VisualElement.GetValue(Canvas.TopProperty)); float width = (float)fluidContainerMain.VisualElement.ActualWidth; float height = (float)fluidContainerMain.VisualElement.ActualHeight; WaveController waveController = fluidContainerMain.WaveControllerObject; waveController.Position = new Vector2((float)x, (float)y); waveController.Width = width; waveController.Height = height; waveController.NodeCount = fluidContainerMain.NodeCount; waveController.DampingCoefficient = (float)fluidContainerMain.DampingCoefficient; waveController.Frequency = (float)fluidContainerMain.Frequency; waveController.WaveGeneratorMax = (float)fluidContainerMain.WaveGeneratorMax; waveController.WaveGeneratorMin = (float)fluidContainerMain.WaveGeneratorMin; waveController.WaveGeneratorStep = (float)fluidContainerMain.WaveGeneratorStep; waveController.Initialize(); Vector2 vecTopLeft = new Vector2((float)x, (float)y); Vector2 vecBottomRight = new Vector2((float)x + width, (float)y + height); AABB waterAABB = new AABB(vecTopLeft, vecBottomRight); AABBFluidContainer waterContainer = new AABBFluidContainer(waterAABB); FluidDragController fluidDragController = new FluidDragController(); foreach (KeyValuePair <string, PhysicsSprite> item in PhysicsObjects) { PhysicsSprite sprite = item.Value; fluidDragController.AddGeom(sprite.GeometryObject); } fluidDragController.Initialize(waterContainer, (float)fluidContainerMain.FluidDensity, (float)fluidContainerMain.LinearDragCoefficient, (float)fluidContainerMain.RotationalDragCoefficient, new Vector2((float)fluidContainerMain.GravityHorizontal, (float)fluidContainerMain.GravityVertical)); Simulator.Add(fluidDragController); }
public static void SetFluidContainer(DependencyObject target, FluidContainerMain value) { target.SetValue(FluidContainerMain.FluidControllerProperty, value); }