本文整理汇总了C#中Axiom.Math.Matrix4.TransformAffine方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix4.TransformAffine方法的具体用法?C# Matrix4.TransformAffine怎么用?C# Matrix4.TransformAffine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Axiom.Math.Matrix4
的用法示例。
在下文中一共展示了Matrix4.TransformAffine方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: _generatePlaneVertexData
private void _generatePlaneVertexData( HardwareVertexBuffer vbuf, int ySegments, int xSegments, float xSpace, float halfWidth, float ySpace, float halfHeight, Matrix4 transform, bool firstTime, bool normals, Matrix4 rotation, int numTexCoordSets, float xTexCoord, float yTexCoord, SubMesh subMesh, ref Vector3 min, ref Vector3 max, ref float maxSquaredLength )
{
Vector3 vec;
unsafe
{
// lock the vertex buffer
IntPtr data = vbuf.Lock( BufferLocking.Discard );
float* pData = (float*)data.ToPointer();
for ( int y = 0; y <= ySegments; y++ )
{
for ( int x = 0; x <= xSegments; x++ )
{
// centered on origin
vec.x = ( x * xSpace ) - halfWidth;
vec.y = ( y * ySpace ) - halfHeight;
vec.z = 0.0f;
vec = transform.TransformAffine( vec );
*pData++ = vec.x;
*pData++ = vec.y;
*pData++ = vec.z;
// Build bounds as we go
if ( firstTime )
{
min = vec;
max = vec;
maxSquaredLength = vec.LengthSquared;
firstTime = false;
}
else
{
min.Floor( vec );
max.Ceil( vec );
maxSquaredLength = Utility.Max( maxSquaredLength, vec.LengthSquared );
}
if ( normals )
{
vec = Vector3.UnitZ;
vec = rotation.TransformAffine( vec );
*pData++ = vec.x;
*pData++ = vec.y;
*pData++ = vec.z;
}
for ( int i = 0; i < numTexCoordSets; i++ )
{
*pData++ = x * xTexCoord;
*pData++ = 1 - ( y * yTexCoord );
} // for texCoords
} // for x
} // for y
// unlock the buffer
vbuf.Unlock();
subMesh.useSharedVertices = true;
} // unsafe
}
示例2: _generateCurvedPlaneVertexData
private void _generateCurvedPlaneVertexData( HardwareVertexBuffer vbuf, int ySegments, int xSegments, float xSpace, float halfWidth, float ySpace, float halfHeight, Matrix4 transform, bool firstTime, bool normals, Matrix4 rotation, float curvature, int numTexCoordSets, float xTexCoord, float yTexCoord, SubMesh subMesh, ref Vector3 min, ref Vector3 max, ref float maxSquaredLength )
{
Vector3 vec;
unsafe
{
// lock the vertex buffer
IntPtr data = vbuf.Lock( BufferLocking.Discard );
float* pData = (float*)data.ToPointer();
for ( int y = 0; y <= ySegments; y++ )
{
for ( int x = 0; x <= xSegments; x++ )
{
// centered on origin
vec.x = ( x * xSpace ) - halfWidth;
vec.y = ( y * ySpace ) - halfHeight;
// Here's where curved plane is different from standard plane. Amazing, I know.
Real diff_x = ( x - ( (Real)xSegments / 2 ) ) / (Real)xSegments;
Real diff_y = ( y - ( (Real)ySegments / 2 ) ) / (Real)ySegments;
Real dist = Utility.Sqrt( diff_x * diff_x + diff_y * diff_y );
vec.z = ( -Utility.Sin( ( 1 - dist ) * ( Utility.PI / 2 ) ) * curvature ) + curvature;
// Transform by orientation and distance
Vector3 pos = transform.TransformAffine( vec );
*pData++ = pos.x;
*pData++ = pos.y;
*pData++ = pos.z;
// Build bounds as we go
if ( firstTime )
{
min = vec;
max = vec;
maxSquaredLength = vec.LengthSquared;
firstTime = false;
}
else
{
min.Floor( vec );
max.Ceil( vec );
maxSquaredLength = Utility.Max( maxSquaredLength, vec.LengthSquared );
}
if ( normals )
{
// This part is kinda 'wrong' for curved planes... but curved planes are
// very valuable outside sky planes, which don't typically need normals
// so I'm not going to mess with it for now.
// Default normal is along unit Z
//vec = Vector3::UNIT_Z;
// Rotate
vec = rotation.TransformAffine( vec );
*pData++ = vec.x;
*pData++ = vec.y;
*pData++ = vec.z;
}
for ( int i = 0; i < numTexCoordSets; i++ )
{
*pData++ = x * xTexCoord;
*pData++ = 1 - ( y * yTexCoord );
} // for texCoords
} // for x
} // for y
// unlock the buffer
vbuf.Unlock();
subMesh.useSharedVertices = true;
} // unsafe
}
示例3: TransformAffine
public void TransformAffine( Matrix4 m )
{
Debug.Assert( m.IsAffine );
// Do nothing if current null or infinite
if ( this.isNull || this.isInfinite )
{
return;
}
Vector3 centre = Center;
Vector3 halfSize = HalfSize;
Vector3 newCentre = m.TransformAffine( centre );
var newHalfSize =
new Vector3(
Utility.Abs( m[ 0, 0 ] )*halfSize.x + Utility.Abs( m[ 0, 1 ] )*halfSize.y + Utility.Abs( m[ 0, 2 ] )*halfSize.z,
Utility.Abs( m[ 1, 0 ] )*halfSize.x + Utility.Abs( m[ 1, 1 ] )*halfSize.y + Utility.Abs( m[ 1, 2 ] )*halfSize.z,
Utility.Abs( m[ 2, 0 ] )*halfSize.x + Utility.Abs( m[ 2, 1 ] )*halfSize.y + Utility.Abs( m[ 2, 2 ] )*halfSize.z );
SetExtents( newCentre - newHalfSize, newCentre + newHalfSize );
}