public void UnloadModel() { isAnimated = false; clipNames.Clear(); animationPlayer = null; model = null; }
/// <summary> /// Set the model and return any error messages /// </summary> public string SetModel(bool animated, Model aModel) { string result = ""; isAnimated = animated; if (aModel != null) { model = aModel; MeasureModel(); InitialiseCameraPosition(); } if (isAnimated) { // Look up our custom skinning information. SkinningData skinningData = model.Tag as SkinningData; if (skinningData == null) { result += "\nThis model does not contain a SkinningData tag."; isAnimated = false; } // Check again to make sure it is still treated as animated if (isAnimated) { // Create an animation player, and start decoding an animation clip. animationPlayer = new AnimationPlayer(skinningData); clipNames.AddRange(skinningData.AnimationClips.Keys); if (clipNames.Count > 0) { //AnimationClip clip = skinningData.AnimationClips["Take 001"]; AnimationClip clip = skinningData.AnimationClips[clipNames[0]]; result += "\nClip: " + clipNames[0]; string error = animationPlayer.StartClip(clip); if (!string.IsNullOrEmpty(error)) { result += "\n" + error; } } else { result += "\nThis model does not have any takes!"; } } } return result; }