当前位置: 首页>>代码示例>>C#>>正文


C# IConfigurationService.GetModelConfiguration方法代码示例

本文整理汇总了C#中IConfigurationService.GetModelConfiguration方法的典型用法代码示例。如果您正苦于以下问题:C# IConfigurationService.GetModelConfiguration方法的具体用法?C# IConfigurationService.GetModelConfiguration怎么用?C# IConfigurationService.GetModelConfiguration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IConfigurationService的用法示例。


在下文中一共展示了IConfigurationService.GetModelConfiguration方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadModel3DGroup

        public static ModelResult LoadModel3DGroup(IConfigurationService configService, bool designMode)
        {
            if (designMode)
            {
                var mesh = new CubeMesh();
                var model = new GeometryModel3D(mesh.Geometry,
                     new DiffuseMaterial(new SolidColorBrush(Colors.Red)));
                var group = new Transform3DGroup();
                group.Children.Add(new ScaleTransform3D(new Vector3D(20, 20, 20)));
                group.Children.Add(new RotateTransform3D(
                    new AxisAngleRotation3D(new Vector3D(1, 1, 0), 30)));
                model.Transform = group;
                var designSesult = new ModelResult();
                designSesult.Model3DGroup.Children.Add(model);

                return designSesult;
            }

            var result = new ModelResult();
            var model3DGroup = new Model3DGroup();
            var modelConfig = configService.GetModelConfiguration();

            foreach (var letter in modelConfig.LetterModels)
            {
                var dictionary = new ResourceDictionary()
                {
                    Source = new Uri(letter.ModelPath, UriKind.Relative)
                };

                var mesh = (MeshGeometry3D)dictionary["mesh"];

                if (mesh == null)
                {
                    throw new InvalidOperationException("3D Mesh could not be read in XAML file '" + letter.ModelPath + "'");
                }

                var brush = new SolidColorBrush(
                    (Color)ColorConverter.ConvertFromString(letter.Color));
                var materialGroup = new MaterialGroup();
                var diffuse = new DiffuseMaterial(brush);
                var specular = new SpecularMaterial(new SolidColorBrush(Colors.White), 1000);
                materialGroup.Children.Add(diffuse);
                materialGroup.Children.Add(specular);

                var model = new GeometryModel3D(mesh, materialGroup);

                var transformGroup = new Transform3DGroup();

                var scale = new ScaleTransform3D(
                    new Vector3D(letter.Scale, letter.Scale, letter.Scale));

                var translate = new TranslateTransform3D(
                    new Vector3D(letter.OffsetX, letter.OffsetY, letter.OffsetZ));

                transformGroup.Children.Add(translate);
                transformGroup.Children.Add(scale);

                model.Transform = transformGroup;

                model3DGroup.Children.Add(model);

                var wireframe = new ScreenLines();

                for (var i = 0; i < mesh.Positions.Count; i++)
                {
                    wireframe.Points.Add(mesh.Positions[i]);
                    wireframe.Thickness = 1;
                    wireframe.Color = Colors.White;
                }

                wireframe.Transform = transformGroup;
                result.Wireframes.Add(wireframe);
            }

            result.Model3DGroup = model3DGroup;
            return result;
        }
开发者ID:kindohm,项目名称:getstem-kinect-3d,代码行数:77,代码来源:ModelLoader.cs


注:本文中的IConfigurationService.GetModelConfiguration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。