protected Mesh CreateSkyboxPlane( BoxPlane plane, float distance, Quaternion orientation, string groupName )
{
Plane p = new Plane();
string meshName = "SkyboxPlane_";
Vector3 up = Vector3.Zero;
// set the distance of the plane
p.D = distance;
switch ( plane )
{
case BoxPlane.Front:
p.Normal = Vector3.UnitZ;
up = Vector3.UnitY;
meshName += "Front";
break;
case BoxPlane.Back:
p.Normal = -Vector3.UnitZ;
up = Vector3.UnitY;
meshName += "Back";
break;
case BoxPlane.Left:
p.Normal = Vector3.UnitX;
up = Vector3.UnitY;
meshName += "Left";
break;
case BoxPlane.Right:
p.Normal = -Vector3.UnitX;
up = Vector3.UnitY;
meshName += "Right";
break;
case BoxPlane.Up:
p.Normal = -Vector3.UnitY;
up = Vector3.UnitZ;
meshName += "Up";
break;
case BoxPlane.Down:
p.Normal = Vector3.UnitY;
up = -Vector3.UnitZ;
meshName += "Down";
break;
}
// modify by orientation
p.Normal = orientation * p.Normal;
up = orientation * up;
MeshManager modelMgr = MeshManager.Instance;
// see if this mesh exists
Mesh planeModel = (Mesh)modelMgr[ meshName ];
// trash it if it already exists
if ( planeModel != null )
{
modelMgr.Unload( planeModel );
}
float planeSize = distance * 2;
// create and return the plane mesh
return modelMgr.CreatePlane( meshName, groupName, p, planeSize, planeSize, 1, 1, false, 1, 1, 1, up );
}