Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssimpContext.ExportFile broken #62

Open
Xeeynamo opened this issue Aug 9, 2020 · 3 comments
Open

AssimpContext.ExportFile broken #62

Xeeynamo opened this issue Aug 9, 2020 · 3 comments

Comments

@Xeeynamo
Copy link

Xeeynamo commented Aug 9, 2020

Using ExportFile method always results to a crash, regardless the format I am exporting to:
using var ctx = new AssimpContext(); ctx.ExportFile(new Scene(), fileName, "obj");

Exception:
System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'

I am using .Net Core 3.1 and AssimpNet 4.1.0.

@kenjiuno
Copy link

Hi.
It seems that we need at least RootNode:

Scene scene = new Scene();
scene.RootNode = new Node("Root");

using var ctx = new AssimpContext();
ctx.ExportFile(scene, fileName, "obj");

I have found test case that it creats scene from scratch.

[Test]
public void TestExportToFile()
{
String path = Path.Combine(TestHelper.RootPath, "TestFiles\\ExportedTriangle.obj");
//Create a very simple scene a single node with a mesh that has a single face, a triangle and a default material
Scene scene = new Scene();
scene.RootNode = new Node("Root");
Mesh triangle = new Mesh("", PrimitiveType.Triangle);
triangle.Vertices.Add(new Vector3D(1, 0, 0));
triangle.Vertices.Add(new Vector3D(5, 5, 0));
triangle.Vertices.Add(new Vector3D(10, 0, 0));
triangle.Faces.Add(new Face(new int[] { 0, 1, 2 }));
triangle.MaterialIndex = 0;
scene.Meshes.Add(triangle);
scene.RootNode.MeshIndices.Add(0);
Material mat = new Material();
mat.Name = "MyMaterial";
scene.Materials.Add(mat);
//Export the scene then read it in and compare!
AssimpContext context = new AssimpContext();
Assert.IsTrue(context.ExportFile(scene, path, "obj"));

@Xeeynamo
Copy link
Author

Thank you @kenjiuno , that was definitively the case.

Although it would be very good if this library was throwing a proper exception message for it (eg. ArgumentException rather than AccessViolationException). I am not going to close this issue, unless the maintainer of this repo would think that argument validation is not required.

@Starnick
Copy link

Starnick commented Aug 14, 2020

Access violation could be the native lib just assumes it exists. More validation and error messages are always welcomed.

This repo isn't the official assimpnet one, and is very old compared to the last few nuget releases. I'm on bit bucket. Several times now I've requested transfer of ownership or admin of this github repo without any action.

Feel free to do a PR for extra validation here https://bitbucket.org/Starnick/assimpnet/src

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants