Beispiel #1
0
        public ModelObject autoMotion(ModelObject myball, int seed)
        {
            Random random = new Random(seed);
            //GameTime gameTime = new GameTime();
            float waitTime = 400;
            //timer += (float)gameTime.ElapsedGameTime.TotalMilliseconds;

            if (myball.gravity.finishBouncing == true)
            {
                myball.gravity.Direction = random.Next(0, 7);
                myball.gravity.finishBouncing = false;
            }

            //-1 = bounce infinitely
            myball.yloc = fullGravity(myball.gravity, -1);

            if (timer < waitTime)
            {
            }

            //hop in place

            //increment timer and set Y direction to equal to gravity calculation.
            //timer++;
            myball.direction = myball.yloc;
            return myball;
        }
Beispiel #2
0
        // "DrawModel()": Draws the model and textures for the model.
        public void DrawModel(modelMatrix modMatrix, ModelObject theModel)
        {
            Matrix[] transforms = new Matrix[theModel.model.Bones.Count];
            theModel.model.CopyAbsoluteBoneTransformsTo(transforms);
            int j = 0;

            foreach (ModelMesh mesh in theModel.model.Meshes)
            {
                foreach (Effect currentEffect in mesh.Effects)
                {
                    Matrix wMatrix = transforms[mesh.ParentBone.Index] * modMatrix.worldMatrix; // Model + motion.
                    //Matrix wMatrix = transforms[mesh.ParentBone.Index]; // Model draw only.
                    currentEffect.CurrentTechnique = currentEffect.Techniques["Textured"]; // Specifies the loading of textures onto model.
                    currentEffect.Parameters["xWorld"].SetValue(wMatrix);
                    currentEffect.Parameters["xView"].SetValue(modMatrix.viewMatrix);
                    currentEffect.Parameters["xProjection"].SetValue(modMatrix.projectionMatrix);
                    currentEffect.Parameters["xEnableLighting"].SetValue(true); // Enables lighting.
                    currentEffect.Parameters["xLightDirection"].SetValue(new Vector3(3, -2, 5)); // Sets the direction of the light.
                    currentEffect.Parameters["xAmbient"].SetValue(0.5f);
                    currentEffect.Parameters["xTexture"].SetValue(theModel.textures[j++]); // Apply the textures.
                }
                mesh.Draw(); // Draws the mesh.
            }
        }
Beispiel #3
0
        // "initModel": Sets up the initial model for other model objects.
        private ModelObject initModel(int x, int z)
        {
            ModelObject thismodel = new ModelObject();
            thismodel.startPos = new Vector3(x, 0, z);
            thismodel.direction = Vector3.Zero;
            thismodel.gravity = new ball();
            //VINIT_VELOCITY
            thismodel.gravity.distance = new Vector3();
            thismodel.gravity.Vinit = 0.8f;
            thismodel.gravity.distance.Y = 0;
            thismodel.gravity.velocity = 0;
            thismodel.gravity.acc = -0.01f;
            thismodel.gravity.time = 0;
            thismodel.gravity.isfalling = false;
            thismodel.gravity.reverse = false;
            thismodel.gravity.hasBounced = false;
            thismodel.gravity.finishBouncing = false;

            return thismodel;
        }
Beispiel #4
0
        protected override void Update(GameTime gameTime)
        {
            keyState = Keyboard.GetState(); // Gets the current keyboard state.
            inputState.UpdateInput(cameraPosition); // Checks the keyboard input and executes the proper action.

            // If the Escape Key is pressed...
            if (keyState.IsKeyDown(Keys.Escape))
            {
                this.Exit(); // Exit program.
            }

            // Disables the music.
            if (keyState.IsKeyDown(Keys.LeftControl))
            {
                mymenu.songString = inputState.displayString;
                mymenu.songEnabled = true;
            }

            // Resets the camera position to default.
            if (keyState.IsKeyDown(Keys.LeftAlt))
            {
                cameraPosition = new Vector3(0, 0, 250);
            }

            // If the Enter Key is pressed...
            if (keyState.IsKeyDown(Keys.Enter))
            {
                // Enables the flag to load the stage and character models.
                if (loadStart == true)
                {
                    inputState.soundEffects("Enter"); // Outputs the "Enter" select sound effect.
                    loading = true;
                }
            }

            // If the inputted key involves changes with the camera, update the camera.
            if (inputState.isCameraUpdate == true)
            {
                UpdateCamera(); // Update the camera position.
            }

            MouseState aMouse = Mouse.GetState(); // Gets the current mouse state.
            mymenu.checkTint(aMouse); // Do the tinting on the mouse.
            mPreviousMouseState = aMouse;  // Store the previous mouse state

            // Check model locations and update accordingly.
            output = testrandom.Next();
            Mario = objAI.autoMotion(Mario, output);
            output = testrandom.Next();
            DonkeyKong = objAI1.autoMotion(DonkeyKong, output);
            output = testrandom.Next();
            Kirby = objAI2.autoMotion(Kirby, output);
            output = testrandom.Next();
            Ness = objAI3.autoMotion(Ness, output);
            output = testrandom.Next();
            Fox = objAI4.autoMotion(Fox, output);
            output = testrandom.Next();
            Peach = objAI5.autoMotion(Peach, output);
            output = testrandom.Next();
            Mario1 = objAI.autoMotion(Mario1, output);
            output = testrandom.Next();
            Mario2 = objAI1.autoMotion(Mario2, output);
            output = testrandom.Next();
            Mario3 = objAI2.autoMotion(Mario3, output);
            output = testrandom.Next();

            base.Update(gameTime);
        }
