Ejemplo n.º 1
0
        public VisualizerCommandSet Initialization()
        {
            var set = new VisualizerCommandSet();

            // Add all the projectiles
            foreach (var projectile in projectiles)
            {
                // Start it off in the right place
                var obj = new ObjectPrototype(projectile.Shape, new BasicMaterial(projectile.Color),
                                              projectile.Position, new Vector3D(projectile.Size, projectile.Size, projectile.Size));

                set.AddCommand(new AddObject(obj, counter));
                projectileMap.Add(counter, projectile);
                ++counter;
            }

            // Add all the connectors
            foreach (var connector in connectorMap)
            {
                // Update them first so they are in the right position
                connector.Value.Update();
                var obj = new ObjectPrototype(new VisualizerControl.Shapes.CaplessCylinder3D(),
                                              new BasicMaterial(connector.Value.Color));
                set.AddCommand(new AddObject(obj, connector.Key));
                set.AddCommand(connector.Value.GetTransformCommand(connector.Key));
            }

            return(set);
        }
Ejemplo n.º 2
0
        private void AddBox(VisualizerCommandSet set)
        {
            var obj = new ObjectPrototype(new Cube3D(), new BasicMaterial(Colors.SlateGray, true),
                                          new Vector3D(0, 0, 0), new Vector3D(.5, .5, .5));

            set.AddCommand(new AddObject(obj, counter++));
        }
        public CommandSet <VisualizerControl.Visualizer> Initialization()
        {
            var set = new VisualizerCommandSet();

            Color boxTransparentColor = Color.FromArgb((byte)80, BoxColor.R, BoxColor.G, BoxColor.B);
            var   box = new ObjectPrototype(new Cube3D(), new BasicMaterial(boxTransparentColor, .05, .3),
                                            ConvertToVector3D(container.Size / 2), ConvertToVector3D(container.Size / 2 * BoxScale));

            set.AddCommand(new AddObject(box, counter));
            ++counter;

            // Add all the particles
            foreach (var particle in container.Particles)
            {
                // Start it off in the right place
                var obj = new ObjectPrototype(new Sphere3D(2), new BasicMaterial(ConvertColor(particle.Info.Color), .05, .3),
                                              ConvertToVector3D(particle.Position), new Vector3D(ParticleSize, ParticleSize, ParticleSize));

                set.AddCommand(new AddObject(obj, counter));
                particleMap.Add(particle, counter);
                ++counter;
            }

            return(set);
        }
Ejemplo n.º 4
0
        public CommandSet <VisualizerControl.Visualizer> Initialization()
        {
            int counter = 0;
            var set     = new VisualizerCommandSet();

            foreach (var projectile in projectiles)
            {
                // Start it off in the right place
                var obj = new ObjectPrototype(projectile.Shape, new BasicMaterial(projectile.Color, .05, .3),
                                              projectile.Position, new Vector3D(projectile.Size, projectile.Size, projectile.Size));

                set.AddCommand(new AddObject(obj, counter++));
            }

            foreach (var tetrahedron in gravStruct.GetTetrahedra())
            {
                var newShape = new Tetrahedron3D(ConvertToVector3D(tetrahedron.Points[0]),
                                                 ConvertToVector3D(tetrahedron.Points[1]), ConvertToVector3D(tetrahedron.Points[2]),
                                                 ConvertToVector3D(tetrahedron.Points[3]));
                var newMaterial = new BasicMaterial(ConvertColor(tetrahedron.Color), tetrahedron.Fresnel, tetrahedron.Roughness);
                var newobj      = new ObjectPrototype(newShape, newMaterial);

                set.AddCommand(new AddObject(newobj, counter++));
            }

            return(set);
        }
Ejemplo n.º 5
0
        public VisualizerCommandSet Tick(double newTime)
        {
            var set = new VisualizerCommandSet();

            container.Update(newTime - Time);

            // Box scale
            Vector3D position = ConvertToVector3D(container.Size / 2);
            Vector3D scale    = ConvertToVector3D(container.Size / 2 * BoxScale);

            set.AddCommand(new TransformObject(0, position, scale, 0, 0));

            container.ParticlesToAdd.ForEach((particle) => AddParticle(particle, set));
            container.ParticlesToRemove.ForEach((particle) => RemoveParticle(particle, set));

            foreach (var particle in container.Particles)
            {
                int index = particleMap[particle];
                set.AddCommand(new MoveObject(index, ConvertToVector3D(particle.Position)));
            }


            Time = newTime;

            return(set);
        }
