public static string ExportFile(FullModelData data, string path) { AnimationFile animationFile = new AnimationFile(); foreach (Object3D object3D in data.SectionsOfType <Object3D>()) { if (object3D.Animations.Count > 0) { AnimationFileObject animationFileObject = new AnimationFileObject(object3D.HashName.String); foreach (IAnimationController animationController in object3D.Animations) { if (animationController is LinearVector3Controller) { LinearVector3Controller linearVector3Controller = (LinearVector3Controller)animationController; animationFileObject.PositionKeyframes = new List <Keyframe <Vector3> >(linearVector3Controller.Keyframes); } else if (animationController is QuatLinearRotationController) { QuatLinearRotationController quatLinearRotationController = (QuatLinearRotationController)animationController; animationFileObject.RotationKeyframes = new List <Keyframe <Quaternion> >(quatLinearRotationController.Keyframes); } } animationFile.Objects.Add(animationFileObject); } } animationFile.Write(path); return(path); }
public IEnumerable <IInspectorNode> GetChildren() { var cname = typeof(TSection).Name; return(data.SectionsOfType <TSection>().Select(i => new GenericNode { Key = $"{cname}_{i.SectionId}", IconName = null, Label = labeller(i), PropertyItem = i })); }
private void UpdateRootPointBox() { string old_selected_name; if (rootPoints.SelectedIndex > 0) { old_selected_name = root_point_items[rootPoints.SelectedIndex].Name; } else { // Use the root point, if it exists. Otherwise, this won't match and // we'll use the default new_index of 0. old_selected_name = "root_point"; } int new_index = 0; root_point_items.Clear(); root_point_items.Add(new RootPointItem("None", 0)); if (scriptFile.Selected != null) { // If we're using a script, we unfortunately have to fully load the file to evaluate the script string model_file = baseModelFileBrowser.Enabled ? baseModelFileBrowser.Selected : null; FullModelData data = model_file != null?ModelReader.Open(model_file) : new FullModelData(); // TODO display the errors in a less intrusive way bool success = Modelscript.Script.ExecuteFileWithMsgBox(ref data, scriptFile.Selected); if (!success) { return; } foreach (Object3D obj in data.SectionsOfType <Object3D>()) { root_point_items.Add(new RootPointItem(obj.Name, obj.SectionId)); if (old_selected_name == obj.Name) { new_index = root_point_items.Count - 1; } } } else if (baseModelFileBrowser.Enabled && baseModelFileBrowser.Selected != null) { // If there is no script file, just skim the model and collect the object IDs like that. // This isn't a major improvement, but it does increase performance. StaticStorage.hashindex.Load(); ModelReader.VisitModel(baseModelFileBrowser.Selected, (reader, header) => { if (header.type == Tags.object3D_tag) { // First field of Object3D ulong hashname = reader.ReadUInt64(); string name = StaticStorage.hashindex.GetString(hashname); RootPointItem item = new RootPointItem(name, header.id); root_point_items.Add(item); Log.Default.Debug("Scanning for rootpoint: {0}", name); if (old_selected_name == name) { new_index = root_point_items.Count - 1; } } }); } rootPoints.Items.Clear(); rootPoints.Items.AddRange(root_point_items.ToArray()); rootPoints.SelectedIndex = new_index; }
public IEnumerable <IInspectorNode> GetChildren() { return(data.SectionsOfType <Sections.Object3D>().Where(i => i.Parent == obj).Select(i => new ObjectNode(data, i))); }