⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmodel.cs

📁 一个Wince的小程序
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;

namespace WindowsFormsApplication1
{
    public class cModel
    {
        private Earth mesh1 = null;
        private Earth mesh2 = null;
        private bool modelloaded;
        public void Load(ref Device device)
        {
            mesh1 = new Earth(ref device);
            mesh2 = new Earth(ref device);
            if (mesh1.LoadMesh(@"..\..\earth2.x"))
            {
                modelloaded = true;
            }
            else
            {
                modelloaded = false;
            }
            if (mesh2.LoadMesh(@"..\..\moon.x"))
            {
                mesh2.XLoc += 20.0f;
                modelloaded = true;
            }
            else
            {
                modelloaded = false;
            }
        }

        public void Update(int dir)
        {
            if (dir > 0)
            {
                mesh1.YRot += 0.02f;
                mesh2.YRot += 0.05f;
            }
            else if (dir < 0)
            {
                mesh1.YRot -= 0.02f;
                mesh2.YRot -= 0.05f;
            }
        }

        public void Render(ref Device device)
        {
            device.Transform.World = Matrix.Identity;
            if (modelloaded)
            {
                mesh1.Render();
                mesh2.Render();
            }
        }

        public void LoadLights(ref Device device)
        {
            device.Lights[0].Type = LightType.Directional;
            device.Lights[0].Diffuse = Color.White;
            device.Lights[0].Position = new Vector3(0.0f, 0.0f, 25.0f);
            device.Lights[0].Direction = new Vector3(0, 0, -1);
        }
        public void Light(ref Device device)
        {
            device.Lights[0].Update();
            device.Lights[0].Enabled = true;
        }


    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -