Refactor HelixViewer extend format support
Some checks failed
MSBuild / build (push) Has been cancelled
MSBuild / publish (push) Has been cancelled

This commit is contained in:
ema
2025-07-12 03:47:49 +08:00
parent 0714574374
commit 55a069046f
5 changed files with 148 additions and 49 deletions

View File

@@ -15,13 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using Assimp;
using HelixToolkit.Wpf;
using System;
using System.Linq;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Media3D;
namespace QuickLook.Plugin.HelixViewer;
@@ -39,43 +33,4 @@ public partial class HelixPanel : UserControl
{
InitializeComponent();
}
private void Load()
{
if (_path.EndsWith(".fbx", StringComparison.OrdinalIgnoreCase))
{
var context = new AssimpContext();
var scene = context.ImportFile(_path, PostProcessSteps.Triangulate);
foreach (var mesh in scene.Meshes)
{
var geometry = new MeshGeometry3D()
{
Positions = [.. mesh.Vertices.Select(v => new Point3D(v.X, v.Y, v.Z))],
TriangleIndices = [.. mesh.GetIndices()],
};
var model = new GeometryModel3D()
{
Geometry = geometry,
Material = Materials.Gray,
};
modelVisual.Content = model;
}
}
else
{
var modelImporter = new ModelImporter();
var model3DGroup = modelImporter.Load(_path);
var diffuseMaterial = new DiffuseMaterial(new SolidColorBrush(Color.FromRgb(0xA0, 0xA0, 0xA0)));
foreach (GeometryModel3D child in model3DGroup.Children.Cast<GeometryModel3D>())
{
child.Material = diffuseMaterial;
child.BackMaterial = diffuseMaterial;
}
modelVisual.Content = model3DGroup;
}
}
}