Exemple #1
0
        /// <summary>
        /// This is the same lightning System as Flare/mp_lightning from the Editor.
        /// </summary>
        public void MakeLighting()
        {
            puLightningBolt      = puManager.CreateParticleSystem("TestLightningBolt", mgr);
            puLightningBoltScene = mgr.RootSceneNode.CreateChildSceneNode("LightningBoltScene");
            puLightningBoltScene.AttachObject(puLightningBolt);


            ParticleTechnique puLightningBoltT = puLightningBolt.CreateTechnique();

            puLightningBoltT.VisualParticleQuota = 5;
            puLightningBoltT.MaterialName        = "mp_flare_lightning_bolt_1x2";
            puLightningBoltT.DefaultWidth        = 200;
            puLightningBoltT.DefaultHeight       = 200;

            MParticleUniverse.ParticleRenderers.BillboardRenderer renderer = (MParticleUniverse.ParticleRenderers.BillboardRenderer)puLightningBoltT.GetRenderer();
            renderer.TextureCoordsColumns  = 2;
            renderer.BillboardRotationType = BillboardRotationType.BBR_VERTEX;

            MParticleUniverse.ParticleEmitters.PointEmitter pe = (MParticleUniverse.ParticleEmitters.PointEmitter)puLightningBoltT.CreateEmitter("Point");
            DynamicAttributeFixed peRate = new DynamicAttributeFixed();

            peRate.SetValue(9);
            pe.DynEmissionRate = peRate;
            DynamicAttributeRandom petime_to_live = new DynamicAttributeRandom();

            petime_to_live.Min    = 0.3f;
            petime_to_live.Max    = 0.6f;
            pe.DynTotalTimeToLive = petime_to_live;
            DynamicAttributeFixed peVelocity = new DynamicAttributeFixed();

            peVelocity.SetValue(0);
            pe.DynVelocity = peVelocity;
            DynamicAttributeFixed peDuration = new DynamicAttributeFixed();

            peDuration.SetValue(0.7f);
            pe.DynDuration = peDuration;
            pe.DynDurationSet(true);
            pe.ParticleTextureCoordsRangeEnd = 1;

            MParticleUniverse.ParticleAffectors.ColourAffector ca = (MParticleUniverse.ParticleAffectors.ColourAffector)puLightningBoltT.CreateAffector("Colour");
            ca.AddColour(0, new Mogre.ColourValue(1, 1, 1, 1));
            ca.AddColour(0.1f, new Mogre.ColourValue(1, 1, 1, 1));
            ca.AddColour(1, new Mogre.ColourValue(0, 0, 0, 1));
            ca.ColourOperation = MParticleUniverse.ParticleAffectors.ColourAffector.ColourOperations.CAO_MULTIPLY;
            ////puLightningBoltT.AddAffector(ca);


            MParticleUniverse.ParticleObservers.OnClearObserver oco = (MParticleUniverse.ParticleObservers.OnClearObserver)puLightningBoltT.CreateObserver("OnClear");
            MParticleUniverse.ParticleEventHandlers.DoStopSystemEventHandler dsseh = (MParticleUniverse.ParticleEventHandlers.DoStopSystemEventHandler)oco.CreateEventHandler("DoStopSystem");
        }
Exemple #2
0
        public void Lesson2()
        {
            puLightningBolt = puManager.CreateParticleSystem("puLesson2", mgr);
            SceneNode scene = mgr.RootSceneNode.CreateChildSceneNode("puLesson2Scene");

            scene.AttachObject(puLightningBolt);

            //puLightningBolt.IsKeepLocal = true;
            ParticleTechnique puLightningBoltT = puLightningBolt.CreateTechnique();

            //ParticleTechnique puLightningBoltT = puLightningBolt.GetTechnique(0);
            puLightningBoltT.MaterialName = "ParticleUniverse/Flare";
            //puLightningBoltT.SetRenderer("Billboard");
            MParticleUniverse.ParticleEmitters.PointEmitter pe = (MParticleUniverse.ParticleEmitters.PointEmitter)puLightningBoltT.CreateEmitter("Point");
            //puLightningBolt.SetDebugDisplayEnabled(true);
            DynamicAttributeFixed emissionRate = new DynamicAttributeFixed();

            emissionRate.SetValue(60);
            pe.DynEmissionRate = emissionRate;

            DynamicAttributeRandom emissionVelocity = new DynamicAttributeRandom();

            emissionVelocity.Min = 50;
            emissionVelocity.Max = 300;
            pe.DynVelocity       = emissionVelocity;

            DynamicAttributeRandom emissionDimentions = new DynamicAttributeRandom();

            emissionDimentions.Min      = 50;
            emissionDimentions.Max      = 150;
            pe.DynParticleAllDimensions = emissionDimentions;

            MParticleUniverse.ParticleAffectors.ColourAffector colAffector = (MParticleUniverse.ParticleAffectors.ColourAffector)puLightningBoltT.CreateAffector("Colour");
            colAffector.AddColour(0, ColourValue.Black);
            colAffector.AddColour(0, new ColourValue(0.929412f, 0.0196078f, 0.909804f, 1f));

            MParticleUniverse.ParticleAffectors.LinearForceAffector lforceAffector = (MParticleUniverse.ParticleAffectors.LinearForceAffector)puLightningBoltT.CreateAffector("LinearForce");
            lforceAffector.ForceVector = new Vector3(100, -100, 0);
        }
