Example #1
0
        override public void DrawModel(Renderer.Camera camera, Vector3 drawPosition, Color drawColor, bool isEnlightend, float lightPower)
        {
            drawPosition = new Vector3(drawPosition.X, drawPosition.Y, drawPosition.Z + Vars_Func.getNestParams(typ).X);

            Matrix modelMatrix = Matrix.Identity *
                                 Matrix.CreateScale(Vars_Func.getNestParams(typ).Y) *
                                 Matrix.CreateRotationX(Vars_Func.getNestParams(typ).Z) *
                                 Matrix.CreateRotationY(0) *
                                 Matrix.CreateRotationZ(0) *
                                 Matrix.CreateTranslation(drawPosition);

            Vars_Func.getNestModell(typ).Color = drawColor;
            Vars_Func.getNestModell(typ).Draw(camera, modelMatrix, !(drawColor.Equals(Color.White)), isEnlightend, lightPower / 2);


            if (typ == Vars_Func.NestTyp.Farm)
            {
                Vars_Func.getFarmInput().Color = drawColor;
                float   zValue      = MathHelper.Lerp(0.3f, -0.1f, ((float)(Player.Food) / 3000));
                Vector3 farmPostion = new Vector3(drawPosition.X, drawPosition.Y, drawPosition.Z - zValue);
                Matrix  farmMatrix  = Matrix.Identity *
                                      Matrix.CreateScale(Vars_Func.getNestParams(typ).Y) *
                                      Matrix.CreateRotationX(Vars_Func.getNestParams(typ).Z) *
                                      Matrix.CreateRotationY(0) *
                                      Matrix.CreateRotationZ(0) *
                                      Matrix.CreateTranslation(farmPostion);
                Vars_Func.getFarmInput().Draw(camera, farmMatrix, !(drawColor.Equals(Color.White)), isEnlightend, lightPower / 2);
            }

            else if (typ == Vars_Func.NestTyp.Temple)
            {
                Vars_Func.getTempelBath().Color  = drawColor;
                Vars_Func.getTempelStone().Color = drawColor;

                float zRoationSpeed = MathHelper.Lerp(0.1f, 1, ((float)(Player.Mana) / 30000));
                rotationSpeed += zRoationSpeed;

                Matrix tempelMatrix = Matrix.Identity *
                                      Matrix.CreateScale(Vars_Func.getNestParams(typ).Y) *
                                      Matrix.CreateRotationX(Vars_Func.getNestParams(typ).Z) *
                                      Matrix.CreateRotationY(0) *
                                      Matrix.CreateRotationZ(rotationSpeed) *
                                      Matrix.CreateTranslation(drawPosition);
                Vars_Func.getTempelStone().Draw(camera, tempelMatrix, !(drawColor.Equals(Color.White)), isEnlightend, lightPower / 2);

                Vector3 tempelBathPosition = new Vector3(drawPosition.X, drawPosition.Y, drawPosition.Z + 1f);
                Matrix  tempelBathMatrix   = Matrix.Identity *
                                             Matrix.CreateScale(10) *
                                             Matrix.CreateRotationX(Vars_Func.getNestParams(typ).Z) *
                                             Matrix.CreateRotationY(0) *
                                             Matrix.CreateRotationZ(0) *
                                             Matrix.CreateTranslation(tempelBathPosition);
                Vars_Func.getTempelBath().Draw(camera, tempelBathMatrix, !(drawColor.Equals(Color.White)), isEnlightend, lightPower / 2);
            }
        }
