本文整理汇总了C#中Matrix3x3.SetRow2方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix3x3.SetRow2方法的具体用法?C# Matrix3x3.SetRow2怎么用?C# Matrix3x3.SetRow2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix3x3
的用法示例。
在下文中一共展示了Matrix3x3.SetRow2方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildTargetCubeMapMip0
// Cube map faces orientation: http://msdn.microsoft.com/en-us/library/windows/desktop/bb204881(v=vs.85).aspx
private void BuildTargetCubeMapMip0( int _CubeFaceSize, Vector4D[][,] _CubeFaces, CubeMapSamplerDelegate _Sampler )
{
Vector View = Vector.Zero;
for ( int CubeFaceIndex=0; CubeFaceIndex < 6; CubeFaceIndex++ )
{
Vector4D[,] Face = new Vector4D[_CubeFaceSize,_CubeFaceSize];
_CubeFaces[CubeFaceIndex] = Face;
Matrix3x3 FaceTransform = new Matrix3x3();
switch ( CubeFaceIndex )
{
case 0: // +X
FaceTransform.SetRow0( -Vector.UnitZ );
FaceTransform.SetRow1( Vector.UnitY );
FaceTransform.SetRow2( Vector.UnitX );
break;
case 1: // -X
FaceTransform.SetRow0( Vector.UnitZ );
FaceTransform.SetRow1( Vector.UnitY );
FaceTransform.SetRow2( -Vector.UnitX );
break;
case 2: // +Y
FaceTransform.SetRow0( Vector.UnitX );
FaceTransform.SetRow1( -Vector.UnitZ );
FaceTransform.SetRow2( Vector.UnitY );
break;
case 3: // -Y
FaceTransform.SetRow0( Vector.UnitX );
FaceTransform.SetRow1( Vector.UnitZ );
FaceTransform.SetRow2( -Vector.UnitY );
break;
case 4: // +Z
FaceTransform.SetRow0( Vector.UnitX );
FaceTransform.SetRow1( Vector.UnitY );
FaceTransform.SetRow2( Vector.UnitZ );
break;
case 5: // -Z
FaceTransform.SetRow0( -Vector.UnitX );
FaceTransform.SetRow1( Vector.UnitY );
FaceTransform.SetRow2( -Vector.UnitZ );
break;
}
for ( int Y=0; Y < _CubeFaceSize; Y++ )
{
for ( int X=0; X < _CubeFaceSize; X++ )
{
// Build camera space view direction
View.x = 2.0f * (0.5f+X) / _CubeFaceSize - 1.0f;
View.y = 1.0f - 2.0f * (0.5f+Y) / _CubeFaceSize;
View.z = 1.0f;
View.Normalize();
// Build world space view direction
View *= FaceTransform;
Vector4D V = _Sampler( View );
Face[X,Y] = V;
}
}
}
}
示例2: SaveSHConvolution
private void SaveSHConvolution( int _CubeFaceSize, Vector4D[][][,] _CubeFaces, int _MipLevel, FileInfo _SourceFile, FileInfo _TargetFile )
{
m_CubeSize = _CubeFaceSize >> _MipLevel;
m_CubeFaces = _CubeFaces[_MipLevel];
double[] SHCoeffs = new double[9];
double[,] SumSH = new double[9,3];
Vector View = new Vector();
// Individual cube face sampling
double SumSolidAngle = 0.0;
for ( int CubeFaceIndex=0; CubeFaceIndex < 6; CubeFaceIndex++ )
{
Matrix3x3 FaceTransform = new Matrix3x3();
switch ( CubeFaceIndex )
{
case 0: // +X
FaceTransform.SetRow0( -Vector.UnitZ );
FaceTransform.SetRow1( Vector.UnitY );
FaceTransform.SetRow2( Vector.UnitX );
break;
case 1: // -X
FaceTransform.SetRow0( Vector.UnitZ );
FaceTransform.SetRow1( Vector.UnitY );
FaceTransform.SetRow2( -Vector.UnitX );
break;
case 2: // +Y
FaceTransform.SetRow0( Vector.UnitX );
FaceTransform.SetRow1( -Vector.UnitZ );
FaceTransform.SetRow2( Vector.UnitY );
break;
case 3: // -Y
FaceTransform.SetRow0( Vector.UnitX );
FaceTransform.SetRow1( Vector.UnitZ );
FaceTransform.SetRow2( -Vector.UnitY );
break;
case 4: // +Z
FaceTransform.SetRow0( Vector.UnitX );
FaceTransform.SetRow1( Vector.UnitY );
FaceTransform.SetRow2( Vector.UnitZ );
break;
case 5: // -Z
FaceTransform.SetRow0( -Vector.UnitX );
FaceTransform.SetRow1( Vector.UnitY );
FaceTransform.SetRow2( -Vector.UnitZ );
break;
}
for ( int Y=0; Y < m_CubeSize; Y++ )
{
for ( int X=0; X < m_CubeSize; X++ )
{
// Build camera space view direction
View.x = 2.0f * (0.5f+X) / m_CubeSize - 1.0f;
View.y = 1.0f - 2.0f * (0.5f+Y) / m_CubeSize;
View.z = 1.0f;
float SqLength = View.LengthSquare;
float Length = (float) Math.Sqrt( SqLength );
float SolidAngle = 4.0f / (Length * SqLength);
SolidAngle /= m_CubeSize*m_CubeSize;
SumSolidAngle += SolidAngle;
View /= Length;
// Build world space view direction
View *= FaceTransform;
double Theta = Math.Acos( View.y );
double Phi = Math.Atan2( View.x, View.z );
//
Vector4D Color = m_CubeFaces[CubeFaceIndex][X,Y];
float Scale = (float) Math.Exp( 3.9120230054281460586187507879106 * Color.w ); // HDR unpacking
Scale *= SolidAngle;
for ( int l=0; l < 3; l++ )
{
// double Filter = 1.0; // No filter
// double Filter = (Math.Cos(Math.PI * l / 3) + 1.0) * 0.5; // Hanning filter
// double Filter = l > 0 ? (float) (Math.Sin(Math.PI * l / 3) / (Math.PI * l / 3)) : 1.0; // Lancsoz filter (sinc)
double Filter = (float) Math.Exp( -(Math.PI * l / 3) * (Math.PI * l / 3) / 2.0 ); // Gaussian filter
Filter *= Scale;
for ( int m=-l; m <= l; m++)
{
double Coeff = Filter * SphericalHarmonics.SHFunctions.ComputeSH( l, m, Theta, Phi );
SumSH[l*(l+1)+m,0] += Coeff * Color.x;
SumSH[l*(l+1)+m,1] += Coeff * Color.y;
SumSH[l*(l+1)+m,2] += Coeff * Color.z;
}
}
}
}
}
//.........这里部分代码省略.........