using System;
using System.Xml;
using CDAColladaNET.Import.Attributes;
// Copyright (c) 2005 Accelerated Pictures, LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
namespace ColladaNET.Import{
public class Library : ColladaNode
{
#region Constants
private static readonly string kLibraryType = "type";
#endregion
#region Enums
public enum ELibraryType { ANIMATION , CAMERA , CODE , CONTROLLER , GEOMETRY , IMAGE , LIGHT , MATERIAL , PROGRAM , TEXTURE };
#endregion
#region Static Methods
public static INamedNode GenerateTemplateNode( XmlNode source )
{
ELibraryType libraryType = ((ELibraryType)(Enum.Parse( typeof(ELibraryType) , source.LocalName , true )));
switch( libraryType )
{
case ELibraryType.ANIMATION:
return new Animation( source );
case ELibraryType.CAMERA:
return new Camera( source );
case ELibraryType.CODE:
return new Code( source );
case ELibraryType.CONTROLLER:
return new Controller( source );
case ELibraryType.GEOMETRY:
return new Geometry( source );
case ELibraryType.IMAGE:
return new Image( source );
case ELibraryType.LIGHT:
return new Light( source );
case ELibraryType.MATERIAL:
return new Material( source );
case ELibraryType.PROGRAM:
return new Program( source );
case ELibraryType.TEXTURE:
return new Texture( source );
default:
return null;
}
}
#endregion
#region Accessors
#region LibraryType
private bool mbLibraryType = false;
private ELibraryType mLibraryType;
public ELibraryType LibraryType
{
get
{
if ( mbLibraryType == false )
{
mLibraryType = (ELibraryType)(Enum.Parse(typeof(ELibraryType) , XmlSource.Attributes[ kLibraryType ].Value , true ));
mbLibraryType = true;
}
return mLibraryType;
}
}
#endregion
private CDA.LibraryContentsAttr mLibraryContents;
public CDA.LibraryContentsAttr LibraryContents { get { return mLibraryContents; } }
#endregion
#region Constructors
public Library( XmlNode source ) : base( source )
{
string path = "dae:"+Enum.GetName( typeof(ELibraryType) , LibraryType ).ToLower();
mLibraryContents = new CDA.LibraryContentsAttr( source , path );
}
#endregion
}
}
|