public FluidBody3d(ParticleSource source, float radius, float density, Matrix4x4f RTS) : base(source.NumParticles, radius, 1.0f) { Density = density; Viscosity = 0.02f; Dampning = 1; float d = ParticleDiameter; ParticleMass = 0.8f * d * d * d * Density; CreateParticles(source, RTS); float cellSize = ParticleRadius * 4.0f; Kernel = new CubicKernel3dGPU(cellSize); NeighboursSearcher = new ParticleNeighboursSearcherGPU(cellSize); Lambda = new float[NumParticles]; GPULambda = new ComputeBuffer <float>(NumParticles); Densities = new float[NumParticles]; GPUDensities = new ComputeBuffer <float>(NumParticles); InitCurrentShader(); InitShaderConsts(); Kernel.InitCubicKernel3dGPU(CurrentShader); }
protected override void InitializeInternal() { base.InitializeInternal(); _lightRotationAngle = 0; _sceneBounds = new BoundingSphere(new Vector3(), MathF.Sqrt(40 * 40 + 60 * 60)); _dirLights = new[] { new DirectionalLight { Ambient = new Color(0.2f, 0.2f, 0.2f), Diffuse = new Color(0.7f, 0.7f, 0.7f), Specular = new Color(0.8f, 0.8f, 0.8f), Direction = new Vector3(-0.57735f, -0.57735f, 0.57735f) }, new DirectionalLight { Ambient = new Color(0, 0, 0), Diffuse = new Color(0.4f, 0.4f, 0.4f), Specular = new Color(0.2f, 0.2f, 0.2f), Direction = new Vector3(-0.707f, -0.707f, 0) }, new DirectionalLight { Ambient = new Color(0, 0, 0), Diffuse = new Color(0.2f, 0.2f, 0.2f), Specular = new Color(0.2f, 0.2f, 0.2f), Direction = new Vector3(0, 0, -1) } }; _originalLightDirs = _dirLights.Select(l => l.Direction).ToArray(); var device = D3DApp11.I.D3DDevice; _shadowMap = new ShadowMap(device, ShadowMapSize, ShadowMapSize); BuildShapeGeometryBuffers(device); BuildScreenQuadGeometryBuffers(device); var context = D3DApp11.I.ImmediateContext; _randomTex = TextureLoader.CreateRandomTexture1D(device); _flareTexSRV = TextureLoader.CreateTexture2DArray(device, context, new[] { NoireConfiguration.GetFullResourcePath("textures/flare0.png") }); _fire = new ParticleSource(RootContainer, this, device, EffectManager11.Instance.GetEffect <FireParticleEffect11>(), _flareTexSRV, _randomTex, 500); _fire.Initialize(); _fire.Visible = _settings.ParticleFlameVisible; ChildComponents.Add(_fire); _rainTexSRV = TextureLoader.CreateTexture2DArray(device, context, new[] { NoireConfiguration.GetFullResourcePath("textures/raindrop.png") }); _rain = new ParticleSource(RootContainer, this, device, EffectManager11.Instance.GetEffect <RainParticleEffect11>(), _rainTexSRV, _randomTex, 10000); _rain.Initialize(); _rain.Visible = _settings.ParticleRainVisible; ChildComponents.Add(_rain); var basicFx = EffectManager11.Instance.GetEffect <BasicEffect11>(); var normalMapFx = EffectManager11.Instance.GetEffect <NormalMapEffect11>(); var displacementMapFx = EffectManager11.Instance.GetEffect <DisplacementMapEffect11>(); InitializeTechniqueTable(basicFx, normalMapFx, displacementMapFx); }
public FluidBoundary3d(ParticleSource source, double radius, double density, Matrix4x4d RTS) { ParticleRadius = radius; Density = density; CreateParticles(source, RTS); CreateBoundryPsi(); }
public RidgidBody3d(ParticleSource source, double radius, double mass, Matrix4x4d RTS) : base(source.NumParticles, radius, mass) { Stiffness = 1.0; CreateParticles(source, RTS); Constraints.Add(new ShapeMatchingConstraint3d(this, mass, Stiffness)); }
private void CreateParticles(ParticleSource source, Matrix4x4d RTS) { for (int i = 0; i < NumParticles; i++) { Vector4d pos = RTS * source.Positions[i].xyz1; Positions[i] = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); Predicted[i] = Positions[i]; } }
private Torch(Texture2D texture, Vector2 position, Rectangle sourceRectangle, Color tint, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth, float transparency, Vector2 velocity, Vector2 acceleration, float decelerationFactor, Texture2D partTexture) : base(texture, position, sourceRectangle, tint, rotation, origin, scale, effects, layerDepth, transparency, velocity, acceleration, decelerationFactor) { rgb = new Tuple <Vector2, Vector2, Vector2>(new Vector2(235, 255), new Vector2(0, 255), new Vector2(0, 0)); this.partTexture = partTexture; partSource = new ParticleSource(position - new Vector2(0, scale.Y * 11), new Vector2(0.5f, 1.2f), new Vector2(3f), 0.2f, rgb); spawnSpeed = new TimeSpan(0, 0, 0, 0, 100); lastSpawn = DateTime.Now; lifeSpan = rand.Next(150, 250); }
private void CreateParticles(ParticleSource source, Matrix4x4d RTS) { NumParticles = source.NumParticles; Positions = new Vector3d[NumParticles]; for (int i = 0; i < NumParticles; i++) { Vector4d pos = RTS * source.Positions[i].xyz1; Positions[i] = new Vector3d(pos.x, pos.y, pos.z); } }
private void CreateParticles(ParticleSource source, Matrix4x4f RTS) { for (int i = 0; i < NumParticles; i++) { Vector4f pos = RTS * source.Positions[i].xyz1; Positions[i] = new Vector3f(pos.x, pos.y, pos.z); Predicted[i] = Positions[i]; } PositionsToGpu(); PredictedToGpu(); }
private void CreateParticles(ParticleSource source, Matrix4x4f RTS) { NumParticles = source.NumParticles; Positions = new Vector3f[NumParticles]; for (int i = 0; i < NumParticles; i++) { Vector4f pos = RTS * source.Positions[i].xyz1; Positions[i] = new Vector3f(pos.x, pos.y, pos.z); } GPUPositions = new ComputeBuffer <Vector3f>(Positions); }
public FluidBody3d(ParticleSource source, double radius, double density, Matrix4x4d RTS) : base(source.NumParticles, radius, 1.0) { Density = density; Viscosity = 0.02; Dampning = 0; double d = ParticleDiameter; ParticleMass = 0.8 * d * d * d * Density; CreateParticles(source, RTS); double cellSize = ParticleRadius * 4.0; Kernel = new CubicKernel3d(cellSize); Hash = new ParticleHash3d(NumParticles, cellSize); Lambda = new double[NumParticles]; Densities = new double[NumParticles]; }
public BuilderWandRenderer(ParticleSource particles) { this._particleSource = particles; }