Ejemplo n.º 6
0
        private void AddGround(VisualizerCommandSet set)
        {
            const double groundSize = 10;
            string       filename   = "dirt.jpg";

            var obj = new ObjectPrototype(new Square3D(), new TextureMaterial(filename), new Vector3D(0, 0, 0), new Vector3D(groundSize, groundSize, 1));

            set.AddCommand(new AddObject(obj, counter++));
        }
Ejemplo n.º 7
0
        public VisualizerCommandSet Tick(double newTime)
        {
            Continue = engine.Tick(newTime);

            var set = new VisualizerCommandSet();

            set.AddCommand(new MoveObject(projectileIndex, engine.Projectile.Position));

            return(set);
        }
Ejemplo n.º 8
0
        private void AddParticle(Particle particle, VisualizerCommandSet set)
        {
            // Start it off in the right place
            var obj = new ObjectPrototype(new Sphere3D(), new BasicMaterial(ConvertColor(particle.Info.Color)),
                                          ConvertToVector3D(particle.Position), new Vector3D(ParticleSize, ParticleSize, ParticleSize));

            set.AddCommand(new AddObject(obj, counter));
            particleMap.Add(particle, counter);
            ++counter;
        }
Ejemplo n.º 9
0
        public VisualizerCommandSet Tick(double newTime)
        {
            Continue = arena.Update(newTime);

            var commandSet = new VisualizerCommandSet();

            for (int i = 0; i < arena.Animals.Count; ++i)
            {
                commandSet.AddCommand(new MoveObject(i, new Vector3D(arena.Animals[i].Position.X, arena.Animals[i].Position.Y, 0)));
            }

            return(commandSet);
        }
Ejemplo n.º 10
0
        public CommandSet <VisualizerControl.Visualizer> Tick(double newTime)
        {
            Continue = engine.Tick(newTime);

            var set = new VisualizerCommandSet();

            int counter = 0;

            foreach (var projectile in projectiles)
            {
                set.AddCommand(new MoveObject(counter++, projectile.Position));
            }

            return(set);
        }
Ejemplo n.º 11
0
        public VisualizerCommandSet Initialization()
        {
            var set = new VisualizerCommandSet();

            var box = new ObjectPrototype(new Cube3D(), new BasicMaterial(BoxColor, true),
                                          ConvertToVector3D(container.Size / 2), ConvertToVector3D(container.Size / 2 * BoxScale));

            set.AddCommand(new AddObject(box, counter));
            ++counter;

            // Add all the particles
            container.Particles.ForEach((particle) => AddParticle(particle, set));

            return(set);
        }
Ejemplo n.º 12
0
        public VisualizerCommandSet Initialization()
        {
            var commandSet = new VisualizerCommandSet();

            for (int i = 0; i < arena.Animals.Count; ++i)
            {
                var animal = arena.Animals[i];
                commandSet.AddCommand(new AddObject(new ObjectPrototype(new Cube3D(), i == 0 ? Colors.Blue : Colors.Red), i));
                commandSet.AddCommand(new TransformObject(i, new Vector(animal.Position.X, animal.Position.Y, 0), new Vector(animal.Width, animal.Height, animal.Width)));
            }
            commandSet.AddCommand(new AddObject(new ObjectPrototype(new Cube3D(), Colors.SandyBrown), arena.Animals.Count));
            commandSet.AddCommand(new TransformObject(arena.Animals.Count, new Vector(0, 0, 0), new Vector(arena.Width, arena.Height, .01)));
            commandSet.AddCommand(new MoveCamera(new Vector(80, 80, 80)));

            return(commandSet);
        }
        public CommandSet <VisualizerControl.Visualizer> Tick(double newTime)
        {
            var set = new VisualizerCommandSet();

            container.Update(newTime - Time);

            foreach (var particle in container.Particles)
            {
                int index = particleMap[particle];
                set.AddCommand(new MoveObject(index, ConvertToVector3D(particle.Position)));
            }

            Time = newTime;

            return(set);
        }
