本文整理汇总了C#中BulletXNA.LinearMath.IndexedVector3.MaxAxis方法的典型用法代码示例。如果您正苦于以下问题:C# IndexedVector3.MaxAxis方法的具体用法?C# IndexedVector3.MaxAxis怎么用?C# IndexedVector3.MaxAxis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BulletXNA.LinearMath.IndexedVector3
的用法示例。
在下文中一共展示了IndexedVector3.MaxAxis方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
//.........这里部分代码省略.........
int NbTris = numVertices - 2;
IndexedVector3 p0 = m_vertices[m_faces[i].m_indices[0]];
for (int j = 1; j <= NbTris; j++)
{
int k = (j + 1) % numVertices;
IndexedVector3 p1 = m_vertices[m_faces[i].m_indices[j]];
IndexedVector3 p2 = m_vertices[m_faces[i].m_indices[k]];
float Area = IndexedVector3.Cross((p0 - p1), (p0 - p2)).Length() * 0.5f;
IndexedVector3 Center = (p0 + p1 + p2) / 3.0f;
m_localCenter += Area * Center;
TotalArea += Area;
}
}
m_localCenter /= TotalArea;
#if TEST_INTERNAL_OBJECTS
if(true)
{
m_radius = float.MaxValue;
for(int i=0;i<m_faces.Count;i++)
{
IndexedVector3 Normal = new IndexedVector3(m_faces[i].m_plane[0], m_faces[i].m_plane[1], m_faces[i].m_plane[2]);
float dist = Math.Abs(m_localCenter.Dot(Normal) + m_faces[i].m_plane[3]);
if(dist<m_radius)
{
m_radius = dist;
}
}
float MinX = float.MaxValue;
float MinY = float.MaxValue;
float MinZ = float.MaxValue;
float MaxX = float.MinValue;
float MaxY = float.MinValue;
float MaxZ = float.MinValue;
for(int i=0; i<m_vertices.Count; i++)
{
IndexedVector3 pt = m_vertices[i];
if(pt.X<MinX) MinX = pt.X;
if(pt.X>MaxX) MaxX = pt.X;
if(pt.Y<MinY) MinY = pt.Y;
if(pt.Y>MaxY) MaxY = pt.Y;
if(pt.Z<MinZ) MinZ = pt.Z;
if(pt.Z>MaxZ) MaxZ = pt.Z;
}
mC = new IndexedVector3(MaxX+MinX, MaxY+MinY, MaxZ+MinZ);
mE = new IndexedVector3(MaxX-MinX, MaxY-MinY, MaxZ-MinZ);
// const float r = m_radius / sqrtf(2.0f);
float r = m_radius / (float)Math.Sqrt(3.0f);
int LargestExtent = mE.MaxAxis();
float Step = (mE[LargestExtent]*0.5f - r)/1024.0f;
m_extents.X = m_extents.Y = m_extents.Z = r;
m_extents[LargestExtent] = mE[LargestExtent]*0.5f;
bool FoundBox = false;
for(int j=0;j<1024;j++)
{
if(TestContainment())
{
FoundBox = true;
break;
}
m_extents[LargestExtent] -= Step;
}
if(!FoundBox)
{
m_extents.X = m_extents.Y = m_extents.Z = r;
}
else
{
// Refine the box
float innerStep = (m_radius - r)/1024.0f;
int e0 = (1<<LargestExtent) & 3;
int e1 = (1<<e0) & 3;
for(int j=0;j<1024;j++)
{
float Saved0 = m_extents[e0];
float Saved1 = m_extents[e1];
m_extents[e0] += innerStep;
m_extents[e1] += innerStep;
if(!TestContainment())
{
m_extents[e0] = Saved0;
m_extents[e1] = Saved1;
break;
}
}
}
}
#endif
}