Example #2
0
        override public void DrawModel(Renderer.Camera camera, Vector3 drawPosition, Color drawColor, bool isEnlightend, float lightPower)
        {
            Matrix modelMatrix = Matrix.Identity *
                                 Matrix.CreateScale(1) *
                                 Matrix.CreateRotationX(0 /*MathHelper.PiOver2*/) *
                                 Matrix.CreateRotationY(0) *
                                 Matrix.CreateRotationZ(0) *
                                 Matrix.CreateTranslation(drawPosition);

            Logic.Vars_Func.getWallModell(typ).Color = drawColor;
            Texture2D externalText = null;

            float percent = ((float)hp / initHP);

            if (percent <= 0.25f)
            {
                switch (typ)
                {
                case Vars_Func.WallTyp.Stone:
                    externalText = Vars_Func.getWall_RockTexture(2);
                    break;

                case Vars_Func.WallTyp.Gold:
                    externalText = Vars_Func.getWall_GoldTexture(2);
                    break;

                case Vars_Func.WallTyp.Diamond:
                    externalText = Vars_Func.getWall_DiamondTexture(2);
                    break;
                }
            }
            if (percent <= 0.5f)
            {
                switch (typ)
                {
                case Vars_Func.WallTyp.Stone:
                    externalText = Vars_Func.getWall_RockTexture(1);
                    break;

                case Vars_Func.WallTyp.Gold:
                    externalText = Vars_Func.getWall_GoldTexture(1);
                    break;

                case Vars_Func.WallTyp.Diamond:
                    externalText = Vars_Func.getWall_DiamondTexture(1);
                    break;
                }
            }
            if (percent <= 0.75f)
            {
                switch (typ)
                {
                case Vars_Func.WallTyp.Stone:
                    externalText = Vars_Func.getWall_RockTexture(0);
                    break;

                case Vars_Func.WallTyp.Gold:
                    externalText = Vars_Func.getWall_GoldTexture(0);
                    break;

                case Vars_Func.WallTyp.Diamond:
                    externalText = Vars_Func.getWall_DiamondTexture(0);
                    break;
                }
            }
            Logic.Vars_Func.getWallModell(typ).DrawTexture(camera, modelMatrix, externalText, !(drawColor.Equals(Color.White)), isEnlightend, lightPower);
        }
