コード例 #1
0
ファイル: MazeBehavior.cs プロジェクト: ulisses177/Work
        public override void Initialize()
        {
            maze = new Maze(mazewidth, mazeheight);
            rec  = new RecursiveBacktracer(maze);

            TImage image = new TImage(maze.Texture, mazewidth * 2 + 1, mazeheight * 2 + 1);

            MaterialDX11 material = new MaterialDX11("vDefault.cso", "pUnlit.cso");

            SamplerState state = new SamplerState(ApplicationDX11.Instance.Device, new SamplerStateDescription()
            {
                AddressU           = TextureAddressMode.Wrap,
                AddressV           = TextureAddressMode.Wrap,
                AddressW           = TextureAddressMode.Wrap,
                BorderColor        = new Color4(0.0f, 1.0f, 0.0f, 1.0f),
                ComparisonFunction = Comparison.LessEqual,
                Filter             = Filter.MinLinearMagMipPoint,
                MaximumAnisotropy  = 0,
                MaximumLod         = 0,
                MinimumLod         = 0,
                MipLodBias         = 0
            });

            material.samplers.Add(state);
            material.AddTexture(image.GetTexture2D());


            Entity.AddComponent(new MeshRenderer(material, Quad.GetMesh()));
        }
コード例 #2
0
ファイル: MazeBehavior.cs プロジェクト: ulisses177/Work
 public override void Update()
 {
     if (start)
     {
         rec.DoOneStep();
         TImage   image = new TImage(maze.Texture, mazewidth * 2 + 1, mazeheight * 2 + 1);
         Resource tex   = image.GetTexture2D();
         ((MeshRenderer)Entity.GetComponent(ComponentType.MeshRenderer)).material_.SetTexture(0, tex);
         Utilities.Dispose <Resource>(ref tex);
     }
 }
コード例 #3
0
        public void Init(int width, int height)
        {
            Width  = width;
            Height = width;

            m_renderer           = Entity.AddComponent <MeshRenderer>();
            m_renderer.model_    = Quad.GetMesh();
            m_renderer.material_ = new MaterialDX11();

            m_image = new TImage(Width, Height);
            SamplerState state = new SamplerState(ApplicationDX11.Instance.Device, new SamplerStateDescription()
            {
                AddressU           = TextureAddressMode.Wrap,
                AddressV           = TextureAddressMode.Wrap,
                AddressW           = TextureAddressMode.Wrap,
                BorderColor        = new Color4(0.0f, 1.0f, 0.0f, 1.0f),
                ComparisonFunction = Comparison.LessEqual,
                Filter             = Filter.MinLinearMagMipPoint,
                MaximumAnisotropy  = 0,
                MaximumLod         = 0,
                MinimumLod         = 0,
                MipLodBias         = 0
            });

            for (int i = 0; i < m_image.Width; i++)
            {
                for (int j = 0; j < m_image.Height; j++)
                {
                    m_image.SetPixel(j, i, 1.0f, 0.0f, 0.0f, 1.0f);
                }
            }
            m_renderer.material_.samplers.Add(state);
            m_renderer.material_.AddTexture(m_image.GetTexture2D());

            GeneratePerlinNoise();
        }