Ejemplo n.º 14
0
        public VisualizerCommandSet Initialization()
        {
            var set = new VisualizerCommandSet();

            if (Box)
            {
                AddBox(set);
            }

            foreach (var triangle in surfaces)
            {
                var tri = new Triangle3D(
                    UtilityFunctions.ConvertVector(triangle.Points[0]),
                    UtilityFunctions.ConvertVector(triangle.Points[1]),
                    UtilityFunctions.ConvertVector(triangle.Points[2]), true);
                var obj = new ObjectPrototype(tri, UtilityFunctions.ConvertColor(triangle.Color), triangle.IsTransparent);
                set.AddCommand(new AddObject(obj, counter++));
            }

            // Add all the projectiles
            foreach (var projectile in projectiles)
            {
                // Start it off in the right place
                var obj = new ObjectPrototype(projectile.Shape, new BasicMaterial(projectile.Color),
                                              projectile.Position, new Vector3D(projectile.Size, projectile.Size, projectile.Size));

                set.AddCommand(new AddObject(obj, counter));
                projectileMap.Add(counter, projectile);
                ++counter;
            }

            // Add all the connectors
            foreach (var connector in connectorMap)
            {
                // Update them first so they are in the right position
                connector.Value.Update();
                var obj = new ObjectPrototype(new VisualizerControl.Shapes.CaplessCylinder3D(),
                                              new BasicMaterial(connector.Value.Color));
                set.AddCommand(new AddObject(obj, connector.Key));
                set.AddCommand(connector.Value.GetTransformCommand(connector.Key));
            }

            return(set);
        }
Ejemplo n.º 15
0
        public VisualizerCommandSet Tick(double newTime)
        {
            Continue = engine.Tick(newTime);

            var set = new VisualizerCommandSet();

            // Change all the projectiles
            foreach (var entry in projectileMap)
            {
                set.AddCommand(new MoveObject(entry.Key, entry.Value.Position));
            }

            // Change all the connectors
            foreach (var connector in connectorMap)
            {
                connector.Value.Update();
                set.AddCommand(connector.Value.GetTransformCommand(connector.Key));
            }

            return(set);
        }
Ejemplo n.º 16
0
        public VisualizerCommandSet Initialization()
        {
            var set = new VisualizerCommandSet();

            var projectile = new ObjectPrototype(new Sphere3D(), new BasicMaterial(ProjectileColor),
                                                 ConvertVector(engine.Projectile.Position), new Vector3D(ProjectileSize, ProjectileSize, ProjectileSize));

            set.AddCommand(new AddObject(projectile, counter));
            projectileIndex = counter;
            ++counter;

            var shape = new FunctionShape3D(engine.Path)
            {
                CircleRadius = PathThickness
            };
            var path = new ObjectPrototype(shape, new BasicMaterial(PathColor));

            set.AddCommand(new AddObject(path, counter));

            return(set);
        }
        public VisualizerCommandSet Initialization()
        {
            var set = new VisualizerCommandSet();

            var box = new ObjectPrototype(new Cube3D(), new BasicMaterial(BoxColor, true),
                                          ConvertToVector3D(container.Size / 2), ConvertToVector3D(container.Size / 2 * BoxScale));

            set.AddCommand(new AddObject(box, counter));
            ++counter;

            // Add all the particles
            foreach (var particle in container.Particles)
            {
                // Start it off in the right place
                var obj = new ObjectPrototype(new Sphere3D(), new BasicMaterial(ConvertColor(particle.Info.Color)),
                                              ConvertToVector3D(particle.Position), new Vector3D(ParticleSize, ParticleSize, ParticleSize));

                set.AddCommand(new AddObject(obj, counter));
                particleMap.Add(particle, counter);
                ++counter;
            }

            return(set);
        }
Ejemplo n.º 18
0
        private void RemoveParticle(Particle particle, VisualizerCommandSet set)
        {
            int index = particleMap[particle];

            set.AddCommand(new RemoveObject(index));
        }