Example #3
0
        public void DrawModel(Renderer.Camera camera, Vector3 drawPosition)
        {
            if (currentDrawPosition != drawPosition)
            {
                currentDrawPosition = drawPosition;
            }
            Matrix modelMatrix = Matrix.Identity *
                                 Matrix.CreateScale(1) *
                                 Matrix.CreateRotationX(0) *
                                 Matrix.CreateRotationY(0) *
                                 Matrix.CreateRotationZ(0) *
                                 Matrix.CreateTranslation(drawPosition + new Vector3(0.0f, 0.0f, 0));

            Logic.Vars_Func.getHexagonModell(typ).Color = drawColor;
            Logic.Vars_Func.getHexagonModell(typ).Draw(camera, modelMatrix, !(drawColor.Equals(Color.White)), isEnlightend, lightPower);

            if (obj != null)
            {
                obj.DrawModel(camera, drawPosition, drawColor, isEnlightend, lightPower);
            }
            if (obj == null && imps.Count > 0)
            {
                imps[0].DrawModel(camera, drawPosition, drawColor, isEnlightend, lightPower);
            }
            //if (obj != null && imps.Count > 0) imps[0].DrawModel(camera, drawPosition, drawColor, isEnlightend, lightPower);

            if (targetFlag)
            {
                Matrix modelMatrix2 = Matrix.Identity *
                                      Matrix.CreateScale(1) *
                                      Matrix.CreateRotationX(0) *
                                      Matrix.CreateRotationY(0) *
                                      Matrix.CreateRotationZ(0) *
                                      Matrix.CreateTranslation(drawPosition);
                Logic.Vars_Func.getTargetFlag().Color = drawColor;
                Logic.Vars_Func.getTargetFlag().Draw(camera, modelMatrix2, !(drawColor.Equals(Color.White)), isEnlightend, lightPower);
            }

            switch (growObject)
            {
            case Logic.Vars_Func.GrowObject.Farm:
                drawPosition = new Vector3(drawPosition.X, drawPosition.Y, drawPosition.Z + Logic.Vars_Func.getGrowObjectParams(growObject).X);
                Matrix farmModelMatrix = Matrix.Identity *
                                         Matrix.CreateScale(Logic.Vars_Func.getGrowObjectParams(growObject).Y) *
                                         Matrix.CreateRotationX(Logic.Vars_Func.getGrowObjectParams(growObject).Z) *
                                         Matrix.CreateRotationY(0) *
                                         Matrix.CreateRotationZ(0) *
                                         Matrix.CreateTranslation(drawPosition);
                Logic.Vars_Func.getGrowModel(growObject).Color = drawColor;
                Logic.Vars_Func.getGrowModel(growObject).Draw(camera, farmModelMatrix, !(drawColor.Equals(Color.White)), isEnlightend, lightPower / 2);
                break;

            case Logic.Vars_Func.GrowObject.Temple:
                //drawPosition = new Vector3(drawPosition.X, drawPosition.Y, drawPosition.Z + Logic.Vars_Func.getGrowObjectParams(growObject).X);
                //Matrix templeModelMatrix = Matrix.Identity *
                //Matrix.CreateScale(Logic.Vars_Func.getGrowObjectParams(growObject).Y) *
                //Matrix.CreateRotationX(Logic.Vars_Func.getGrowObjectParams(growObject).Z) *
                //Matrix.CreateRotationY(0) *
                //Matrix.CreateRotationZ(0) *
                //Matrix.CreateTranslation(drawPosition);
                //Logic.Vars_Func.getGrowModel(growObject).Color = drawColor;
                //Logic.Vars_Func.getGrowModel(growObject).Draw(camera, templeModelMatrix, false, isEnlightend, lightPower/2);
                break;

            case Logic.Vars_Func.GrowObject.Graveyard:
                drawPosition = new Vector3(drawPosition.X, drawPosition.Y, drawPosition.Z + Logic.Vars_Func.getGrowObjectParams(growObject).X);
                Matrix graveyardModelMatrix = Matrix.Identity *
                                              Matrix.CreateScale(Logic.Vars_Func.getGrowObjectParams(growObject).Y) *
                                              Matrix.CreateRotationX(Logic.Vars_Func.getGrowObjectParams(growObject).Z) *
                                              Matrix.CreateRotationY(0) *
                                              Matrix.CreateRotationZ(0) *
                                              Matrix.CreateTranslation(drawPosition);
                Logic.Vars_Func.getGrowModel(growObject).Color = drawColor;
                Logic.Vars_Func.getGrowModel(growObject).Draw(camera, graveyardModelMatrix, !(drawColor.Equals(Color.White)), isEnlightend, lightPower / 2);
                break;

            case Logic.Vars_Func.GrowObject.length:
                break;
            }

            #region Draw Fireball
            if (fireBalls.Count > 0)
            {
                System.Diagnostics.Debug.WriteLine(fireBalls.Count);
                for (int i = fireBalls.Count - 1; i >= 0; i--)
                {
                    FireBallModel fireBall = fireBalls[i];
                    // Draw the fireball
                    Vector3 fireBallPostion = new Vector3(drawPosition.X, drawPosition.Y, drawPosition.Z + fireBall.Z);
                    Matrix  fireBallMatrix  = Matrix.Identity *
                                              Matrix.CreateScale(fireBall.Scale) *
                                              Matrix.CreateRotationX(0) *
                                              Matrix.CreateRotationY(0) *
                                              Matrix.CreateRotationZ(fireBall.RotationZ) *
                                              Matrix.CreateTranslation(fireBallPostion);
                    fireBall.Color = drawColor;
                    fireBall.Draw(camera, fireBallMatrix);

                    // Draw the all the ball's fire
                    foreach (FireBallModel fire in fireBall.Fires)
                    {
                        Vector3 firePositon = new Vector3(fireBallPostion.X, fireBallPostion.Y, fireBallPostion.Z + fire.Z);
                        Matrix  fireMatrix  = Matrix.Identity *
                                              Matrix.CreateScale(fire.Scale) *
                                              Matrix.CreateRotationX(0) *
                                              Matrix.CreateRotationY(0) *
                                              Matrix.CreateRotationZ(fire.RotationZ) *
                                              Matrix.CreateTranslation(firePositon);
                        fire.Color = drawColor;
                        fire.Draw(camera, fireMatrix);
                    }
                    if (fireBallPostion.Z < 0)
                    {
                        fireBall.Remove();
                        fireBalls.Remove(fireBall);
                    }
                }
            }
            #endregion

            if (!isEntrance && !isHQ)
            {
                foreach (FireModel fire in fireModels)
                {
                    if (fire != null)
                    {
                        Matrix fireModelMatrix = Matrix.Identity *
                                                 Matrix.CreateScale(1) *
                                                 Matrix.CreateRotationX(0) *
                                                 Matrix.CreateRotationY(0) *
                                                 Matrix.CreateRotationZ(0) *
                                                 Matrix.CreateTranslation(drawPosition + new Vector3(0.0f, 0.0f, fire.Z));
                        fire.Draw(camera, fireModelMatrix);
                    }
                }
                if (isStartLight)
                {
                    Logic.Vars_Func.getTorchModel().Color = drawColor;
                    Logic.Vars_Func.getTorchModel().Draw(camera, modelMatrix, !(drawColor.Equals(Color.White)), isEnlightend, lightPower / 2);
                }
            }
            else if (isEntrance)
            {
                //Draw God's Ray
                Matrix rayModelMatrix = Matrix.Identity *
                                        Matrix.CreateScale(Logic.Vars_Func.getEntranceRayModel().Scale) *
                                        Matrix.CreateRotationX(0) *
                                        Matrix.CreateRotationY(0) *
                                        Matrix.CreateRotationZ(camera.Rotation + Logic.Vars_Func.getEntranceRayModel().RotationZ) *
                                        Matrix.CreateTranslation(drawPosition + new Vector3(0.0f, 0.0f, Logic.Vars_Func.getEntranceRayModel().PositionZ));
                Logic.Vars_Func.getEntranceRayModel().Draw(camera, rayModelMatrix);
            }
        }
