Ejemplo n.º 1
0
        private void DrawBoats(Model model, out Matrix world, GameTime gameTime, boat b)
        {
            RasterizerState rasterizerState1 = new RasterizerState();
            rasterizerState1.CullMode = CullMode.None;
            device.RasterizerState = rasterizerState1;
            Matrix matIdent, matScale, matRotY, matRotZ, matTransl;

            matIdent = Matrix.Identity;
            matScale = Matrix.CreateScale(0.005f);
            matTransl = Matrix.CreateTranslation(b.BoatPosition);
            matRotY = Matrix.CreateRotationY(b.BoatRotY);
            matRotZ = Matrix.Identity; 

            world = matIdent * matScale * matRotZ * matRotY * matTransl;
            model.CopyAbsoluteBoneTransformsTo(matrixEnemy);

            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.World = matrixEnemy[mesh.ParentBone.Index] * world;
                    effect.View = view;
                    effect.Projection = proj;
                    effect.VertexColorEnabled = false;
                }
                mesh.Draw();
            }
        }
Ejemplo n.º 2
0
        private void loadBoatObjects()
        {
            // different textures
            Textures[0] = Content.Load<Texture2D>("Textures/tex_ship_hero");    // HeroBoat
            Textures[1] = Content.Load<Texture2D>("Textures/soil_texture");    // jordtextur
            Textures[2] = Content.Load<Texture2D>("Textures/skybox_top");
            Textures[3] = Content.Load<Texture2D>("Sprites/map");

            // hero
            modelHERO = this.LoadModelWithBoundingSphere("Models/HeroShip", ref matrixHERO, ref originalTransforms1);
            HERO = new boat(10, new Vector3(5, 5, 10));
            HERO.BoatModel = modelHERO;
            (HERO.BoatModel.Meshes[0].Effects[0] as BasicEffect).EnableDefaultLighting();

            // enemy boats
            boatArray[0] = new boat(6, new Vector3(6, 0, -4));
            boatArray[1] = new boat(50, new Vector3(-8, 0, 10));
            boatArray[2] = new boat(180, new Vector3(-9, 0, 5));

            // array for setting enemy boats models
            for (int i = 0; i < boatArray.Length; i++) 
            {
                modelEnemy = this.LoadModelWithBoundingSphere("Models/EnemyShip", ref matrixEnemy, ref originalTransforms2);
                boatArray[i].BoatModel = modelEnemy; 
                (boatArray[i].BoatModel.Meshes[0].Effects[0] as BasicEffect).EnableDefaultLighting();
            }

            // load world model and load texture
            modelWorld_North = this.LoadModelWithBoundingSphere("Models/World_Northnew", ref matrixWorld_North, ref originalTransforms2);
            modelWorld_East = this.LoadModelWithBoundingSphere("Models/World_Eastnew", ref matrixWorld_East, ref originalTransforms3);
            modelWorld_West = this.LoadModelWithBoundingSphere("Models/World_Westnew", ref matrixWorld_West, ref originalTransforms4);
            modelWorld_South = this.LoadModelWithBoundingSphere("Models/World_Southnew", ref matrixWorld_South, ref originalTransforms5);
            modelIsland1 = this.LoadModelWithBoundingSphere("Models/Island1new", ref matrixIsland1, ref originalTransforms6);
            modelIsland2 = this.LoadModelWithBoundingSphere("Models/Island2new", ref matrixIsland2, ref originalTransforms7);
            modelIsland3 = this.LoadModelWithBoundingSphere("Models/Island3new", ref matrixIsland3, ref originalTransforms8);
            
            // skybox model 
            skyboxModel = Content.Load<Model>("Models/skybox2");
        }