public void addHitSpots(SLaser laser) { var newHitSpot = new HitSpotData(laser, (ushort)(_nextEffectorMask + 1), _nextEffectorMask); _nextEffectorMask += 2; if (_nextEffectorMask == 0) // 0 is reserved for the global smoke dimmer { _nextEffectorMask = 2; } _hitSpots.Add(laser, newHitSpot); foreach (var emitter in newHitSpot.emitters()) { base.addEmitter(emitter); } foreach (var effector in newHitSpot.effectors()) { base.addEffector(effector); } // update global smoke smoke effectors with particle lifetime float newFlameSmokeDuration = laser.parameters.flameSmokeLifetime; _globalSmokeDimmerEffector.particleLifetime = newFlameSmokeDuration; _globalSmokeScaleEffector.particleLifetime = newFlameSmokeDuration; }
public SLaserBeamMiddleObject(SLaser laser, int beamId, SSScene cameraScene, SSTexture middleBackgroundTexture, SSTexture middleOverlayTexture, SSTexture inteferenceTexture) { this._laser = laser; this._beamId = beamId; this._cameraScene = cameraScene; this.renderState.castsShadow = false; this.renderState.receivesShadows = false; this.renderState.depthTest = true; this.renderState.depthWrite = false; this.renderState.alphaBlendingOn = true; //this.renderState.alphaBlendingOn = false; renderState.blendFactorSrcRGB = renderState.blendFactorSrcAlpha = BlendingFactorSrc.SrcAlpha; renderState.blendFactorDestRGB = renderState.blendFactorDestAlpha = BlendingFactorDest.One; // reset all mat colors. emission will be controlled during rendering this.colorMaterial = new SSColorMaterial(Color4Helper.Zero); this.middleBackgroundSprite = middleBackgroundTexture; this.middleOverlayTexture = middleOverlayTexture; this.interferenceTexture = inteferenceTexture; // initialize non-changing vertex data _initMiddleMesh(); _initInterferenceVertices(); // force an update to make sure we are not rendering (very noticable) bogus Update(0f); }
public SLaser addLaser(SLaserParameters laserParams, SSObject srcObject, SSObject dstObject) { if (_2dEffectRenderer.textureMaterial == null) { _2dEffectRenderer.textureMaterial = new SSTextureMaterial (laserParams.emissionSpritesTexture); } var newLaser = new SLaser (laserParams); //newLaser.intensityEnvelope.sustainDuration = sustainDuration; newLaser.sourceObject = srcObject; newLaser.targetObject = dstObject; var newLaserRuntime = new LaserRuntimeInfo (newLaser, _beamScene3d, _occDiskScene, _2dEffectRenderer); _laserRuntimes.Add (newLaserRuntime); if (laserParams.doLaserBurn) { _laserBurnParticles.particleSystem.addHitSpots(newLaser); } // debug hacks //newLaser.sourceObject = newLaserRuntime.beamRuntimes[0].emissionBillboard; //newLaser.sourceTxfm = Matrix4.Identity; return newLaser; }
public SLaserBeam(SLaser laser, int beamId) { _laser = laser; _beamId = beamId; // make periodic beam effects slightly out of sync with each other _periodicTOffset = (float)_random.NextDouble() * 10f; }
public void updateHitSpotVelocity(SLaser laser, Vector3 velocity) { var hitSpot = _hitSpots [laser]; foreach (var emitter in hitSpot.emitters()) { emitter.velocity = velocity; } }
public BeamRuntimeInfo(SLaser laser, int beamId, SSScene beamScene, SSScene occDiskScene, SSInstancedSpriteRenderer sprite2dRenderer) { _laser = laser; _beamId = beamId; _beamScene = beamScene; _occDiskScene = occDiskScene; _sprite2dRenderer = sprite2dRenderer; }
public SLaserScreenHitFlareUpdater( SLaser laser, int beamId, SSScene camera3dScene, RectangleF[] rects = null, float[] scales = null ) { _rects = rects ?? _defaultRects; _masterScales = scales ?? _defaultMasterScales; this._laser = laser; this._beamId = beamId; }
public LaserRuntimeInfo(SLaser laser, SSScene beamScene, SSScene occDiskScene, SSInstancedSpriteRenderer sprite2dRenderer) { _laser = laser; var numBeams = laser.parameters.numBeams; _beams = new BeamRuntimeInfo[numBeams]; for (int i = 0; i < numBeams; ++i) { _beams[i] = new BeamRuntimeInfo(laser, i, beamScene, occDiskScene, sprite2dRenderer); } }
public void removeHitSpots(SLaser laser) { var hitSpot = _hitSpots [laser]; foreach (var emitter in hitSpot.emitters()) { base.removeEmitter(emitter); } foreach (var effector in hitSpot.effectors()) { base.removeEffector(effector); } _hitSpots.Remove(laser); }
public SLaserEmissionFlareUpdater( SLaser laser, int beamId, /*SSObjectOcclusionQueuery occFlat,*/ SSObjectOcclusionQueuery occDisk, RectangleF backgroundRect, RectangleF overlayRect ) { this._laser = laser; this._beamId = beamId; //this._beamOccFlatObj = occFlat; this._occDiskObj = occDisk; this._backgroundRect = backgroundRect; this._overlayRect = overlayRect; }
public SLaser addLaser(SLaserParameters laserParams, SSObject srcObject, SSObject dstObject, SLaser.TargetVelFunc targetVelFunc = null) { if (_2dEffectRenderer.textureMaterial == null) { _2dEffectRenderer.textureMaterial = new SSTextureMaterial(laserParams.emissionSpritesTexture()); } var newLaser = new SLaser(laserParams, targetVelFunc); newLaser.sourceObject = srcObject; newLaser.targetObject = dstObject; var newLaserRuntime = new LaserRuntimeInfo(newLaser, _beamScene3d, _occDiskScene, _2dEffectRenderer); _laserRuntimes.Add(newLaserRuntime); if (laserParams.doLaserBurn) { SLaserBurnParticlesObject burnRenderer; bool ok = _laserBurnParticleRenderers.TryGetValue(dstObject, out burnRenderer); if (!ok) { burnRenderer = new SLaserBurnParticlesObject(dstObject, _maxBurnParticlesPerObject, null); burnRenderer.Name = "laser manager's laser burn particle system renderer"; burnRenderer.textureMaterial = new SSTextureMaterial(laserParams.laserBurnParticlesTexture()); //_laserBurnParticles.renderMode = SSInstancedMeshRenderer.RenderMode.GpuInstancing; burnRenderer.simulateOnUpdate = false; burnRenderer.simulateOnRender = true; _beamScene3d.AddObject(burnRenderer); _laserBurnParticleRenderers [dstObject] = burnRenderer; } burnRenderer.particleSystem.addHitSpots(newLaser); } // debug hacks //newLaser.sourceObject = newLaserRuntime.beamRuntimes[0].emissionBillboard; //newLaser.sourceTxfm = Matrix4.Identity; return(newLaser); }
public SLaser addLaser(SLaserParameters laserParams, SSObject srcObject, SSObject dstObject, SLaser.TargetVelFunc targetVelFunc = null) { if (_2dEffectRenderer.textureMaterial == null) { _2dEffectRenderer.textureMaterial = new SSTextureMaterial (laserParams.emissionSpritesTexture()); } var newLaser = new SLaser (laserParams, targetVelFunc); newLaser.sourceObject = srcObject; newLaser.targetObject = dstObject; var newLaserRuntime = new LaserRuntimeInfo (newLaser, _beamScene3d, _occDiskScene, _2dEffectRenderer); _laserRuntimes.Add (newLaserRuntime); if (laserParams.doLaserBurn) { SLaserBurnParticlesObject burnRenderer; bool ok = _laserBurnParticleRenderers.TryGetValue(dstObject, out burnRenderer); if (!ok) { burnRenderer = new SLaserBurnParticlesObject (dstObject, _maxBurnParticlesPerObject, null); burnRenderer.Name = "laser manager's laser burn particle system renderer"; burnRenderer.textureMaterial = new SSTextureMaterial(laserParams.laserBurnParticlesTexture()); //_laserBurnParticles.renderMode = SSInstancedMeshRenderer.RenderMode.GpuInstancing; burnRenderer.simulateOnUpdate = false; burnRenderer.simulateOnRender = true; _beamScene3d.AddObject(burnRenderer); _laserBurnParticleRenderers [dstObject] = burnRenderer; } burnRenderer.particleSystem.addHitSpots(newLaser); } // debug hacks //newLaser.sourceObject = newLaserRuntime.beamRuntimes[0].emissionBillboard; //newLaser.sourceTxfm = Matrix4.Identity; return newLaser; }
public SLaserBeamMiddleObject(SLaser laser, int beamId, SSScene cameraScene, SSTexture middleBackgroundTexture, SSTexture middleOverlayTexture, SSTexture inteferenceTexture) { this._laser = laser; this._beamId = beamId; this._cameraScene = cameraScene; this.renderState.castsShadow = false; this.renderState.receivesShadows = false; this.renderState.depthTest = true; this.renderState.depthWrite = false; this.renderState.alphaBlendingOn = true; //this.renderState.alphaBlendingOn = false; this.renderState.blendFactorSrc = BlendingFactorSrc.SrcAlpha; this.renderState.blendFactorDest = BlendingFactorDest.One; // reset all mat colors. emission will be controlled during rendering this.AmbientMatColor = new Color4(0f, 0f, 0f, 0f); this.DiffuseMatColor = new Color4(0f, 0f, 0f, 0f); this.SpecularMatColor = new Color4(0f, 0f, 0f, 0f); this.EmissionMatColor = new Color4(0f, 0f, 0f, 0f); this.middleBackgroundSprite = middleBackgroundTexture; this.middleOverlayTexture = middleOverlayTexture; this.interferenceTexture = inteferenceTexture; // initialize non-changing vertex data _initMiddleMesh (); _initInterferenceVertices (); // force an update to make sure we are not rendering (very noticable) bogus Update(0f); }
public void removeLaser(SLaser laser) { int idx = _laserRuntimes.FindIndex(lrt => lrt.laser == laser); _removeLaser(idx); _laserBurnParticles.particleSystem.removeHitSpots(laser); }
public void releaseLaser(SLaser laser) { laser.release(); }
public void removeLaser(SLaser laser) { int idx = _laserRuntimes.FindIndex(lrt => lrt.laser == laser); _removeLaser(idx); }
public HitSpotData(SLaser laser, ushort flameEffectorMask, ushort flashEffectorMask) { _laser = laser; int numBeams = _laser.parameters.numBeams; // initialize emitters _flashEmitters = new SSRadialEmitter[numBeams]; _smokeEmitters = new SSRadialEmitter[numBeams]; var laserParams = _laser.parameters; for (int i = 0; i < numBeams; ++i) { // hit spot flame/smoke { var newFlameSmokeEmitter = new SSRadialEmitter(); newFlameSmokeEmitter.effectorMask = flameEffectorMask; newFlameSmokeEmitter.billboardXY = true; newFlameSmokeEmitter.phiMin = (float)Math.PI/3f; newFlameSmokeEmitter.phiMax = (float)Math.PI/2f; newFlameSmokeEmitter.spriteRectangles = laserParams.flameSmokeSpriteRects; newFlameSmokeEmitter.emissionInterval = 1f / laserParams.flameSmokeEmitFrequency; newFlameSmokeEmitter.componentScaleMin = new Vector3(laserParams.flameSmokeScaleMin); newFlameSmokeEmitter.componentScaleMax = new Vector3(laserParams.flameSmokeScaleMax); newFlameSmokeEmitter.particlesPerEmission = 0; // init to 0 to not emit until updated newFlameSmokeEmitter.life = laserParams.flameSmokeLifetime; newFlameSmokeEmitter.velocityFromCenterMagnitudeMin = laserParams.spriteVelocityTowardsCameraMin; newFlameSmokeEmitter.velocityFromCenterMagnitudeMax = laserParams.spriteVelocityTowardsCameraMax; newFlameSmokeEmitter.thetaMin = 0f; newFlameSmokeEmitter.thetaMax = (float)Math.PI * 2f; newFlameSmokeEmitter.phiMin = (float)Math.PI/2f-0.1f; newFlameSmokeEmitter.phiMax = (float)Math.PI/2f+0.1f; _smokeEmitters[i] = newFlameSmokeEmitter; } // hit spot flash { var newFlashEmitter = new SSRadialEmitter(); newFlashEmitter.effectorMask = flashEffectorMask; newFlashEmitter.billboardXY = true; newFlashEmitter.spriteRectangles = laserParams.flashSpriteRects; newFlashEmitter.emissionInterval = 1f / laserParams.flashEmitFrequency; newFlashEmitter.masterScaleMin = laserParams.flashScaleMin; newFlashEmitter.masterScaleMax = laserParams.flashScaleMax; newFlashEmitter.particlesPerEmission = 0; // init to 0 to not emit until updated newFlashEmitter.life = laserParams.flashLifetime; //newFlashEmitter.colorPresets = Color4Helper.DebugPresets; newFlashEmitter.velocityFromCenterMagnitudeMin = laserParams.spriteVelocityTowardsCameraMin; newFlashEmitter.velocityFromCenterMagnitudeMax = laserParams.spriteVelocityTowardsCameraMax; newFlashEmitter.thetaMin = 0f; newFlashEmitter.thetaMax = (float)Math.PI * 2f; newFlashEmitter.phiMin = (float)Math.PI/2f-0.1f; newFlashEmitter.phiMax = (float)Math.PI/2f+0.1f; _flashEmitters[i] = newFlashEmitter; } } { // laser-specific flame/smoke effector _flamesSmokeColorEffector = new SSColorKeyframesEffector (); _flamesSmokeColorEffector.effectorMask = flameEffectorMask; _flamesSmokeColorEffector.preRemoveHook = _releaseSmokeParticle; _flamesSmokeColorEffector.maskMatchFunction = SSParticleEffector.MatchFunction.Equals; _flamesSmokeColorEffector.keyframes.Clear(); _flamesSmokeColorEffector.keyframes.Add(0f, new Color4 (1f, 1f, 1f, 1f)); _flamesSmokeColorEffector.keyframes.Add(0.4f, new Color4 (0f, 0f, 0f, 1f)); _flamesSmokeColorEffector.keyframes.Add(1f, new Color4 (0f, 0f, 0f, 0f)); _flamesSmokeColorEffector.particleLifetime = laserParams.flameSmokeLifetime; } { // laser-specific flash effector _flashColorEffector = new SSColorKeyframesEffector (); _flashColorEffector.effectorMask = flashEffectorMask; _flashColorEffector.preRemoveHook = _releaseFlashParticle; _flashColorEffector.maskMatchFunction = SSParticleEffector.MatchFunction.Equals; _flashColorEffector.keyframes.Clear(); _flashColorEffector.keyframes.Add(0f, new Color4 (1f, 1f, 1f, 0.5f)); _flashColorEffector.keyframes.Add(1f, new Color4 (1f, 1f, 1f, 0f)); _flashColorEffector.particleLifetime = laserParams.flashLifetime; } }
public void addHitSpots(SLaser laser) { var newHitSpot = new HitSpotData (laser, (ushort)(_nextEffectorMask + 1), _nextEffectorMask); _nextEffectorMask += 2; if (_nextEffectorMask == 0) { // 0 is reserved for the global smoke dimmer _nextEffectorMask = 2; } _hitSpots.Add(laser, newHitSpot); foreach (var emitter in newHitSpot.emitters()) { base.addEmitter(emitter); } foreach (var effector in newHitSpot.effectors()) { base.addEffector(effector); } // update global smoke smoke effectors with particle lifetime float newFlameSmokeDuration = laser.parameters.flameSmokeLifetime; _globalSmokeDimmerEffector.particleLifetime = newFlameSmokeDuration; _globalSmokeScaleEffector.particleLifetime = newFlameSmokeDuration; }
public HitSpotData(SLaser laser, ushort flameEffectorMask, ushort flashEffectorMask) { _laser = laser; int numBeams = _laser.parameters.numBeams; // initialize emitters _flashEmitters = new SSRadialEmitter[numBeams]; _smokeEmitters = new SSRadialEmitter[numBeams]; var laserParams = _laser.parameters; for (int i = 0; i < numBeams; ++i) { // hit spot flame/smoke { var newFlameSmokeEmitter = new SSRadialEmitter(); newFlameSmokeEmitter.effectorMask = flameEffectorMask; newFlameSmokeEmitter.billboardXY = true; newFlameSmokeEmitter.phiMin = (float)Math.PI / 3f; newFlameSmokeEmitter.phiMax = (float)Math.PI / 2f; newFlameSmokeEmitter.spriteRectangles = laserParams.flameSmokeSpriteRects; newFlameSmokeEmitter.emissionInterval = 1f / laserParams.flameSmokeEmitFrequency; newFlameSmokeEmitter.componentScaleMin = new Vector3(laserParams.flameSmokeScaleMin); newFlameSmokeEmitter.componentScaleMax = new Vector3(laserParams.flameSmokeScaleMax); newFlameSmokeEmitter.particlesPerEmission = 0; // init to 0 to not emit until updated newFlameSmokeEmitter.life = laserParams.flameSmokeLifetime; newFlameSmokeEmitter.velocityFromCenterMagnitudeMin = laserParams.spriteVelocityTowardsCameraMin; newFlameSmokeEmitter.velocityFromCenterMagnitudeMax = laserParams.spriteVelocityTowardsCameraMax; newFlameSmokeEmitter.thetaMin = 0f; newFlameSmokeEmitter.thetaMax = (float)Math.PI * 2f; newFlameSmokeEmitter.phiMin = (float)Math.PI / 2f - 0.1f; newFlameSmokeEmitter.phiMax = (float)Math.PI / 2f + 0.1f; _smokeEmitters[i] = newFlameSmokeEmitter; } // hit spot flash { var newFlashEmitter = new SSRadialEmitter(); newFlashEmitter.effectorMask = flashEffectorMask; newFlashEmitter.billboardXY = true; newFlashEmitter.spriteRectangles = laserParams.flashSpriteRects; newFlashEmitter.emissionInterval = 1f / laserParams.flashEmitFrequency; newFlashEmitter.masterScaleMin = laserParams.flashScaleMin; newFlashEmitter.masterScaleMax = laserParams.flashScaleMax; newFlashEmitter.particlesPerEmission = 0; // init to 0 to not emit until updated newFlashEmitter.life = laserParams.flashLifetime; //newFlashEmitter.colorPresets = Color4Helper.DebugPresets; newFlashEmitter.velocityFromCenterMagnitudeMin = laserParams.spriteVelocityTowardsCameraMin; newFlashEmitter.velocityFromCenterMagnitudeMax = laserParams.spriteVelocityTowardsCameraMax; newFlashEmitter.thetaMin = 0f; newFlashEmitter.thetaMax = (float)Math.PI * 2f; newFlashEmitter.phiMin = (float)Math.PI / 2f - 0.1f; newFlashEmitter.phiMax = (float)Math.PI / 2f + 0.1f; _flashEmitters[i] = newFlashEmitter; } } { // laser-specific flame/smoke effector _flamesSmokeColorEffector = new SSColorKeyframesEffector(); _flamesSmokeColorEffector.effectorMask = flameEffectorMask; _flamesSmokeColorEffector.preRemoveHook = _releaseSmokeParticle; _flamesSmokeColorEffector.maskMatchFunction = SSParticleEffector.MatchFunction.Equals; _flamesSmokeColorEffector.keyframes.Clear(); _flamesSmokeColorEffector.keyframes.Add(0f, new Color4(1f, 1f, 1f, 1f)); _flamesSmokeColorEffector.keyframes.Add(0.4f, new Color4(0f, 0f, 0f, 1f)); _flamesSmokeColorEffector.keyframes.Add(1f, new Color4(0f, 0f, 0f, 0f)); _flamesSmokeColorEffector.particleLifetime = laserParams.flameSmokeLifetime; } { // laser-specific flash effector _flashColorEffector = new SSColorKeyframesEffector(); _flashColorEffector.effectorMask = flashEffectorMask; _flashColorEffector.preRemoveHook = _releaseFlashParticle; _flashColorEffector.maskMatchFunction = SSParticleEffector.MatchFunction.Equals; _flashColorEffector.keyframes.Clear(); _flashColorEffector.keyframes.Add(0f, new Color4(1f, 1f, 1f, 0.5f)); _flashColorEffector.keyframes.Add(1f, new Color4(1f, 1f, 1f, 0f)); _flashColorEffector.particleLifetime = laserParams.flashLifetime; } }