public BoneModel(PartBone element) : base(element) { UpdateBoundingBox(); SetTransformFromElement(); BoundingBox = BBox.FromCenterSize(Vector3.Zero, Vector3.One); BoneLength = 0.4f; UpdateModelTransforms(); CalculateBoneLength(); }
private void ImportModels() { ProjectManager.StartBatchChanges(); progressBar1.Style = ProgressBarStyle.Continuous; progressBar1.Value = 0; progressBar1.Maximum = SelectedModels.Count(); var bonesToImport = GetBoneMappings(); if (bonesToImport.Count > 0 && SelectedModels.Any(x => x.IsFlexible)) { Project.Flexible = true; foreach (var boneMap in bonesToImport) { var existing = Project.Bones.FirstOrDefault(x => x.BoneID == boneMap.AssimpID); if (existing == null) { existing = new PartBone(boneMap.AssimpID); } existing.Transform = boneMap.Transform; if (boneMap.ParentName != null) { var parentbone = bonesToImport.FirstOrDefault(x => x.Name == boneMap.ParentName); existing.TargetBoneID = parentbone.AssimpID; } if (existing.Project == null) { Project.Bones.Add(existing); } } } foreach (var model in SelectedModels) { var geom = Meshes.MeshConverter.AssimpToLdd(SceneToImport, model.Mesh); var surface = Project.Surfaces.FirstOrDefault(x => x.SurfaceID == model.SurfaceID); if (surface == null) { surface = new PartSurface(model.SurfaceID, Project.Surfaces.Max(x => x.SubMaterialIndex) + 1); Project.Surfaces.Add(surface); } var partModel = surface.Components.FirstOrDefault(x => x.ComponentType == ModelComponentType.Part); if (partModel == null) { partModel = new PartModel(); surface.Components.Add(partModel); } var modelMesh = Project.AddMeshGeometry(geom, model.Name); partModel.Meshes.Add(new ModelMeshReference(modelMesh)); progressBar1.Value += 1; } if (bonesToImport.Any()) { ProjectManager.RebuildBoneConnections(); } ProjectManager.EndBatchChanges(); }