Ejemplo n.º 1
0
        public SLaserManager(SSScene beamScene3d, SSScene occDiskScene, SSScene flareScene2d,
            int sprite2dCapacity = 1000, int laserBurnParticlesCapacity = 2000)
        {
            _beamScene3d = beamScene3d;
            _occDiskScene = occDiskScene;
            _flareScene2d = flareScene2d;

            _2dEffectInstanceData = new SInstancedSpriteData (sprite2dCapacity);
            _2dEffectRenderer = new SSInstancedSpriteRenderer (_beamScene3d, _2dEffectInstanceData);
            _2dEffectRenderer.Name = "laser manager's 2d screen effect renderer";

            _2dEffectRenderer.renderState.alphaBlendingOn = true;
            _2dEffectRenderer.renderState.blendFactorSrc = BlendingFactorSrc.SrcAlpha;
            _2dEffectRenderer.renderState.blendFactorDest = BlendingFactorDest.One;
            //_2dEffectRenderer.renderMode = SSInstancedMeshRenderer.RenderMode.GpuInstancing;
            _flareScene2d.AddObject(_2dEffectRenderer);

            _laserBurnParticles = new SLaserBurnParticlesObject (
                laserBurnParticlesCapacity, SLaserParameters.laserBurnParticlesDefaultTexture());
            _laserBurnParticles.Name = "laser manager's laser burn particle system renderer";
            //_laserBurnParticles.renderMode = SSInstancedMeshRenderer.RenderMode.GpuInstancing;
            _beamScene3d.AddObject(_laserBurnParticles);

            _beamScene3d.preRenderHooks += this._update;
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
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;
        }