本文整理汇总了C#中Cylinder.SetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# Cylinder.SetAttribute方法的具体用法?C# Cylinder.SetAttribute怎么用?C# Cylinder.SetAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cylinder
的用法示例。
在下文中一共展示了Cylinder.SetAttribute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Bezier
/// <summary>
/// Test scene for BezierSurface.
/// </summary>
public static void Bezier( IRayScene sc )
{
Debug.Assert( sc != null );
// CSG scene:
CSGInnerNode root = new CSGInnerNode( SetOperation.Union );
root.SetAttribute( PropertyName.REFLECTANCE_MODEL, new PhongModel() );
root.SetAttribute( PropertyName.MATERIAL, new PhongMaterial( new double[] { 1.0, 0.8, 0.1 }, 0.1, 0.5, 0.5, 64 ) );
sc.Intersectable = root;
// Background color:
sc.BackgroundColor = new double[] { 0.0, 0.05, 0.07 };
// Camera:
sc.Camera = new StaticCamera( new Vector3d( 0.7, 0.5, -5.0 ),
new Vector3d( 0.0, -0.18, 1.0 ),
50.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 ) );
// --- NODE DEFINITIONS ----------------------------------------------------
// Bezier patch (not yet):
BezierSurface b = new BezierSurface( 1, 2, new double[] {
0.0, 0.0, 3.0, // row 0
1.0, 0.0, 3.0,
2.0, 0.0, 3.0,
3.0, 0.0, 3.0,
4.0, 0.0, 3.0,
5.0, 0.0, 3.0,
6.0, 0.0, 3.0,
0.0, 0.0, 2.0, // row 1
1.0, 0.0, 2.0,
2.0, 3.0, 2.0,
3.0, 3.0, 2.0,
4.0, 3.0, 2.0,
5.0, 0.0, 2.0,
6.0, 0.0, 2.0,
0.0, 0.0, 1.0, // row 2
1.0, 0.0, 1.0,
2.0, 0.0, 1.0,
3.0, 1.5, 1.0,
4.0, 3.0, 1.0,
5.0, 0.0, 1.0,
6.0, 0.0, 1.0,
0.0, 0.0, 0.0, // row 3
1.0, 0.0, 0.0,
2.0, 0.0, 0.0,
3.0, 0.0, 0.0,
4.0, 0.0, 0.0,
5.0, 0.0, 0.0,
6.0, 0.0, 0.0,
} );
b.SetAttribute( PropertyName.TEXTURE, new CheckerTexture( 10.5, 12.0, new double[] { 0.0, 0.0, 0.1 } ) );
root.InsertChild( b, Matrix4d.RotateY( -0.4 ) * Matrix4d.CreateTranslation( -1.1, -0.9, 0.0 ) );
// Cylinders for reflections..
Cylinder c = new Cylinder();
c.SetAttribute( PropertyName.MATERIAL, new PhongMaterial( new double[] { 0.0, 0.6, 0.0 }, 0.2, 0.6, 0.3, 8 ) );
root.InsertChild( c, Matrix4d.Scale( 0.15 ) * Matrix4d.RotateX( MathHelper.PiOver2 ) * Matrix4d.CreateTranslation( -0.4, 0.0, 0.0 ) );
c = new Cylinder();
c.SetAttribute( PropertyName.MATERIAL, new PhongMaterial( new double[] { 0.8, 0.2, 0.0 }, 0.2, 0.6, 0.3, 8 ) );
root.InsertChild( c, Matrix4d.Scale( 0.2 ) * Matrix4d.RotateX( MathHelper.PiOver2 ) * Matrix4d.CreateTranslation( -1.9, 0.0, 3.0 ) );
// Infinite plane with checker:
Plane pl = new Plane();
pl.SetAttribute( PropertyName.COLOR, new double[] { 0.3, 0.0, 0.0 } );
pl.SetAttribute( PropertyName.TEXTURE, new CheckerTexture( 0.6, 0.6, new double[] { 1.0, 1.0, 1.0 } ) );
root.InsertChild( pl, Matrix4d.RotateX( -MathHelper.PiOver2 ) * Matrix4d.CreateTranslation( 0.0, -1.0, 0.0 ) );
}
示例2: Cylinders
/// <summary>
/// Test scene for cylinders
/// </summary>
public static void Cylinders( IRayScene sc )
{
Debug.Assert( sc != null );
// CSG scene:
CSGInnerNode root = new CSGInnerNode( SetOperation.Union );
root.SetAttribute( PropertyName.REFLECTANCE_MODEL, new PhongModel() );
root.SetAttribute( PropertyName.MATERIAL, new PhongMaterial( new double[] { 0.6, 0.0, 0.0 }, 0.15, 0.8, 0.15, 16 ) );
sc.Intersectable = root;
// Background color:
sc.BackgroundColor = new double[] { 0.0, 0.05, 0.07 };
// Camera:
sc.Camera = new StaticCamera( new Vector3d( 0.7, 3.0, -10.0 ),
new Vector3d( 0.0, -0.2, 1.0 ),
50.0 );
// Light sources:
sc.Sources = new LinkedList<ILightSource>();
sc.Sources.Add( new AmbientLightSource( 1.0 ) );
sc.Sources.Add( new PointLightSource( new Vector3d( -5.0, 3.0, -3.0 ), 1.6 ) );
// --- NODE DEFINITIONS ----------------------------------------------------
// Base plane
Plane pl = new Plane();
pl.SetAttribute( PropertyName.COLOR, new double[] { 0.0, 0.2, 0.0 } );
pl.SetAttribute( PropertyName.TEXTURE, new CheckerTexture( 0.5, 0.5, new double[] { 1.0, 1.0, 1.0 } ) );
root.InsertChild( pl, Matrix4d.RotateX( -MathHelper.PiOver2 ) * Matrix4d.CreateTranslation( 0.0, -1.0, 0.0 ) );
// Cylinders
Cylinder c = new Cylinder();
root.InsertChild( c, Matrix4d.RotateX( MathHelper.PiOver2 ) * Matrix4d.CreateTranslation( -2.1, 0.0, 1.0 ) );
c = new Cylinder();
c.SetAttribute( PropertyName.COLOR, new double[] { 0.2, 0.0, 0.7 } );
c.SetAttribute( PropertyName.TEXTURE, new CheckerTexture( 12.0, 1.0, new double[] { 0.0, 0.0, 0.3 } ) );
root.InsertChild( c, Matrix4d.RotateY( -0.4 ) * Matrix4d.CreateTranslation( 1.0, 0.0, 1.0 ) );
c = new Cylinder( 0.0, 100.0 );
c.SetAttribute( PropertyName.COLOR, new double[] { 0.1, 0.7, 0.0 } );
root.InsertChild( c, Matrix4d.RotateY( 0.2 ) * Matrix4d.CreateTranslation( 5.0, 0.3, 4.0 ) );
c = new Cylinder( -0.5, 0.5 );
c.SetAttribute( PropertyName.COLOR, new double[] { 0.8, 0.6, 0.0 } );
root.InsertChild( c, Matrix4d.Scale( 2.0 ) * Matrix4d.RotateX( 1.2 ) * Matrix4d.CreateTranslation( 2.0, 1.8, 16.0 ) );
}
示例3: head
protected static CSGInnerNode head()
{
CSGInnerNode root = new CSGInnerNode( SetOperation.Union );
double[] skinColor = new double[] { 1, .8, .65 };
double[] whiteColor = new double[] { 1, 1, 1 };
double[] blackColor = new double[] { 0, 0, 0 };
double[] blueColor = new double[] { 0, 0, 1 };
double[] redColor = new double[] { 1, 0, 0 };
CSGInnerNode hlava = new CSGInnerNode( SetOperation.Difference );
root.InsertChild( hlava, Matrix4d.Identity );
Sphere s = new Sphere();
s.SetAttribute( PropertyName.COLOR, skinColor );
hlava.InsertChild( s, Matrix4d.Scale( 2.3 ) );
// klobouk
CSGInnerNode klobouk = new CSGInnerNode( SetOperation.Union );
Cylinder klb = new Cylinder( -0.5, 0.5 );
klb.SetAttribute( PropertyName.COLOR, blackColor );
klobouk.InsertChild( klb, Matrix4d.Scale( 2, 2, 1.4 ) * Matrix4d.RotateX( Math.PI / 2 ) * Matrix4d.CreateTranslation( 0, 0.5, 0 ) );
Cylinder ksilt = new Cylinder( -0.5, 0.5 );
ksilt.SetAttribute( PropertyName.COLOR, blackColor );
klobouk.InsertChild( ksilt, Matrix4d.Scale( 3, 3, .1 ) * Matrix4d.RotateX( Math.PI / 2 ) );
root.InsertChild( klobouk, Matrix4d.CreateTranslation( 0, 1.25, 0 ) );
// levy ocni dulek
s = new Sphere();
s.SetAttribute( PropertyName.COLOR, skinColor );
hlava.InsertChild( s, Matrix4d.Scale( 0.7 ) * Matrix4d.CreateTranslation( -0.7, .3, -1.8 ) );
// pravy ocni dulek
s = new Sphere();
s.SetAttribute( PropertyName.COLOR, skinColor );
hlava.InsertChild( s, Matrix4d.Scale( 0.7 ) * Matrix4d.CreateTranslation( 0.7, .3, -1.8 ) );
// prave oko
CSGInnerNode oko = new CSGInnerNode( SetOperation.Union );
root.InsertChild( oko, Matrix4d.CreateTranslation( 0.70, 0.3, -0.5 ) );
Sphere bulva = new Sphere();
bulva.SetAttribute( PropertyName.COLOR, whiteColor );
oko.InsertChild( bulva, Matrix4d.Scale( 1.3 ) );
Sphere cocka = new Sphere();
cocka.SetAttribute( PropertyName.COLOR, blueColor );
oko.InsertChild( cocka, Matrix4d.Scale( 0.3 ) * Matrix4d.CreateTranslation( 0, 0, -1.2 ) );
// leve oko
oko = new CSGInnerNode( SetOperation.Union );
root.InsertChild( oko, Matrix4d.CreateTranslation( -0.70, 0.3, -0.5 ) );
bulva = new Sphere();
bulva.SetAttribute( PropertyName.COLOR, whiteColor );
oko.InsertChild( bulva, Matrix4d.Scale( 1.3 ) );
cocka = new Sphere();
cocka.SetAttribute( PropertyName.COLOR, blueColor );
oko.InsertChild( cocka, Matrix4d.Scale( 0.3 ) * Matrix4d.CreateTranslation( 0, 0, -1.2 ) );
// nos
Cylinder nos = new Cylinder( -0.5, 0.5 );
nos.SetAttribute( PropertyName.COLOR, skinColor );
root.InsertChild( nos, Matrix4d.Scale( 0.2, 0.2, 0.6 ) * Matrix4d.CreateTranslation( 0, 0, -2.65 ) );
// usta
CSGInnerNode usta = new CSGInnerNode( SetOperation.Xor );
Cylinder horniRet = new Cylinder( -0.5, 0.5 );
horniRet.SetAttribute( PropertyName.COLOR, redColor );
usta.InsertChild( horniRet, Matrix4d.CreateTranslation( 0, -0.3, 0 ) );
Cylinder dolniRet = new Cylinder( -0.5, 0.5 );
dolniRet.SetAttribute( PropertyName.COLOR, redColor );
usta.InsertChild( dolniRet, Matrix4d.CreateTranslation( 0, 0.3, 0 ) );
root.InsertChild( usta, Matrix4d.Scale( 0.7, 0.3, 1 ) * Matrix4d.CreateTranslation( 0, -0.7, -1.85 ) );
// vnitrek ust
CSGInnerNode vnitrekUst = new CSGInnerNode( SetOperation.Intersection );
horniRet = new Cylinder( -0.5, 0.5 );
horniRet.SetAttribute( PropertyName.COLOR, blackColor );
vnitrekUst.InsertChild( horniRet, Matrix4d.CreateTranslation( 0, -0.3, 0 ) );
dolniRet = new Cylinder( -0.5, 0.5 );
dolniRet.SetAttribute( PropertyName.COLOR, blackColor );
vnitrekUst.InsertChild( dolniRet, Matrix4d.CreateTranslation( 0, 0.3, 0 ) );
usta.InsertChild( vnitrekUst, Matrix4d.CreateTranslation( 0, 0, 0.1 ) );
return root;
}
示例4: testWithCylinders
protected static CSGInnerNode testWithCylinders( SetOperation op )
{
// scene:
CSGInnerNode root = new CSGInnerNode( op );
int num = 5;
for ( int i = 0; i < num; ++i )
{
double j = i;
Cylinder c = new Cylinder( -0.5, 0.5 );
c.SetAttribute( PropertyName.COLOR, new double[] { j / num, 1.0 - j / num, 0 } );
root.InsertChild( c, Matrix4d.RotateX( Math.PI / 4 ) * Matrix4d.CreateTranslation( -1 + 0.6 * i, 0, 0 ) );
}
return root;
}