public override IResource create(ResourceManager mgr) { Bob.TextFile tf = new Bob.TextFile(); if (tf.loadFile(name) == false) { Warn.print("Error loading model file {0}", name); return(null); } BobModelLoader loader = new BobModelLoader(mgr, Path.GetDirectoryName(name)); Model m = loader.load(tf); if (m != null) { return(m); } return(null); }
public Model load(Bob.TextFile tf) { Model model = null; Skeleton skel = null; Dictionary <string, Animation> anims = new Dictionary <string, Animation>(); foreach (Bob.Chunk c in tf.chunks) { switch (c.myType) { case Bob.ChunkType.SKELETON: skel = loadSkeleton(c as Bob.SkeletonChunk); break; case Bob.ChunkType.ANIMATION: Animation a = loadAnimation(c as Bob.AnimationChunk); anims[a.name] = a; break; case Bob.ChunkType.MODEL: model = loadModel(c as Bob.ModelChunk); break; } } if (model is SkinnedModel) { (model as SkinnedModel).skeleton = skel; (model as SkinnedModel).createNullAnimation(); foreach (KeyValuePair <string, Animation> anim in anims) { anim.Value.skeleton = skel; (model as SkinnedModel).animations.Add(anim.Key, anim.Value); } } return(model); }