本文整理汇总了C#中TextureCube.SetPixels方法的典型用法代码示例。如果您正苦于以下问题:C# TextureCube.SetPixels方法的具体用法?C# TextureCube.SetPixels怎么用?C# TextureCube.SetPixels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextureCube
的用法示例。
在下文中一共展示了TextureCube.SetPixels方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateNormalizeCubeTexture
/// 正規化キューブマップの生成
public static TextureCube CreateNormalizeCubeTexture( int width )
{
int height = width;
TextureCube nc = new TextureCube( width, false, PixelFormat.Rgba );
nc.SetFilter( TextureFilterMode.Linear,
TextureFilterMode.Linear,
TextureFilterMode.Linear );
nc.SetWrap( TextureWrapMode.ClampToEdge, TextureWrapMode.ClampToEdge );
// +X
{
byte[] pixsPX = new byte[ width * height * 4 ];
byte[] pixsNX = new byte[ width * height * 4 ];
byte[] pixsPY = new byte[ width * height * 4 ];
byte[] pixsNY = new byte[ width * height * 4 ];
byte[] pixsPZ = new byte[ width * height * 4 ];
byte[] pixsNZ = new byte[ width * height * 4 ];
for( int v = 0; v < width; v++ ){
float y = (float)(v + v - height) / (float)height;
for( int u = 0; u < width; u++ ){
float x = (float)(u + u - width) / (float)width;
float r = 1.0f / (float)Math.Sqrt( (x * x) + (y * y) + 1.0f);
float s = x * r;
float t = y * r;
Vector3 vn = new Vector3( r, s, t );
vn = vn.Normalize();
r = (r / 2.0f + 0.5f);
s = (s / 2.0f + 0.5f);
t = (t / 2.0f + 0.5f);
int ofst = (4 * u) + ((v * 4) * width);
pixsPX[ ofst + 0 ] = (byte)(255 * r);
pixsPX[ ofst + 1 ] = (byte)(255 * -t);
pixsPX[ ofst + 2 ] = (byte)(255 * -s);
pixsPX[ ofst + 3 ] = 0xFF;
pixsNX[ ofst + 0 ] = (byte)(255 * -r);
pixsNX[ ofst + 1 ] = (byte)(255 * -t);
pixsNX[ ofst + 2 ] = (byte)(255 * s);
pixsNX[ ofst + 3 ] = 0xFF;
pixsPY[ ofst + 0 ] = (byte)(255 * s);
pixsPY[ ofst + 1 ] = (byte)(255 * r);
pixsPY[ ofst + 2 ] = (byte)(255 * t);
pixsPY[ ofst + 3 ] = 0xFF;
pixsNY[ ofst + 0 ] = (byte)(255 * s);
pixsNY[ ofst + 1 ] = (byte)(255 * -r);
pixsNY[ ofst + 2 ] = (byte)(255 * -t);
pixsNY[ ofst + 3 ] = 0xFF;
pixsPZ[ ofst + 0 ] = (byte)(255 * s);
pixsPZ[ ofst + 1 ] = (byte)(255 * -t);
pixsPZ[ ofst + 2 ] = (byte)(255 * r);
pixsPZ[ ofst + 3 ] = 0xFF;
pixsNZ[ ofst + 0 ] = (byte)(255 * -s);
pixsNZ[ ofst + 1 ] = (byte)(255 * -t);
pixsNZ[ ofst + 2 ] = (byte)(255 * -r);
pixsNZ[ ofst + 3 ] = 0xFF;
}
}
nc.SetPixels( 0, TextureCubeFace.PositiveX, pixsPX );
nc.SetPixels( 0, TextureCubeFace.NegativeX, pixsNX );
nc.SetPixels( 0, TextureCubeFace.PositiveY, pixsPY );
nc.SetPixels( 0, TextureCubeFace.NegativeY, pixsNY );
nc.SetPixels( 0, TextureCubeFace.PositiveZ, pixsPZ );
nc.SetPixels( 0, TextureCubeFace.NegativeZ, pixsNZ );
}
return nc;
}