Exemplo n.º 1
0
        public async Task InitParticleSubSystemComponent(EngineNS.GamePlay.Actor.GActor actor, GParticleComponent particlecomponent, CGfxParticleSystem sys)
        {
            var rc = EngineNS.CEngine.Instance.RenderContext;

            ParticleModifier = new CGfxParticleModifier();
            ParticleModifier.SetParticleSystem(sys);

            GMeshComponentInitializer initializer = new GMeshComponentInitializer();

            await SetInitializer(rc, actor, particlecomponent, initializer);

            SpecialName       = string.IsNullOrEmpty(sys.Name) ? Guid.NewGuid().ToString() : sys.Name;
            EditorVisibleName = sys.EditorVisibleName;
            particlecomponent.AddComponent(this);

            Host = actor;

            var mPlacementData = Placement.mPlacementData;

            Placement = new GParticlePlacementComponent();
            await Placement.SetInitializer(rc, actor, this, mPlacementData as GComponentInitializer);

            Placement.SetMatrix(ref sys.Matrix);

            ((GParticlePlacementComponent)Placement).IsIgnore = !sys.IsBind;

            sys.HostActorMesh = this;
        }
Exemplo n.º 2
0
        public override async Task <bool> SetInitializer(CRenderContext rc, GamePlay.IEntity host, IComponentContainer hostContainer, GComponentInitializer v)
        {
            var init = v as GParticleComponentInitializer;

            if (init == null)
            {
                return(false);
            }

            mParticleModifier = new Particle.CGfxParticleModifier();
            var sys = mParticleModifier.ParticleSys;

            sys.Effector = CEngine.Instance.MacrossDataManager.NewObjectGetter <McParticleEffector>(init.MacrossName);

            if (sys.Effector != null)
            {
                await sys.Effector.Get(false).InitSystem(sys, host as GamePlay.Actor.GActor, this, init);
            }

            //default..
            if (init.MeshName == null)
            {
                init.MeshName = RName.GetRName("ParticleResource/models/sphere.gms");
            }

            if (false == await base.SetInitializer(rc, host, hostContainer, v))
            {
                return(false);
            }

            sys.HostActor = Host;

            if (sys.UseMaterialRName != null)
            {
                await SetMaterialInstance(rc, 0, sys.UseMaterialRName, null);
            }

            if (this.SceneMesh != null && this.SceneMesh.MdfQueue != null)
            {
                this.SceneMesh.MdfQueue.AddModifier(mParticleModifier);
            }

            //Box
            {
                BoundingBox.Merge(ref Host.LocalBoundingBox, ref sys.AABB.Box, out Host.LocalBoundingBox);
                OnUpdateDrawMatrix(ref Host.Placement.mDrawTransform);
            }
            return(true);
        }