本文整理汇总了C#中Vector4D.GetLength方法的典型用法代码示例。如果您正苦于以下问题:C# Vector4D.GetLength方法的具体用法?C# Vector4D.GetLength怎么用?C# Vector4D.GetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector4D
的用法示例。
在下文中一共展示了Vector4D.GetLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExtractCross
private void ExtractCross( Vector4D[,] _HDRValues, int _CubeFaceSize, Vector4D[][,] _CubeFaces )
{
int Width = _HDRValues.GetLength( 0 ), Height = _HDRValues.GetLength( 1 );
// Extract cube faces
Vector4D[][,] TempCubeFaces = new Vector4D[6][,];
int SourceCubeFaceSize = 0;
if ( Height > Width )
{ // Vertical cross
SourceCubeFaceSize = Height / 4;
if ( Width != SourceCubeFaceSize * 3 )
throw new Exception( "The cube map " + Width + "x" + Height + " was detected as a VERTICAL CROSS with a cube face size of " + SourceCubeFaceSize + " (Height/4) but the width is not of the expected size of 3x" + SourceCubeFaceSize + " (3xWidth)! Are you sure you're using a CROSS cube map?" );
TempCubeFaces[0] = ReadCubeFace( _HDRValues, SourceCubeFaceSize, 2, 1 ); // +X
TempCubeFaces[1] = ReadCubeFace( _HDRValues, SourceCubeFaceSize, 0, 1 ); // -X
TempCubeFaces[2] = ReadCubeFace( _HDRValues, SourceCubeFaceSize, 1, 0 ); // +Y
TempCubeFaces[3] = ReadCubeFace( _HDRValues, SourceCubeFaceSize, 1, 2 ); // -Y
TempCubeFaces[4] = ReadCubeFace( _HDRValues, SourceCubeFaceSize, 1, 1 ); // +Z
TempCubeFaces[5] = ReadCubeFace( _HDRValues, SourceCubeFaceSize, 1, 3, true ); // -Z
}
else
{ // Horizontal cross
SourceCubeFaceSize = Width / 4;
if ( Height != SourceCubeFaceSize * 3 )
throw new Exception( "The cube map " + Width + "x" + Height + " was detected as a HORIZONTAL CROSS with a cube face size of " + SourceCubeFaceSize + " (Width/4) but the height is not of the expected size of 3x" + SourceCubeFaceSize + " (3xHeight)! Are you sure you're using a CROSS cube map?" );
TempCubeFaces[0] = ReadCubeFace( _HDRValues, SourceCubeFaceSize, 2, 1 ); // +X
TempCubeFaces[1] = ReadCubeFace( _HDRValues, SourceCubeFaceSize, 0, 1 ); // -X
TempCubeFaces[2] = ReadCubeFace( _HDRValues, SourceCubeFaceSize, 1, 0 ); // +Y
TempCubeFaces[3] = ReadCubeFace( _HDRValues, SourceCubeFaceSize, 1, 2 ); // -Y
TempCubeFaces[4] = ReadCubeFace( _HDRValues, SourceCubeFaceSize, 1, 1 ); // +Z
TempCubeFaces[5] = ReadCubeFace( _HDRValues, SourceCubeFaceSize, 3, 1 ); // -Z
}
// Convert to final size
m_CubeSize = SourceCubeFaceSize;
m_CubeFaces = TempCubeFaces;
BuildTargetCubeMapMip0( _CubeFaceSize, _CubeFaces, ( Vector _Direction ) => {
Vector4D Result = PointSampleCubeMap( _Direction );
return Result;
} );
}
示例2: ExtractProbe
private void ExtractProbe( Vector4D[,] _HDRValues, int _CubeFaceSize, Vector4D[][,] _CubeFaces )
{
int Width = _HDRValues.GetLength( 0 ), Height = _HDRValues.GetLength( 1 );
BuildTargetCubeMapMip0( _CubeFaceSize, _CubeFaces, ( Vector _Direction ) => {
// Stolen from http://www.pauldebevec.com/Probes/
double R = (1.0/ Math.PI) * Math.Acos( _Direction.z ) / Math.Sqrt( _Direction.x*_Direction.x + _Direction.y*_Direction.y );
double U = _Direction.x * R;
double V = _Direction.y * R;
// Bilinear interpolate
float X = (float) (Width * (0.5 * (1.0 + U)));
float Y = (float) (Height * (0.5 * (1.0 - V)));
int X0 = (int) Math.Floor( X );
int Y0 = (int) Math.Floor( Y );
float x = X - X0;
float y = Y - Y0;
X0 = Math.Min( Width-1, X0 );
Y0 = Math.Min( Height-1, Y0 );
int X1 = Math.Min( Width-1, X0+1 );
int Y1 = Math.Min( Height-1, Y0+1 );
Vector4D V00 = _HDRValues[X0,Y0];
Vector4D V01 = _HDRValues[X1,Y0];
Vector4D V10 = _HDRValues[X0,Y1];
Vector4D V11 = _HDRValues[X1,Y1];
Vector4D V0 = V00 + x * (V01 - V00);
Vector4D V1 = V10 + x * (V11 - V10);
Vector4D Result = V0 + y * (V1 - V0);
return Result;
} );
}