Beispiel #5
0
        // "Initialize()": Allows the game to perform any initialization it needs to before starting to run.
        // This is where it can query for any required services and load any non-graphic
        // related content. Calling base.Initialize will enumerate through any components
        // and initialize them as well.
        protected override void Initialize()
        {
            // Graphics initializer variables.
            graphics.PreferredBackBufferWidth = 1024; // Window width.
            graphics.PreferredBackBufferHeight = 768; // Window height.
            graphics.IsFullScreen = false; // Used to set the application to fullscreen or windowed mode.
            graphics.ApplyChanges(); // Updates the graphics with the updated changes.
            Window.Title = "Super Smash Bros. Brawl Model Viewer v0.50 (WIP) - NOT FOR PUBLIC RELEASE"; // Title of the window application.

            // Initialize the 3D stage models.
            Skybox = new ModelObject(); // Main stage model.
            Skybox.startPos = new Vector3(0, 0, 0); // Starting coordinates.
            Skybox1 = new ModelObject(); // Additional stage objects.
            Skybox1.startPos = new Vector3(0, 0, 0);
            FinalDest = new ModelObject(); // Final Destination model coordinates.
            FinalDest.startPos = new Vector3(0, 0, 0);

            // Initialize the 3D character models.
            //Mario = new ModelObject();
            //Mario.startPos = new Vector3(0, 0, 0);
            Mario = initModel(0, 0);
            Mario.startPos = new Vector3(0, -1, 0); // Used to correct position on Y.
            DonkeyKong = initModel(40, 0);
            DonkeyKong.startPos = new Vector3(40, 10, 0); // Used to correct position on Y.
            Kirby = initModel(80, 0);
            Kirby.startPos = new Vector3(80, 10, 90); // Used to correct position on Y & Z.
            Mario1 = initModel(20, 0); // Load an additional Mario.
            Mario2 = initModel(40, 0); // Load an additional Mario.
            Mario3 = initModel(-40, 0);
            Ness = initModel(-40, 0);
            Ness.startPos = new Vector3(-40, -2, 0); // Used to correct position on Y.
            Peach = initModel(-80, 0);
            Peach.startPos = new Vector3(-80, -1, 0); // Used to correct position on Y.
            Fox = initModel(-60, 0);
            Fox.startPos = new Vector3(-60, 7, 0); // Used to correct position on Y.

            // Input initializer variables.
            keyState = Keyboard.GetState(); // Retrive the keyboard status.
            this.IsMouseVisible = true;

            // Initialize the matrix object.
            mMatrix.worldMatrix = new Matrix();
            mMatrix.viewMatrix = new Matrix();
            mMatrix.projectionMatrix = new Matrix();

            // Initialize the menu.
            mymenu.init();

            base.Initialize();
        }
Beispiel #6
0
        protected override void Update(GameTime gameTime)
        {
            keyState = Keyboard.GetState();         // Gets the current keyboard state.
            inputState.UpdateInput(cameraPosition); // Checks the keyboard input and executes the proper action.

            // If the Escape Key is pressed...
            if (keyState.IsKeyDown(Keys.Escape))
            {
                this.Exit(); // Exit program.
            }

            // Disables the music.
            if (keyState.IsKeyDown(Keys.LeftControl))
            {
                mymenu.songString  = inputState.displayString;
                mymenu.songEnabled = true;
            }

            // Resets the camera position to default.
            if (keyState.IsKeyDown(Keys.LeftAlt))
            {
                cameraPosition = new Vector3(0, 0, 250);
            }

            // If the Enter Key is pressed...
            if (keyState.IsKeyDown(Keys.Enter))
            {
                // Enables the flag to load the stage and character models.
                if (loadStart == true)
                {
                    inputState.soundEffects("Enter"); // Outputs the "Enter" select sound effect.
                    loading = true;
                }
            }

            // If the inputted key involves changes with the camera, update the camera.
            if (inputState.isCameraUpdate == true)
            {
                UpdateCamera(); // Update the camera position.
            }

            MouseState aMouse = Mouse.GetState(); // Gets the current mouse state.

            mymenu.checkTint(aMouse);             // Do the tinting on the mouse.
            mPreviousMouseState = aMouse;         // Store the previous mouse state

            // Check model locations and update accordingly.
            output     = testrandom.Next();
            Mario      = objAI.autoMotion(Mario, output);
            output     = testrandom.Next();
            DonkeyKong = objAI1.autoMotion(DonkeyKong, output);
            output     = testrandom.Next();
            Kirby      = objAI2.autoMotion(Kirby, output);
            output     = testrandom.Next();
            Ness       = objAI3.autoMotion(Ness, output);
            output     = testrandom.Next();
            Fox        = objAI4.autoMotion(Fox, output);
            output     = testrandom.Next();
            Peach      = objAI5.autoMotion(Peach, output);
            output     = testrandom.Next();
            Mario1     = objAI.autoMotion(Mario1, output);
            output     = testrandom.Next();
            Mario2     = objAI1.autoMotion(Mario2, output);
            output     = testrandom.Next();
            Mario3     = objAI2.autoMotion(Mario3, output);
            output     = testrandom.Next();

            base.Update(gameTime);
        }