Example #1
0
        //============================================================
        private void QDsTemplateEditorForm_Load(object sender, System.EventArgs e)
        {
            // 创建设备
            _device = RDxCore.Adapter.CreateDevice(pnlViewport.Handle, pnlViewport.Width, pnlViewport.Height);
            // 创建舞台
            FDxStage stage = new FDxStage();

            RDxCore.StageConsole.ActiveStage = stage;
            // 创建场景
            _scene        = new FDxDesignScene();
            _scene.Device = _device;
            _scene.Setup();
            _scene.Region.BackgroundColor.Set(0, 0, 0, 1);
            _scene.Region.BackgroundColor.Set(0.5f, 0.5f, 0.5f, 1.0f);
            _scene.Region.Camera.Viewport.width  = pnlSpace.Width;
            _scene.Region.Camera.Viewport.height = pnlSpace.Height;
            _scene.Region.Camera.Viewport.Update();
            _scene.Region.Camera.Position.Set(0, 200, -500);
            _scene.Region.Camera.LookAt(0, 200, 0);
            _scene.Region.LightDirectional.Position.Set(1000, 1000, 0);
            _scene.Region.LightDirectional.Camera.Position.Set(1000, 1000, 0);
            _scene.Region.LightDirectional.Camera.LookAt(0, 200, 0);
            // 加载模型
            if (!RString.IsEmpty(_templateName))
            {
                LoadTemplate(_templateName);
            }
            // 加载场景
            // qdsDeviceProperty.LoadDevice(_device);
            // qdsSceneTree.LoadScene(_scene);
            // 开始时钟
            timRefresh.Enabled = true;
            CenterToScreen();
        }
Example #2
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++;
            }
        }
Example #3
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);
        }
Example #4
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);
        }
Example #5
0
        //============================================================
        public FDxSpatial Create(FDxDevice3D device, string code)
        {
            // 获得资源定义
            FDxRsTemplate resource = RDxCore.TemplateResourceConsole.Get(code);
            // 加载资源
            FDxSpatial spatial = RDxCore.Factory.Create <FDxSpatial>(EDxObject.ModelSpatial);

            spatial.Device = device;
            spatial.LoadResource(resource);
            _spatials.Push(spatial);
            return(spatial);
        }
Example #6
0
        //============================================================s
        public FDxTechnique Get(FDxDevice3D device, string type)
        {
            FDxTechnique technique = _techniques.Find(type);

            if (null == technique)
            {
                technique        = Create(type);
                technique.Device = device;
                technique.Setup();
                _techniques.Set(type, technique);
            }
            return(technique);
        }
Example #7
0
        //============================================================s
        public FDxEffect Get(FDxDevice3D device, string type)
        {
            FDxEffect effect = _effects.Find(type);

            if (null == effect)
            {
                effect        = Create(type);
                effect.Device = device;
                effect.LoadFile(_path + "\\" + type + ".fx");
                effect.Setup();
                _effects.Set(type, effect);
            }
            return(effect);
        }
Example #8
0
        //============================================================
        public FDxGeometry Create(FDxDevice3D device, string modelCode, string geometryCode)
        {
            // 创建几何体
            FDxGeometry geometry = RDxCore.Factory.Create <FDxGeometry>(EDxObject.ModelGeometry);

            geometry.Device = device;
            // 加载资源
            FDxModel         model         = RDxCore.ModelConsole.Get(device, modelCode);
            FDxModelGeometry modelGeometry = model.Geometries.Get(geometryCode);

            geometry.ModelGeometry = modelGeometry;
            geometry.Setup();
            return(geometry);
        }
Example #9
0
        //============================================================
        public FDxModel Get(FDxDevice3D device, string code)
        {
            FDxModel model = _models.Find(code);

            if (null == model)
            {
                // 创建模型
                model        = new FDxModel();
                model.Device = device;
                // 加载模型资源
                FDxRsModel rsModel = RDxCore.ModelResourceConsole.Get(code);
                model.LoadResource(rsModel);
                // 存储模型
                _models.Set(code, model);
            }
            return(model);
        }
Example #10
0
        //============================================================
        public FDxModelTexture Get(FDxDevice3D device, string code, int typeCd)
        {
            string          name    = code + "|" + typeCd;
            FDxModelTexture texture = _textures.Find(name);

            if (null == texture)
            {
                // 创建模型
                texture        = new FDxModelTexture();
                texture.Device = device;
                // 加载模型资源
                FDxRsTexturePack       rsTexture = RDxCore.TextureResourceConsole.Get(code);
                FDxRsTextureBitmapPack rsPack    = rsTexture.Packs[typeCd];
                texture.LoadResource(rsPack);
                // 存储模型
                _textures.Set(name, texture);
            }
            return(texture);
        }
Example #11
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;
        }
Example #12
0
        //protected VertexShader _nativeShader;

        //============================================================
        public FDxVertexShader(FDxDevice3D device)
        {
            _device = device;
        }
Example #13
0
 //============================================================
 public void LoadDevice(FDxDevice3D device)
 {
     _device = device;
 }
Example #14
0
        //protected PixelShader _nativeShader;

        //============================================================
        public FDxPixelShader(FDxDevice3D device)
        {
            _device = device;
        }
Example #15
0
        //protected GeometryShader _nativeShader;

        //============================================================
        public FDxGeometryShader(FDxDevice3D device)
        {
            _device = device;
        }