Beispiel #1
0
        public SLaser(SLaserParameters laserParams, TargetVelFunc targetVelFunc = null)
        {
            this.parameters = laserParams;
            this._localIntensityEnvelope = laserParams.intensityEnvelope.Clone();
            this.targetVelFunc           = targetVelFunc;

            _beams = new SLaserBeam[parameters.numBeams];
            for (int i = 0; i < parameters.numBeams; ++i)
            {
                _beams[i] = new SLaserBeam(this, i);
            }
        }
Beispiel #2
0
        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);
        }