Esempio n. 1
0
        //============================================================
        public void LoadResource(FDxRsTemplate resource)
        {
            //............................................................
            // 加载材质列表
            int materialCount = resource.Materials.Count;

            for (int n = 0; n < materialCount; n++)
            {
                // 创建几何体
                FDxRsTemplateMaterial rsMaterial = resource.Materials[n];
                FDxSpatialMaterial    material   = new FDxSpatialMaterial();
                material.Device = _device;
                material.LoadResource(rsMaterial);
                // 增加渲染对象
                _materials.Set(material.Name, material);
            }
            //............................................................
            // 加载渲染列表
            int renderableCount = resource.Renderables.Count;

            for (int n = 0; n < renderableCount; n++)
            {
                // 创建几何体
                FDxRsTemplateRenderable rsRenderable = resource.Renderables[n];
                FDxGeometry             geometry     = RDxCore.GeometryConsole.Create(_device, rsRenderable.ModelCode, rsRenderable.GeometryName);
                geometry.Display = this;
                geometry.LoadRenderable(rsRenderable);
                _geometries.Push(geometry);
                // 设置材质
                FDxSpatialMaterial material = _materials.Get(rsRenderable.MaterialCode);
                geometry.ModelMaterial = material;
                // 增加渲染对象
                _renderables.Push(geometry);
            }
        }
Esempio n. 2
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);
        }