Click here to Skip to main content
15,886,026 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.4K   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 Light
    {
       TVMesh LightNode;
       TV_3DVECTOR LightDirection= new TV_3DVECTOR(0,0,0);

       public float LightRadius = 360.0f;

       public struct LightRGB
       {
           public float Red;
           public float Green;
           public float Blue;


       }
       public enum LightType
       {
           pointlight


       };
        private TVMaterialFactory Mats; 
        private TVLightEngine Lights;
        private int IDLight;


        public Light(ref TVScene Scene, LightType Type,TV_3DVECTOR LightPointPosition)
        {

            Lights = new TVLightEngine();
            LightNode = new TVMesh();
            LightNode = Scene.CreateMeshBuilder("light mark");
            LightNode.CreateSphere(0.25f, 4, 4);
            LightNode.SetPosition(LightPointPosition.x, LightPointPosition.y, LightPointPosition.z );

            if (Type == LightType.pointlight)
            {
                IDLight = Lights.CreatePointLight(LightPointPosition , 1, 1, 1, LightRadius , "simple_point_lightKonstruktor", 1);
                

            }


        }

        public void SetLightPosition(TV_3DVECTOR LightPointPosition)
        {
            LightNode.SetPosition(LightPointPosition.x, LightPointPosition.y, LightPointPosition.z);
            Lights.SetLightPosition(IDLight, LightPointPosition.x,
                LightPointPosition.y, LightPointPosition.z);


        }

        public TV_3DVECTOR GetLightPosition()
        {

            return LightNode.GetPosition();
        }

        public void SetLightDirection(TV_3DVECTOR LightPointDirection)
        {
            Lights.SetLightDirection(IDLight, LightPointDirection.x, LightPointDirection.y, LightPointDirection.z);
            LightDirection = LightPointDirection;
        }
        public TV_3DVECTOR GetLightDirection()
        {
            return LightDirection;

        }

        public void RenderLight()
        {

            LightNode.Render();
        }

    }
}

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