示例#1
0
        /// <summary>
        /// 自己的加载资源函数(仅调用一次)
        /// </summary>
        private void MyFKGameLoadContent()
        {
            // 创建渲染设备状态列表
            m_DeviceStatesList = new GraphicsDeviceStateStack(GraphicsDevice);
            // 加载自定义字体
            m_DeafultFont = Content.Load <SpriteFont>("Font\\DefaultFont");
            // 创建背景图片
            m_DeafaultBGImg = new Texture2D(m_Graphics.GraphicsDevice, 1, BACKGROUND_IMG_LINE_NUM);
            var gradientColor = new Color[BACKGROUND_IMG_LINE_NUM];

            for (var i = 0; i < BACKGROUND_IMG_LINE_NUM; i++)
            {
                var val = Remap((float)i / BACKGROUND_IMG_LINE_NUM, 0f, 1f, 0.3f, 0.75f);
                gradientColor[i] = new Color(val, val, val, 1f);
            }
            m_DeafaultBGImg.SetData(gradientColor);
            // 加载模型
            var ModelNamesList  = Utils.GetModelFileNameList();
            var ModelChunksList = new List <Chunk>();

            foreach (var model in ModelNamesList)
            {
                var chunk = Content.Load <Chunk>("VoxModel\\" + model);
                ModelChunksList.Add(chunk);
                chunk.Position = -chunk.Center();
            }
            // 创建ShadowMap
            m_ShadowMap = new DirectionalShadowMap(GraphicsDevice);
            // 创建GameState
            m_GameState = new FKGameState(ModelNamesList, ModelChunksList);
        }
示例#2
0
        protected override void LoadContent()
        {
            base.LoadContent();

            _deviceState = new GraphicsStateStack(GraphicsDevice);

            _spriteBatch = new SpriteBatch(_graphics.GraphicsDevice);
            _font        = Content.Load <SpriteFont>("font");

            // nice gradient background
            const int resolution = 30;

            _background = new Texture2D(_graphics.GraphicsDevice, 1, resolution);
            var gradient = new Color[resolution];

            for (var i = 0; i < resolution; i++)
            {
                var val = Remap((float)i / resolution, 0f, 1f, 0.3f, 0.75f);
                gradient[i] = new Color(val, val, val, 1f);
            }
            _background.SetData(gradient);

            var modelNames = new List <string>();

            modelNames.Add("3x3x3");
            modelNames.Add("8x8x8");
            modelNames.Add("castle");
            modelNames.Add("chr_knight");
            modelNames.Add("chr_old");
            modelNames.Add("chr_rain");
            modelNames.Add("chr_sword");
            modelNames.Add("doom");
            modelNames.Add("ephtracy");
            modelNames.Add("menger");
            modelNames.Add("monu1");
            modelNames.Add("monu9");
            modelNames.Add("nature");
            modelNames.Add("shelf");
            modelNames.Add("teapot");

            var modelChunks = new List <Chunk>();

            foreach (var model in modelNames)
            {
                var chunk = Content.Load <Chunk>(model);
                modelChunks.Add(chunk);
                chunk.Position = -chunk.Center;
            }

            _shadowMap = new DirectionalShadowMap(GraphicsDevice);

            State = new VoxViewerState(this, modelNames, modelChunks);
        }