Click here to Skip to main content
15,892,072 members
Articles / Multimedia / DirectX

Game Engine

Rate me:
Please Sign up or sign in to vote.
3.78/5 (6 votes)
20 Nov 2009CPL2 min read 47.5K   1.5K   34  
A game engine first prototype
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MTV3D65;

namespace gefx
{
   public  class Effects
    {
        private TVGraphicEffect FX = null ;     
        private TVRenderSurface Glow = null ;

        public enum EffectsType
        {
            Glow

        };


        public Effects()
        {
            FX = new TVGraphicEffect();
            



        }

        public   void InitMaterials(ref TVMaterialFactory MaterialFactory)
        {
            int matId;

            matId = MaterialFactory.CreateMaterial("Matte");
            MaterialFactory.SetAmbient(matId, 0.25f, 0.25f, 0.25f, 1);
            MaterialFactory.SetDiffuse(matId, 1, 1, 1, 1);
            MaterialFactory.SetSpecular(matId, 0, 0, 0, 1);
            MaterialFactory.SetEmissive(matId, 0, 0, 0, 1);
            MaterialFactory.SetOpacity(matId, 1);
            MaterialFactory.SetPower(matId, 0);

            matId = MaterialFactory.CreateMaterial("Shiny");
            MaterialFactory.SetAmbient(matId, 0.25f, 0.25f, 0.25f, 1);
            MaterialFactory.SetDiffuse(matId, 0.9f, 0.9f, 0.9f, 1);
            MaterialFactory.SetSpecular(matId, 1, 1, 1, 1);
            MaterialFactory.SetEmissive(matId, 0, 0, 0, 1);
            MaterialFactory.SetOpacity(matId, 1);
            MaterialFactory.SetPower(matId, 25);
        }

        public void AddEffects(EffectsType Type, ref TVScene Scene)
        {

            if (Type == EffectsType.Glow)
            {


                Glow = Scene.CreateRenderSurface(512, 512, true, CONST_TV_RENDERSURFACEFORMAT.TV_TEXTUREFORMAT_A8R8G8B8);
                FX.InitGlowEffect(Glow);
            }
        }

        public void DrawEffects()
        {

            if (Glow != null)
            {

                FX.DrawGlow();
            }

        }

        public void UpdateEffects()
        {

            if (Glow != null)
            {
                Glow.StartRender(false);
                Glow.EndRender();
                FX.UpdateGlow();

            }
        }

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Common Public License Version 1.0 (CPL)


Written By
Software Developer
Croatia Croatia
Programer

Comments and Discussions