Example #1
0
        // This function creates texture and renders models shadow to it.
        void RenderMeshToTexture(out ITexture pTex, IMesh pMesh, ITexture pMeshTex)
        {
            pResMan.CreateTexture(out pTex, null, 256, 256, E_TEXTURE_DATA_FORMAT.TDF_RGBA8, E_TEXTURE_CREATION_FLAGS.TCF_DEFAULT, E_TEXTURE_LOAD_FLAGS.TLF_FILTERING_BILINEAR);
            pRender.SetRenderTarget(pTex);
            TPoint2 coords = new TPoint2(128f, 128f);
            TPoint3 dims   = new TPoint3(256f, 256f, 1f);
            TPoint3 axis   = new TPoint3(0f, 0f, 1f);

            pRender2D.DrawMesh(pMesh, pMeshTex, ref coords, ref dims, ref axis);
            pRender.SetRenderTarget(null); // switch back to on-screen drawing
        }
Example #2
0
        void Init(IntPtr pParam)
        {
            // get subsystems

            pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_RESOURCE_MANAGER, out p_sub_sys);
            pResMan = (IResourceManager)p_sub_sys;

            pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_INPUT, out p_sub_sys);
            pInput = (IInput)p_sub_sys;
            pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_RENDER, out p_sub_sys);
            pRender = (IRender)p_sub_sys;
            pRender.GetRender2D(out pRender2D);

            // create arrays
            IEngineBaseObject pObj = null;
            pTextures = new ITexture[TexCount];
            pShadows = new ITexture[ShadowCount];
            pMeshes = new IMesh[MeshCount];

            // loading data
            pResMan.Load(RESOURCE_PATH + "sounds\\helicopter.wav", out pObj, 0);
            pSound = (ISoundSample)pObj;
            pSound.PlayEx(out pSoundChannel, E_SOUND_SAMPLE_PARAMS.SSP_LOOPED);

            for (int i = 0; i < TexCount; i++)
            {
                uint flags = TexNames[i].Contains("grass") ? (uint)(E_TEXTURE_LOAD_FLAGS.TLF_FILTERING_BILINEAR | E_TEXTURE_LOAD_FLAGS.TLF_COORDS_REPEAT) : (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_2D;
                pResMan.Load(RESOURCE_PATH + TexNames[i], out pObj, flags);
                pTextures[i] = (ITexture)pObj;
            }

            pTextures[6].SetFrameSize(256, 256); // zombie sprite splitting

            for (int i = 0; i < MeshCount; i++)
            {
                pResMan.Load(RESOURCE_PATH + MeshNames[i], out pObj, (uint)E_MESH_MODEL_LOAD_FLAGS.MMLF_FORCE_MODEL_TO_MESH);
                pMeshes[i] = (IMesh)pObj;
            }

            // render shadows
            for (int i = 0; i < MeshCount; i++)
            {
                RenderMeshToTexture(out pShadows[i], pMeshes[i], pTextures[i]);
            }

            // render rotor shadow
            pResMan.CreateTexture(out pShadows[5], null, 256, 256, E_TEXTURE_DATA_FORMAT.TDF_RGBA8, E_TEXTURE_CREATE_FLAGS.TCF_DEFAULT, E_TEXTURE_LOAD_FLAGS.TLF_FILTERING_BILINEAR);
            pRender.SetRenderTarget(pShadows[5]);
            TPoint2 coords = new TPoint2(128f, 128f);
            TColor4 col = TColor4.ColorWhite();
            pRender2D.DrawCircle(ref coords, 100, 64, ref col, E_PRIMITIVE2D_FLAGS.PF_FILL);
            pRender.SetRenderTarget(null);

            // gather, fill and init 3d-objects data
            MyMeshes = new MyMesh[8]
            {
                new MyMesh(pMeshes[0], pTextures[0], pShadows[0], new TPoint2( 900f, 500f), new TPoint3(400f, 400f, 500f), 225),
                new MyMesh(pMeshes[0], pTextures[0], pShadows[0], new TPoint2(-250f, 300f), new TPoint3(400f, 400f, 500f), 225),
                new MyMesh(pMeshes[0], pTextures[0], pShadows[0], new TPoint2( 800f, 200f), new TPoint3(400f, 400f, 400f), 225),
                new MyMesh(pMeshes[1], pTextures[1], pShadows[1], new TPoint2(   0f, 450f), new TPoint3(300f, 300f, 400f), 175),
                new MyMesh(pMeshes[1], pTextures[1], pShadows[1], new TPoint2(  50f, 750f), new TPoint3(300f, 300f, 300f), 175),
                new MyMesh(pMeshes[2], pTextures[2], pShadows[2], new TPoint2( 500f, 150f), new TPoint3(400f, 400f, 500f), 225),
                new MyMesh(pMeshes[3], pTextures[3], pShadows[3], new TPoint2( 180f, 150f), new TPoint3(400f, 400f, 600f), 200),
                new MyMesh(pMeshes[3], pTextures[3], pShadows[3], new TPoint2( 600f, 550f), new TPoint3(400f, 400f, 600f), 200, 90)
            };

            copter = new Copter(new MyMesh(pMeshes[4], pTextures[4], pShadows[4], new TPoint2(), new TPoint3(600, 600, 600), 200, 0, true), pTextures[5], pShadows[5]);
            zombie = new Zombie(pTextures[6]);
        }
