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


C# Cube.SetAttribute方法代码示例

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


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

示例1: Flags

        /// <summary>
        /// Six national flags (in artistic style) - by Jakub Vlcek, (c) 2012
        /// </summary>
        public static void Flags( IRayScene sc )
        {
            Debug.Assert( sc != null );

              // CSG scene:
              CSGInnerNode flags = new CSGInnerNode( SetOperation.Union );
              flags.SetAttribute( PropertyName.REFLECTANCE_MODEL, new PhongModel() );
              flags.SetAttribute( PropertyName.MATERIAL, new PhongMaterial( new double[] { 0.5, 0.5, 0.5 }, 0.2, 0.7, 0.1, 16 ) );
              sc.Intersectable = flags;
              Sphere s;
              Cube c;

              // Background color:
              sc.BackgroundColor = new double[] { 0.0, 0.05, 0.05 };

              // Camera:
              sc.Camera = new StaticCamera( new Vector3d( 0.0, 0.0, -10.0 ),
                                    new Vector3d( 0.0, 0.0, 1.0 ),
                                    60.0 );

              // Light sources:
              sc.Sources = new LinkedList<ILightSource>();
              sc.Sources.Add( new AmbientLightSource( 0.8 ) );
              sc.Sources.Add( new PointLightSource( new Vector3d( -5.0, 3.0, -3.0 ), 1.0 ) );
              sc.Sources.Add( new PointLightSource( new Vector3d( 5.0, 3.0, -3.0 ), 1.0 ) );

              // --- NODE DEFINITIONS ----------------------------------------------------

              // Latvian flag (intersection, difference and xor):
              CSGInnerNode latvia = new CSGInnerNode( SetOperation.Intersection );
              c = new Cube();
              c.SetAttribute( PropertyName.COLOR, new double[] { 0.3, 0.0, 0.0 } );
              latvia.InsertChild( c, Matrix4d.Scale( 4.0, 2.0, 0.4 ) * Matrix4d.CreateTranslation( -2.0, -1.0, 0.0 ) );
              CSGInnerNode latviaFlag = new CSGInnerNode( SetOperation.Xor );
              c = new Cube();
              c.SetAttribute( PropertyName.COLOR, new double[] { 0.3, 0.0, 0.0 } );
              latviaFlag.InsertChild( c, Matrix4d.CreateTranslation( -0.5, -0.5, -0.5 ) * Matrix4d.Scale( 4.0, 2.0, 2.0 ) );
              c = new Cube();
              c.SetAttribute( PropertyName.COLOR, new double[] { 1.0, 1.0, 1.0 } );
              latviaFlag.InsertChild( c, Matrix4d.CreateTranslation( -0.5, -0.5, -0.5 ) * Matrix4d.Scale( 4.2, 0.5, 0.5 ) );
              latvia.InsertChild( latviaFlag, Matrix4d.Identity );
              flags.InsertChild( latvia, Matrix4d.Scale( 0.7 ) * Matrix4d.CreateRotationX( Math.PI / 8 ) * Matrix4d.CreateTranslation( -3.5, 1.5, 0.0 ) );

              // Czech flag (difference):
              CSGInnerNode czech = new CSGInnerNode( SetOperation.Difference );
              s = new Sphere();
              s.SetAttribute( PropertyName.COLOR, new double[] { 0.2, 0.2, 0.2 } );
              czech.InsertChild( s, Matrix4d.Identity );
              s = new Sphere();
              s.SetAttribute( PropertyName.COLOR, new double[] { 1.0, 1.0, 1.0 } );
              czech.InsertChild( s, Matrix4d.CreateTranslation( 0.0, 0.8, -1.0 ) );
              s = new Sphere();
              s.SetAttribute( PropertyName.COLOR, new double[] { 1.0, 0.0, 0.0 } );
              czech.InsertChild( s, Matrix4d.CreateTranslation( 0.0, -0.8, -1.1 ) );
              s = new Sphere();
              s.SetAttribute( PropertyName.COLOR, new double[] { 0.0, 0.0, 1.0 } );
              czech.InsertChild( s, Matrix4d.CreateTranslation( -1.0, 0.0, -0.8 ) );
              flags.InsertChild( czech, Matrix4d.Scale( 1.6, 1.0, 1.0 ) * Matrix4d.CreateRotationY( Math.PI / 8 ) *
                                Matrix4d.CreateTranslation( 4.0, -1.5, 0.0 ) );

              // Croatian flag (union, intersection):
              CSGInnerNode croatianFlag = new CSGInnerNode( SetOperation.Union );
              CSGInnerNode croatianSign = new CSGInnerNode( SetOperation.Intersection );
              CSGInnerNode checkerBoard = new CSGInnerNode( SetOperation.Union );
              c = new Cube();
              c.SetAttribute( PropertyName.COLOR, new double[] { 1.0, 0.0, 0.0 } );
              c.SetAttribute( PropertyName.TEXTURE, new CheckerTexture( 10.0, 10.0, new double[] { 1.0, 1.0, 1.0 } ) );
              croatianSign.InsertChild( c, Matrix4d.CreateTranslation( -0.5, -0.5, -0.5 ) * Matrix4d.Scale( 2.0, 2.0, 0.4 ) );
              CSGInnerNode sign = new CSGInnerNode( SetOperation.Union );
              s = new Sphere();
              s.SetAttribute( PropertyName.COLOR, new double[] { 1.0, 1.0, 1.0 } );
              sign.InsertChild( s, Matrix4d.Identity );
              c = new Cube();
              c.SetAttribute( PropertyName.COLOR, new double[] { 1.0, 1.0, 1.0 } );
              sign.InsertChild( c, Matrix4d.Scale( 1.8 ) * Matrix4d.CreateTranslation( -0.9, 0.1, -0.9 ) );
              croatianSign.InsertChild( sign, Matrix4d.Scale( 0.5, 0.33, 0.5 ) * Matrix4d.CreateTranslation( 0.44, -0.5, 0.0 ) );
              c = new Cube();
              c.SetAttribute( PropertyName.COLOR, new double[] { 1.0, 0.0, 0.0 } );
              croatianFlag.InsertChild( c, Matrix4d.CreateTranslation( -0.5, -0.5, -0.5 ) * Matrix4d.Scale( 4.0, 0.6, 0.6 ) *
                                   Matrix4d.RotateX( Math.PI / 4 ) * Matrix4d.CreateTranslation( 0.5, 1.0, 1.0 ) );
              c = new Cube();
              c.SetAttribute( PropertyName.COLOR, new double[] { 1.0, 1.0, 1.0 } );
              croatianFlag.InsertChild( c, Matrix4d.CreateTranslation( -0.5, -0.5, -0.5 ) * Matrix4d.Scale( 4.0, 0.6, 0.6 ) *
                                   Matrix4d.RotateX( Math.PI / 4 ) * Matrix4d.CreateTranslation( 0.5, 0.3, 1.0 ) );
              c = new Cube();
              c.SetAttribute( PropertyName.COLOR, new double[] { 0.0, 0.0, 1.0 } );
              croatianFlag.InsertChild( c, Matrix4d.CreateTranslation( -0.5, -0.5, -0.5 ) * Matrix4d.Scale( 4.0, 0.6, 0.6 ) *
                                   Matrix4d.RotateX( Math.PI / 4 ) * Matrix4d.CreateTranslation( 0.5, -0.4, 1.0 ) );
              croatianFlag.InsertChild( croatianSign, Matrix4d.Scale( 0.8 ) * Matrix4d.CreateTranslation( 0.4, 0.5, 0.0 ) );
              flags.InsertChild( croatianFlag, Matrix4d.Scale( 0.8 ) * Matrix4d.CreateRotationY( Math.PI / 8 ) * Matrix4d.CreateTranslation( -0.4, 1.5, 1.0 ) );

              // Brazilian flag (union):
              CSGInnerNode brazilianFlag = new CSGInnerNode( SetOperation.Union );
              c = new Cube();
              c.SetAttribute( PropertyName.COLOR, new double[] { 0.0, 0.8, 0.0 } );
              brazilianFlag.InsertChild( c, Matrix4d.CreateTranslation( -0.5, -0.5, -0.5 ) * Matrix4d.Scale( 4.0, 2.0, 0.2 ) );
              c = new Cube();
//.........这里部分代码省略.........
开发者ID:pepouch,项目名称:PG1Grcis,代码行数:101,代码来源:RayCastingScenes.cs


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