Exemple #3
0
        public void TestLaser()
        {
            puLightningBolt      = puManager.CreateParticleSystem("TestLaser", mgr);
            puLightningBoltScene = mgr.RootSceneNode.CreateChildSceneNode("TestLaserScene");
            puLightningBoltScene.AttachObject(puLightningBolt);

            puLightningBolt.Scale = (new Vector3(10, 10, 10));
            //MParticleUniverse.ParticleRenderers.BillboardRenderer renderer = (MParticleUniverse.ParticleRenderers.BillboardRenderer)puLightningBoltT.GetRenderer();
            //MParticleUniverse.ParticleEmitters.PointEmitter pe = (MParticleUniverse.ParticleEmitters.PointEmitter)puLightningBoltT.CreateEmitter("Point");

            ParticleTechnique tTarget1 = puLightningBolt.CreateTechnique();

            tTarget1.VisualParticleQuota   = 2;
            tTarget1.EmittedEmitterQuota   = 0;
            tTarget1.EmittedTechniqueQuota = 0;
            tTarget1.EmittedAffectorQuota  = 0;
            tTarget1.EmittedSystemQuota    = 0;
            tTarget1.MaterialName          = "ParticleUniverse/Beam_1";
            tTarget1.DefaultWidth          = 0.3f;
            tTarget1.SetRenderer("Beam");
            MParticleUniverse.ParticleRenderers.BeamRenderer tTarget1Renderer = (MParticleUniverse.ParticleRenderers.BeamRenderer)tTarget1.GetRenderer();
            tTarget1Renderer.MaxChainElements = 20;
            tTarget1Renderer.UpdateInterval   = 0.04f;
            tTarget1Renderer.Deviation        = 10;
            tTarget1Renderer.NumberOfSegments = 1;
            MParticleUniverse.ParticleEmitters.PointEmitter tTarget1Emitter = (MParticleUniverse.ParticleEmitters.PointEmitter)tTarget1.CreateEmitter("Point");
            DynamicAttributeFixed tTarget1EmitterTTL = new DynamicAttributeFixed();

            tTarget1EmitterTTL.SetValue(200);
            tTarget1Emitter.DynTotalTimeToLive = tTarget1EmitterTTL;
            tTarget1Emitter.Position           = new Vector3(0, 0, 10);
            tTarget1Emitter.Direction          = new Vector3(0, 0, 0);

            ParticleTechnique tTarget2 = puLightningBolt.CreateTechnique();

            tTarget2.VisualParticleQuota   = 2;
            tTarget2.EmittedEmitterQuota   = 0;
            tTarget2.EmittedTechniqueQuota = 0;
            tTarget2.EmittedAffectorQuota  = 0;
            tTarget2.MaterialName          = "ParticleUniverse/Beam_2";
            tTarget2.DefaultWidth          = 0.1f;
            tTarget2.SetRenderer("Beam");
            MParticleUniverse.ParticleRenderers.BeamRenderer tTarget2Renderer = (MParticleUniverse.ParticleRenderers.BeamRenderer)tTarget2.GetRenderer();
            tTarget2Renderer.MaxChainElements = 20;
            tTarget2Renderer.UpdateInterval   = 0.02f;
            tTarget2Renderer.Deviation        = 1.5f;
            tTarget2Renderer.NumberOfSegments = 3;
            tTarget2Renderer.Jump             = true;
            MParticleUniverse.ParticleEmitters.PointEmitter tTarget2Emitter = (MParticleUniverse.ParticleEmitters.PointEmitter)tTarget2.CreateEmitter("Point");
            DynamicAttributeFixed tTarget2EmitterTTL = new DynamicAttributeFixed();

            tTarget2EmitterTTL.SetValue(200);
            tTarget2Emitter.DynTotalTimeToLive = tTarget2EmitterTTL;
            tTarget2Emitter.Direction          = new Vector3(0, 0, 0);
            tTarget2Emitter.Position           = new Vector3(0, 0, 10);
            ParticleTechnique tTarget3 = puLightningBolt.CreateTechnique();

            tTarget3.MaterialName  = "ParticleUniverse/Star";
            tTarget3.DefaultWidth  = 1;
            tTarget3.DefaultHeight = 5;
            MParticleUniverse.ParticleRenderers.BillboardRenderer tTarget3Renderer = (MParticleUniverse.ParticleRenderers.BillboardRenderer)tTarget3.GetRenderer();
            tTarget3Renderer.BillboardType = MParticleUniverse.ParticleRenderers.BillboardRenderer.BillboardTypes.BBT_ORIENTED_SELF;
            MParticleUniverse.ParticleEmitters.PointEmitter tTarget3Emitter1 = (MParticleUniverse.ParticleEmitters.PointEmitter)tTarget3.CreateEmitter("Point");
            DynamicAttributeFixed tTarget3EmitterTTL1 = new DynamicAttributeFixed();

            tTarget3EmitterTTL1.SetValue(0.2f);
            tTarget3Emitter1.DynTotalTimeToLive = tTarget3EmitterTTL1;
            DynamicAttributeFixed tTarget3EmitterEmissionRate1 = new DynamicAttributeFixed();

            tTarget3EmitterEmissionRate1.SetValue(100);
            tTarget3Emitter1.DynEmissionRate = tTarget3EmitterEmissionRate1;
            DynamicAttributeFixed tTarget3EmitterAngle1 = new DynamicAttributeFixed();

            tTarget3EmitterAngle1.SetValue(90);
            tTarget3Emitter1.DynAngle = tTarget3EmitterAngle1;
            DynamicAttributeRandom tTarget3EmitterVelocity1 = new DynamicAttributeRandom();

            tTarget3EmitterVelocity1.Min = 1;
            tTarget3EmitterVelocity1.Max = 15;
            tTarget3Emitter1.DynVelocity = tTarget3EmitterVelocity1;
            tTarget3Emitter1.Name        = "tTarget3Emitter1_Sparkles";

            MParticleUniverse.ParticleEmitters.PointEmitter tTarget3Emitter2 = (MParticleUniverse.ParticleEmitters.PointEmitter)tTarget3.CreateEmitter("Point");
            DynamicAttributeFixed tTarget3EmitterEmissionRate2 = new DynamicAttributeFixed();

            tTarget3EmitterEmissionRate2.SetValue(1);
            tTarget3Emitter2.DynEmissionRate = tTarget3EmitterEmissionRate2;
            DynamicAttributeFixed tTarget3EmitterTTL2 = new DynamicAttributeFixed();

            tTarget3EmitterTTL2.SetValue(200);
            tTarget3Emitter2.DynTotalTimeToLive = tTarget3EmitterTTL2;
            tTarget3Emitter2.Position           = new Vector3(0, 0, 10);
            tTarget3Emitter2.Direction          = new Vector3(0, 0, 0);
            tTarget3Emitter2.EmitsName          = tTarget3Emitter1.Name;
            tTarget3Emitter2.EmitsType          = MParticleUniverse.Particle.ParticleType.PT_EMITTER;
            tTarget3Emitter2.ForceEmission      = true;
            tTarget3Emitter2.Name = "tTarget3Emitter2_Base";

            MParticleUniverse.ParticleAffectors.LinearForceAffector tTarget3LinearForceAffector = (MParticleUniverse.ParticleAffectors.LinearForceAffector)tTarget3.CreateAffector("LinearForce");
            tTarget3LinearForceAffector.AddEmitterToExclude(tTarget3Emitter2.Name);
            tTarget3LinearForceAffector.ForceVector = new Vector3(0, -30, 0);

            ParticleTechnique tTarget4 = puLightningBolt.CreateTechnique();

            tTarget4.MaterialName = "BaseWhite";
            tTarget1.SetRenderer("Sphere");
            //MParticleUniverse.ParticleRenderers.SphereRenderer tTarget4Renderer = (MParticleUniverse.ParticleRenderers.SphereRenderer)tTarget1.GetRenderer();
            MParticleUniverse.ParticleEmitters.BoxEmitter tTarget4Emitter = (MParticleUniverse.ParticleEmitters.BoxEmitter)tTarget4.CreateEmitter("Box");
            tTarget4Emitter.Position = new Vector3(0, 0, 0);
            DynamicAttributeFixed tTarget4EmitterTTL = new DynamicAttributeFixed();

            tTarget4EmitterTTL.SetValue(10);
            tTarget4Emitter.DynTotalTimeToLive = tTarget4EmitterTTL;
            DynamicAttributeFixed tTarget4EmitterVelocity = new DynamicAttributeFixed();

            tTarget4EmitterVelocity.SetValue(1);
            tTarget4Emitter.DynVelocity = tTarget4EmitterVelocity;
            DynamicAttributeFixed tTarget4EmitterDim = new DynamicAttributeFixed();

            tTarget4EmitterDim.SetValue(0.5f);
            tTarget4Emitter.DynParticleAllDimensions = tTarget4EmitterDim;
            tTarget4Emitter.Width  = 10;
            tTarget4Emitter.Height = 10;
            tTarget4Emitter.Depth  = 10;

            //extern                                  PhysXActor
            //    physx_shape                         Sphere
            //        shape_group                     2
        }