Exemplo n.º 1
0
        RevoluteJoint wandHinge; // Moves the wand

        #endregion Fields

        #region Constructors

        public Vehicle(MemoryBank memBank, float distance)
        {
            // Figure out the positions of the vehicle and it's sliderBase
            Vector3 position = new Vector3(memBank.Position.X, memBank.Position.Y, memBank.Position.Z + 10);
            Vector3 motorPos = new Vector3(position.X - memBank.Length - distance, position.Y, position.Z);
            byteDist = memBank.ByteDistance;
            bytes = memBank.NumberOfBytes;

            wandGoal = sliderGoal = false;
            delay = 0;

            // Build the main vechicle
            chassis = XNAGame.Instance.createVehicle(position);

            // Build the slider, and attatch
            sliderBase = new Box(motorPos, 1, 1, 1);
            slider = new PrismaticJoint(sliderBase, chassis.body, sliderBase.Position, Vector3.UnitX, chassis.body.Position);
            XNAGame.Instance.space.Add(slider);
            XNAGame.Instance.space.Add(sliderBase);

            // Change slider settings
            slider.Motor.Settings.Mode = MotorMode.Servomechanism;
            slider.Motor.Settings.Servo.SpringSettings.StiffnessConstant /= 20;
            slider.Motor.Settings.Servo.MaxCorrectiveVelocity = 200;
            slider.Motor.Settings.Servo.BaseCorrectiveSpeed = 120;

            // Create the wand
            setUpWand(position);
        }
        public Controller(Vehicle v, MemoryBank mb, string pathToSourceCode, string pathToInputs)
        {
            // Create a ByteCollection
            collection = new ByteCollection(pathToSourceCode, 300);
            collection.FilterCode();

            // Create an Interpreter
            interpreter = new Interpreter(pathToInputs, this);
            interpreter.PrepareToRun(collection);

            this.mb = mb;

            // Create a VehicleEventControl
            vec = new VehicleEventControl(interpreter.ExtractBlock(collection), v);
        }
Exemplo n.º 3
0
        void resetScene()
        {
            for (int i = 0; i < children.Count(); i++)
            {
                if (children[i] is BepuEntity)
                {
                    children.Remove(children[i]);
                    i--;
                }
            }
            space = null;
            space = new Space();
            space.ForceUpdater.Gravity = new Vector3(0, -9.8f, 0);

            groundBox = new Box(Vector3.Zero, ground.width, 0.1f, ground.height);
            groundBox.Material.KineticFriction = 2;
            space.Add(groundBox);

            cameraCylindar = new Cylinder(Camera.Position, 5, 2);
            space.Add(cameraCylindar);

            MemoryBank mb = new MemoryBank(300, new Vector3(0, 2.5f, 0), 8);
            children.Add(mb);

            Vehicle v = new Vehicle(mb, 8.0f);
            //v.FlipTo();

            controller = new Controller(v, mb, program, "input.txt");

            children.Add(v);
        }