protected override void OnEntityRemoved(Entity entity, ModelNodeLinkComponent modelNodeLinkComponent)
        {
            if (meshProcessor == null)
            {
                meshProcessor = EntitySystem.GetProcessor <MeshProcessor>();
            }

            meshProcessor.UnlinkEntity(modelNodeLinkComponent.EntityLink);

            modelNodeLinkComponent.Processor = null;
        }
Exemple #2
0
        /// <inheritdoc/>
        protected internal override void OnSystemAdd()
        {
            var rootEntities = EntitySystem.GetProcessor <HierarchicalProcessor>().RootEntities;

            ((ITrackingCollectionChanged)rootEntities).CollectionChanged += rootEntities_CollectionChanged;

            // Add transformation of existing root entities
            foreach (var entity in rootEntities)
            {
                transformationRoots.Add(entity.Transformation);
            }
        }
        protected override void OnEntityAdding(Entity entity, ModelNodeLinkComponent modelNodeLinkComponent)
        {
            entity.Transformation.UseTRS        = false;
            entity.Transformation.isSpecialRoot = true;

            modelNodeLinkComponent.Processor = this;

            if (meshProcessor == null)
            {
                meshProcessor = EntitySystem.GetProcessor <MeshProcessor>();
            }

            lock (DirtyLinks)
            {
                DirtyLinks.Add(modelNodeLinkComponent);

                // Mark it as invalid
                modelNodeLinkComponent.EntityLink.NodeIndex = -1;
            }
        }
        public override void Draw(GameTime time)
        {
            lock (DirtyLinks)
            {
                if (DirtyLinks.Count == 0)
                {
                    return;
                }

                if (meshProcessor == null)
                {
                    meshProcessor = EntitySystem.GetProcessor <MeshProcessor>();
                }

                foreach (var transformationLinkComponent in DirtyLinks)
                {
                    // ModelNodeLinkComponent has been changed, regenerate link
                    meshProcessor.UnlinkEntity(transformationLinkComponent.EntityLink);
                    meshProcessor.LinkEntity(transformationLinkComponent.Entity, transformationLinkComponent.Target, transformationLinkComponent.NodeName);
                }

                DirtyLinks.Clear();
            }
        }