Example #3
0
        void Init(IntPtr pParam)
        {
            // get subsystems

            pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_RESOURCE_MANAGER, out p_sub_sys);
            pResMan = (IResourceManager)p_sub_sys;

            pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_INPUT, out p_sub_sys);
            pInput = (IInput)p_sub_sys;
            pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_RENDER, out p_sub_sys);
            pRender = (IRender)p_sub_sys;
            pRender.GetRender2D(out pRender2D);

            // create arrays
            IEngineBaseObject pObj = null;

            pTextures = new ITexture[TexCount];
            pShadows  = new ITexture[ShadowCount];
            pMeshes   = new IMesh[MeshCount];

            // loading data
            pResMan.Load(RESOURCE_PATH + "sounds\\helicopter.wav", out pObj, 0);
            pSound = (ISoundSample)pObj;
            pSound.PlayEx(out pSoundChannel, E_SOUND_SAMPLE_PARAMS.SSP_LOOPED);

            for (int i = 0; i < TexCount; i++)
            {
                uint flags = TexNames[i].Contains("grass") ? (uint)(E_TEXTURE_LOAD_FLAGS.TLF_FILTERING_BILINEAR | E_TEXTURE_LOAD_FLAGS.TLF_COORDS_REPEAT) : (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_2D;
                pResMan.Load(RESOURCE_PATH + TexNames[i], out pObj, flags);
                pTextures[i] = (ITexture)pObj;
            }

            pTextures[6].SetFrameSize(256, 256); // zombie sprite splitting

            for (int i = 0; i < MeshCount; i++)
            {
                pResMan.Load(RESOURCE_PATH + MeshNames[i], out pObj, (uint)E_MESH_MODEL_LOAD_FLAGS.MMLF_FORCE_MODEL_TO_MESH);
                pMeshes[i] = (IMesh)pObj;
            }

            // render shadows
            for (int i = 0; i < MeshCount; i++)
            {
                RenderMeshToTexture(out pShadows[i], pMeshes[i], pTextures[i]);
            }

            // render rotor shadow
            pResMan.CreateTexture(out pShadows[5], null, 256, 256, E_TEXTURE_DATA_FORMAT.TDF_RGBA8, E_TEXTURE_CREATION_FLAGS.TCF_DEFAULT, E_TEXTURE_LOAD_FLAGS.TLF_FILTERING_BILINEAR);
            pRender.SetRenderTarget(pShadows[5]);
            TPoint2 coords = new TPoint2(128f, 128f);
            TColor4 col    = TColor4.ColorWhite();

            pRender2D.DrawCircle(ref coords, 100, 64, ref col, E_PRIMITIVE2D_FLAGS.PF_FILL);
            pRender.SetRenderTarget(null);


            // gather, fill and init 3d-objects data
            MyMeshes = new MyMesh[8]
            {
                new MyMesh(pMeshes[0], pTextures[0], pShadows[0], new TPoint2(900f, 500f), new TPoint3(400f, 400f, 500f), 225),
                new MyMesh(pMeshes[0], pTextures[0], pShadows[0], new TPoint2(-250f, 300f), new TPoint3(400f, 400f, 500f), 225),
                new MyMesh(pMeshes[0], pTextures[0], pShadows[0], new TPoint2(800f, 200f), new TPoint3(400f, 400f, 400f), 225),
                new MyMesh(pMeshes[1], pTextures[1], pShadows[1], new TPoint2(0f, 450f), new TPoint3(300f, 300f, 400f), 175),
                new MyMesh(pMeshes[1], pTextures[1], pShadows[1], new TPoint2(50f, 750f), new TPoint3(300f, 300f, 300f), 175),
                new MyMesh(pMeshes[2], pTextures[2], pShadows[2], new TPoint2(500f, 150f), new TPoint3(400f, 400f, 500f), 225),
                new MyMesh(pMeshes[3], pTextures[3], pShadows[3], new TPoint2(180f, 150f), new TPoint3(400f, 400f, 600f), 200),
                new MyMesh(pMeshes[3], pTextures[3], pShadows[3], new TPoint2(600f, 550f), new TPoint3(400f, 400f, 600f), 200, 90)
            };

            copter = new Copter(new MyMesh(pMeshes[4], pTextures[4], pShadows[4], new TPoint2(), new TPoint3(600, 600, 600), 200, 0, true), pTextures[5], pShadows[5]);
            zombie = new Zombie(pTextures[6]);
        }
Example #4
0
 public void createTexture(string name, int width, int height)
 {
     _resourceManager.CreateTexture(name, width, height);
 }