예제 #1
0
        //============================================================
        public void ExportMerge(FDrModel model)
        {
            SIntSize    size   = new SIntSize(_width, _height);
            Form        form   = new Form();
            FDxDevice3D device = RDxCore.Adapter.CreateDevice(form.Handle, size.Width, size.Height);

            device.ModeWireFrame = false;
            // 设置几何体
            FDxRegion region = new FDxRegion();
            // 设置目标
            FDxBufferedTexture texture = new FDxBufferedTexture();

            texture.Device = device;
            texture.Create(size.Width, size.Height);
            device.SetRenderTarget(texture);
            // 渲染几何体
            FDxTechnique technique = RDxCore.TechniqueConsole.Get(device, "light.map");
            int          index     = 0;

            foreach (INamePair <FDrGeometry> pair in model.Mesh.GeometryDictionary)
            {
                FDrLightGeometry geometry = new FDrLightGeometry();
                geometry.Device = device;
                geometry.LoadResource(pair.Value);
                region.Renderables.Clear();
                region.Renderables.Push(geometry);
                // 绘制结果
                technique.Draw(region);
                // 保存内容
                texture.SaveFile(model.Directory + "/" + RInt.Pad(index, 3) + ".png");
                index++;
            }
        }
예제 #2
0
        //============================================================
        public void Export3d2(FDrGeometry geometry, string filename)
        {
            SIntSize    size   = new SIntSize(1024, 1024);
            Form        form   = new Form();
            FDxDevice3D device = RDxCore.Adapter.CreateDevice(form.Handle, size.Width, size.Height);

            device.ModeWireFrame = false;
            // 设置几何体
            FDxRegion         region         = new FDxRegion();
            FDsNormalGeometry normalGeometry = new FDsNormalGeometry();

            normalGeometry.Device = device;
            normalGeometry.LoadResource(geometry);
            region.Renderables.Push(normalGeometry);
            // 设置目标
            FDxBufferedTexture texture = new FDxBufferedTexture();

            texture.Device = device;
            texture.Create(size.Width, size.Height);
            device.SetRenderTarget(texture);
            // 绘制结果
            FDxTechnique technique = RDxCore.TechniqueConsole.Get(device, "normal.map");

            technique.Draw(region);
            // 保存内容
            texture.SaveFile(filename);
            // 创建设备
            // QNormalMapForm form = new QNormalMapForm();
            // form.geometry = geometry;
            // Application.Run(form);
        }
예제 #3
0
        //============================================================
        public FDxBufferedTexture ExportTexture(string importFileName)
        {
            // 获得图片大小
            Bitmap bmp = new Bitmap(importFileName);

            _size.Set(bmp.Width, bmp.Height);
            bmp.Dispose();
            // 生成目标
            Form        form   = new Form();
            FDxDevice3D device = RDxCore.Adapter.CreateDevice(form.Handle, _size.Width, _size.Height);

            device.ModeWireFrame = false;
            // 设置几何体
            FDxRegion region = new FDxRegion();
            // 渲染几何体
            FDxTechnique       technique = RDxCore.TechniqueConsole.Get(device, "growing");
            FDrGrowingGeometry geometry  = new FDrGrowingGeometry();

            geometry.Device = device;
            geometry.LoadResource();
            // 绘制结果
            region.Renderables.Push(geometry);
            // 设置目标
            FDxBufferedTexture texture = new FDxBufferedTexture();

            texture.Device = device;
            texture.Create(_size.Width, _size.Height);
            // 绘制目标
            FDxTexture originTexture = new FDxTexture();

            originTexture.Device = device;
            originTexture.LoadFile(importFileName);
            geometry.Material.Textures.Push(originTexture);
            // 绘制目标
            FDxTexture importTexture = new FDxTexture();

            importTexture.Device = device;
            importTexture.LoadFile(importFileName);
            geometry.Material.Textures.Push(importTexture);
            MemoryStream stream = new MemoryStream();

            for (int n = 0; n < _borderCount; n++)
            {
                device.SetRenderTarget(texture);
                // 绘制目标
                technique.Draw(region);
                device.SetRenderTarget();
                // 复制渲染目标为开始
                //importTexture.CopyFrom(texture);
                texture.SaveStream(stream);
                importTexture.LoadStream(stream);
            }
            // 保存内容
            return(texture);
        }
예제 #4
0
        //============================================================
        // <T>设置渲染过程。</T>
        //============================================================
        public override void Setup()
        {
            base.Setup();
            SIntSize size = new SIntSize(2048, 2048);

            // 创建深度检测区
            _depthTexture.Device = _device;
            _depthTexture.Create(size.Width, size.Height);
            // 创建渲染目标纹理区 (颜色,透明度)
            _lineTexture.Device       = _device;
            _lineTexture.NativeFormat = Format.R8G8B8A8_UNorm;
            _lineTexture.Create(size.Width, size.Height);
        }
예제 #5
0
        //============================================================
        // <T>设置渲染过程。</T>
        //============================================================
        public override void Setup()
        {
            base.Setup();
            SIntSize size = new SIntSize(2048, 2048);
            FObjects <FDxBufferedTexture> textures = new FObjects <FDxBufferedTexture>();

            // 创建深度检测区
            _depthTexture.Device = _device;
            _depthTexture.Create(size.Width, size.Height);
            // 创建渲染目标纹理区 (标识)
            _textureFlags.Device       = _device;
            _textureFlags.NativeFormat = Format.R32G32B32A32_SInt;
            _textureFlags.Create(size.Width, size.Height);
            textures.Push(_textureFlags);
            // 创建渲染目标纹理区 (颜色,透明度)
            _textureColor.Device       = _device;
            _textureColor.NativeFormat = Format.R8G8B8A8_UNorm;
            _textureColor.Create(size.Width, size.Height);
            textures.Push(_textureColor);
            // 建立纹理列表
            _targets = textures.ToArray();
        }
예제 #6
0
        private void QNormalMapForm_Load(object sender, EventArgs e)
        {
            device = RDxCore.Adapter.CreateDevice(Handle, 1024, 1024);
            // 设置几何体
            region = new FDxRegion();
            FDsNormalGeometry normalGeometry = new FDsNormalGeometry();

            normalGeometry.Device = device;
            normalGeometry.LoadResource(geometry);
            region.Renderables.Push(normalGeometry);
            // 设置目标
            FDxBufferedTexture texture = new FDxBufferedTexture();

            texture.Device = device;
            texture.Create(1024, 1024);
            //device.SetRenderTarget(texture);
            // 绘制结果
            technique = RDxCore.TechniqueConsole.Get(device, "normal.map");
            // 保存内容
            //texture.SaveFile(filename);
            timer1.Enabled = true;
        }