Giter Site home page Giter Site logo

unitymeshimporter's Introduction

UnityMeshImporter

Runtime mesh importer for Unity using AssimpNet. This mesh importer creates UnityEngine.GameObject from mesh files.

Update: Tested on Linux, macOS and Windows.

What is Assimp?

Open Asset Import Library (Assimp) is a cross-platform 3D model import library which aims to provide a common application programming interface (API) for different 3D asset file formats. Written in C++, it offers interfaces for both C and C++. Bindings to other languages (e.g., BlitzMax, C#, Python) are developed as part of the project or are available elsewhere.

By Wikipedia

This project uses C# .NET wrapper for the Assimp, AssimpNet

Supported file formates are listed here.

Quickstart

Before you start, you may need to install minizip package by

$ sudo apt install minizip
  1. Install "com.donghok.meshimporter" package as follows: In the Packages directory of your Unity project,

    $ git clone https://github.com/eastskykang/UnityMeshImporter.git com.donghok.meshimporter

    or

    Open Packages/manifest.json and add "com.donghok.meshimporter":"https://github.com/eastskykang/UnityMeshImporter.git" to the "dependencies" list.

  2. As the package is imported, you can use UnityMeshImporter as follows:

    using UnityMeshImporter;
    
    string meshFile = <YOUR-MESH-FILE-PATH>;
    var ob = MeshImporter.Load(meshFile);
  3. The mesh importer uses Unity "Standard" shader. Please add Standard shader to Project Settings > Graphics > Built-in Shader Settings > Always Included Shaders.

Unity Example

See the following examples:

unitymeshimporter's People

Contributors

eastskykang avatar scooterboo avatar tolinsimpson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unitymeshimporter's Issues

Larger models render in a broken state

Larger models render in a broken state. The models I'm testing happen to be Wavefront OBJs, but I don't think this is related to #6. Simpler or smaller models seem to import fine.

I've found that these models use meshes that have indices in faces that are higher than 2^16, which are disabled by Unity by default.

afbeelding

Setting the index format to be Uint32 for Mesh on MeshImporter.cs#L184 seems to fix it:

afbeelding

I could make a pull request for it, if you want, but I'm not using this project directly myself. In any case, I hope this helps someone, like this project provided guidance for me in getting Assimp data converted to Unity!

Wierd/Wrong import of COLLADA (.dae ) files

Hello,
I am currently using this project to import at runtime a COLLADA file, but for some reason, the import seems to be all messede up.
Using the Unity editor to import del file, seems to be working correctly, here is the exptected result:
correct

Yet, when I use the importer at runtime, this is the result:
runtime_collada

Wierdly enough, some other .dae files get imported correctly, for example the anymal_thigh_r.dae attached to this issue get imported correctly.

I've tried different extension of the same file, for example .obj and .ply, which seems work to but I cannot get the vertex colors rendered in that case (feature I need)

Attached to this issue there is also the file used in the screenshot. As I am quite new to working with 3D files, I have very little clue on what might be issue.

Here are the meshes that causes the wierd behaviour:
meshes.zip

Thanks in advance

DllNotFoundException: libdl.so on macOS 11.1 and Unity 2020.1.3f

Plugin fails to load Assimp

DllNotFoundException: libdl.so
Assimp.Unmanaged.UnmanagedLibrary+UnmanagedLinuxLibraryImplementation.NativeLoadLibrary (System.String path) (at <d40f2b0ad6814d4c8094142d8473733f>:0)
Assimp.Unmanaged.UnmanagedLibrary+UnmanagedLibraryImplementation.LoadLibrary (System.String path) (at <d40f2b0ad6814d4c8094142d8473733f>:0)
Assimp.Unmanaged.UnmanagedLibrary.LoadLibrary (System.String libPath) (at <d40f2b0ad6814d4c8094142d8473733f>:0)
Assimp.Unmanaged.UnmanagedLibrary.LoadLibrary () (at <d40f2b0ad6814d4c8094142d8473733f>:0)
Assimp.AssimpUnity.InitializePlugin () (at Library/PackageCache/com.donghok.meshimporter@2918f2fe44/Runtime/Plugins/AssimpNet/AssimpUnity.cs:158)

System info: macOS 11.1 and Unity 2020.1.3f

Wrong (?) assumptions about Assimp coordinate system

I have a question about the vertex and normal conversion happening in MeshImporter.cs: the conversion that happens negates the X coordinate and maintains the Y and Z coordinates. Why is this the case? Perhaps I'm misunderstanding, but in Unity +X is right, +Y is up, and +Z is farther away. In Assimp, +X is also right, +Y is up, and +Z is closer by, into the camera, doesn't this mean only the Z coordinate should be inverted?

The lines in question are MeshImporter.cs#L144 and MeshImporter.cs#L153.

Recompile in debug myself?

Hi,
Thanks for this Unity plugin which could be really useful to me.
I currently have issues with materials/textures because the material is pink (I'm target HDRP rendering pipeline).
And no texture seems to be loaded.

I can understand that you cannot fix everybody's issue so I'd like to compile the plugin myself so that I can debug/fix it a why not propose a merge request.

But I currently have no idea how to proceed. Could you help me on this?

Export function crashes Unity editor 2019.4 LTS

AssimpContext exporter = new AssimpContext();
exporter.ExportFile(scene, "savePath", "objnomtl");
ExportDataBlob blob = exporter.ExportToBlob(scene, "objnomtl");

both these methods crash Unity no matter how I try and save these in the Unity Editor (saving to StreamingAssets).
writing bytes with streamwriter and with File.Create() both fail, although I think the issue is with the implementation in the DLL.

How does the unmanaged DLL try to save the files? Can the wrapper be written differently to save the file the way you would in Unity.

Runtime Build Error Unity 2019.4 Windows x86 and Windows x86_64

@eastskykang

Installed via package manager using git link. I can see assimp.dll in the Plugins folder of the build.

COMException
Rethrow as AssimpException: Error loading unmanaged library from path: assimp.dll
Assimp.Unmanaged.UnmanagedLibrary+UnmanagedWindowsLibraryImplementation.NativeLoadLibrary (System.String path) (at :0)
Assimp.Unmanaged.UnmanagedLibrary+UnmanagedLibraryImplementation.LoadLibrary (System.String path) (at :0)
Assimp.Unmanaged.UnmanagedLibrary.LoadLibrary (System.String libPath) (at :0)
Assimp.Unmanaged.UnmanagedLibrary.LoadLibrary () (at :0)
Assimp.Unmanaged.UnmanagedLibrary.LoadIfNotLoaded () (at :0)
Assimp.Unmanaged.AssimpLibrary.CreatePropertyStore () (at :0)
Assimp.AssimpContext.CreateConfigs () (at :0)
Assimp.AssimpContext.PrepareImport () (at :0)
Assimp.AssimpContext.ImportFile (System.String file, Assimp.PostProcessSteps postProcessFlags) (at :0)

I'm having trouble understanding how the DLL is loaded why not use: https://docs.unity3d.com/Manual/PlatformDependentCompilation.html

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.