Example #4
0
 //abstract public void DrawModel(Renderer.Camera camera, Vector3 drawPosition, Color drawColor);
 abstract public void DrawModel(Renderer.Camera camera, Vector3 drawPosition, Color drawColor, bool isEnlightend, float lightPower);
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            renderer.Settings.ScreenHeight = this.Height;
            renderer.Settings.ScreenWidth  = this.Width;
            camera = new Renderer.Camera(new Vector3(0.0f, 0.0f, -25.0f), new Vector3(0.0f, 1.0f, 0.0f));
            renderer.AddCamera(camera, "default");
            renderer.SetActiveCamera("default");
            //code for loading to be placed here set up and initialise the shaders
            string vertex   = System.IO.Directory.GetCurrentDirectory() + @"\test2.vert";
            string fragment = System.IO.Directory.GetCurrentDirectory() + @"\test2.frag";

            shaderindex = renderer.AddShader(vertex, fragment, "test2", true);
            if (shaderindex == -1)
            {
                //shader compile error
                MessageBox.Show("Error loading shader. Program will Close", "Load Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Exit();
                return;
            }
            vertex      = System.IO.Directory.GetCurrentDirectory() + @"\Background.vert";
            fragment    = System.IO.Directory.GetCurrentDirectory() + @"\BackgroundNoFog.frag";
            shaderindex = renderer.AddShader(vertex, fragment, "BackgroundNoFog", true);
            if (shaderindex == -1)
            {
                //shader compile error
                MessageBox.Show("Error loading shader. Program will Close", "Load Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Exit();
                return;
            }
            vertex      = System.IO.Directory.GetCurrentDirectory() + @"\Background.vert";
            fragment    = System.IO.Directory.GetCurrentDirectory() + @"\BackgroundFog.frag";
            shaderindex = renderer.AddShader(vertex, fragment, "BackgroundFog", true);
            if (shaderindex == -1)
            {
                //shader compile error
                MessageBox.Show("Error loading shader. Program will Close", "Load Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Exit();
                return;
            }
            Renderer.BufferObjects.VertexAttribute[] attribute = new Renderer.BufferObjects.VertexAttribute[3];
            attribute[0] = new Renderer.BufferObjects.VertexAttribute("position", 3, OpenTK.Graphics.OpenGL.VertexAttribPointerType.Float,
                                                                      Renderer.Vertex.Size, 0);
            attribute[1] = new Renderer.BufferObjects.VertexAttribute("normal", 3, OpenTK.Graphics.OpenGL.VertexAttribPointerType.Float,
                                                                      Renderer.Vertex.Size, Vector3.SizeInBytes);
            attribute[2] = new Renderer.BufferObjects.VertexAttribute("texcoord", 2, OpenTK.Graphics.OpenGL.VertexAttribPointerType.Float,
                                                                      Renderer.Vertex.Size, 2 * Vector3.SizeInBytes);
            Renderer.Vertex[] vertices = CreateCube();
            renderer.CreateBufferObjects(vertices, shaderindex, out testItem, out testvao, attribute);
            string textureFile = System.IO.Directory.GetCurrentDirectory() + @"\brick2.png";

            textureIndex = renderer.AddTexture(textureFile, "texture1");
            textureFile  = System.IO.Directory.GetCurrentDirectory() + @"\background.png";
            backgroundData.BackgroundTextureIndex = renderer.AddTexture(textureFile, "background");
            backgroundData.ImageHeight            = 512;
            backgroundData.ImageWidth             = 1024;
            backgroundData.KeepAspectRatio        = true;
            backgroundData.ImageRepations         = 6;
            backgroundData.ImageDistance          = 600;
            backgroundData.FogStart = 1.0f;
            backgroundData.FogEnd   = 0.0f;
            backgroundData.FogRed   = 155;
            backgroundData.FogGreen = 155;
            backgroundData.FogBlue  = 155;
        }