public void LoadWorldGeometry()
{
bspGeometry = new BspGeometry();
if ( !optionList.ContainsKey( "Map" ) )
throw new AxiomException( "Unable to load world geometry. \"Map\" filename option is not set." );
if ( Path.GetExtension( ( (string)optionList[ "Map" ] ).ToLower() ) != ".bsp" )
throw new AxiomException( "Unable to load world geometry. Invalid extension of map filename option (must be .bsp)." );
if ( !optionList.ContainsKey( "SetYAxisUp" ) )
optionList[ "SetYAxisUp" ] = false;
if ( !optionList.ContainsKey( "Scale" ) )
optionList[ "Scale" ] = 1f;
if ( !optionList.ContainsKey( "Move" ) )
{
optionList[ "Move" ] = Vector3.Zero;
optionList[ "MoveX" ] = 0;
optionList[ "MoveY" ] = 0;
optionList[ "MoveZ" ] = 0;
}
if ( !optionList.ContainsKey( "UseLightmaps" ) )
optionList[ "UseLightmaps" ] = true;
if ( !optionList.ContainsKey( "AmbientEnabled" ) )
optionList[ "AmbientEnabled" ] = false;
if ( !optionList.ContainsKey( "AmbientRatio" ) )
optionList[ "AmbientRatio" ] = 1f;
InitTextureLighting();
if ( spotlightFrustum == null )
spotlightFrustum = new SpotlightFrustum();
NameValuePairList paramList = new NameValuePairList();
foreach ( DictionaryEntry option in optionList )
{
paramList.Add( option.Key.ToString(), option.Value.ToString() );
}
// Load using resource manager
level = (BspLevel)BspResourceManager.Instance.Load( (string)optionList[ "Map" ], ResourceGroupManager.Instance.WorldResourceGroupName, false, null, paramList );
// Init static render operation
renderOp.vertexData = level.VertexData;
// index data is per-frame
renderOp.indexData = new IndexData();
renderOp.indexData.indexStart = 0;
renderOp.indexData.indexCount = 0;
// Create enough index space to render whole level
renderOp.indexData.indexBuffer = HardwareBufferManager.Instance.CreateIndexBuffer(
IndexType.Size32,
level.NumIndexes,
BufferUsage.Dynamic, false
);
renderOp.operationType = OperationType.TriangleList;
renderOp.useIndices = true;
}