Exemplo n.º 1
0
        public (GeometryComponent, TransformComponent, BoundingSphereComponent) Create(GeometryModel model)
        {
            var entity = this.Entities.Create();

            var geometry  = new GeometryComponent(entity, model);
            var transform = new TransformComponent(entity, Vector3.Zero, 1.0f);
            var bounds    = new BoundingSphereComponent(entity, BoundingSphere.CreateMerged(new BoundingSphere(Vector3.Zero, 0.0f), model.Bounds).Radius);

            this.Components.Add(geometry, transform, bounds);

            return(geometry, transform, bounds);
        }
Exemplo n.º 2
0
        public (ParticleEmitterComponent, TransformComponent, BoundingSphereComponent, ForcesComponent) Create(int paticleCount)
        {
            var entity = this.Entities.Create();

            var particleEmitter = new ParticleEmitterComponent(entity, this.Device, paticleCount);
            var transform       = new TransformComponent(entity);
            var bounds          = new BoundingSphereComponent(entity, 1.0f); // Automatically adjusted by particle system
            var forces          = new ForcesComponent(entity);

            this.Components.Add(particleEmitter, transform, bounds, forces);

            return(particleEmitter, transform, bounds, forces);
        }
Exemplo n.º 3
0
        public (GeometryComponent, TransformComponent, BoundingSphereComponent, InstancingComponent instances) Create(GeometryModel model, Matrix[] instances)
        {
            var entity = this.Entities.Create();

            var geometry   = new GeometryComponent(entity, model);
            var transform  = new TransformComponent(entity, Vector3.Zero, 1.0f);
            var bounds     = new BoundingSphereComponent(entity, Merge(model.Bounds, instances).Radius);
            var instancing = InstancingComponent.Create(entity, instances);

            this.Components.Add(geometry, transform, bounds, instancing);

            return(geometry, transform, bounds, instancing);
        }
Exemplo n.º 4
0
 public void UpdateBounds(ParticleEmitterComponent component, BoundingSphereComponent bounds)
 {
     bounds.Radius = ComputeBounds(component);
     bounds.ChangeState.Change();
 }