-
Notifications
You must be signed in to change notification settings - Fork 196
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
How to load a PLY via script? #46
Comments
The ply importer only supports Editor; There is no runtime support. I didn't implement it because I thought it's too slow and memory-intensive to use in a practical application. Do you think it could be a useful feature? |
Yes, in my opinion this is an important feature. I want to do it especially for mobile devices and point clouds with around 10k-1M points. (static point clouds, no streaming) Analogy: Google is successfully doing runtime imports of Tiltbrush and other content via Poly database for almost all platforms. In another issue you mention that the most time consuming part is the Initialize method, right? |
I managed to load the PLY files during runtime. The point shader works for deployment on Android, but not on iOS. I created a runtime method based on the the mesh import. @keijiro : do you know how create a iOS compatible shader? |
The point shader should work on iOS, the point size property doesn't work though. |
@keijiro : Can you explain how did you achieve to load the PLY file during runtime? |
Here an example on how to lazy-load PLY files:
public class PlyImporter : ScriptedImporter
...
public PointCloudData ImportAsPointCloudData(string path) {
...
void Start()
{
var pclRenderer = gameObject.GetComponent<PointCloudRenderer>();
var importer = new PlyImporter();
var cloud = importer.ImportAsPointCloudData("path/to/my/file.ply");
pclRenderer.sourceData = cloud;
} @keijiro It is a nice feature for an exhibition where you have a realtime-scanning device. |
Just seconding everyone else on this thread in regards to being able to do all this in runtime, I think it will be a very useful feature. I am personally trying to download a .ply file from the web and visualising it in realtime. Exposing the ImportAsMesh as a public method and using it with the downloaded file path allows me to do it pretty easily.
@keijiro thank you again for creating this incredibly useful package |
Thanks @keijiro for the awesome library, I was able to get the runtime import working using @cansik's method. However, when I try to build to the UWP, I get a bunch of errors of the type
Is there something else that needs to be done or somewhere the files need to be moved for the runtime import build to work? |
Hey. I'm having the same issue as everyone else. I'm working with a teacher who hopes to use this to have her students be able to import their own point clouds and visualize them. I got everything working using this
but when I build i get errors. What i can tell the issue is, is that "UnityEditor.AssetImporters.ScriptedImporter" in plyimporter isn't made to work anywhere outside of the editor, so when building i get a nullreference exception. I'm hoping for some quick assistance here so i can assure her that we will get to where we need to be. Fantastic work by the way. Thanks |
Hey @Blabab So the way I got around this issue was to essentially to make a copy of the pcx package and import it in manually in the Assets folder (instead of it being in the package manifest as was the recommended installation method on the README of this repo) - this will allow us to edit the code within the Pcx package. Once that is done, all you will need to do is find the ImportAsMesh function (in the PlyImporter.cs file) and expose it as a public method. I would recommend creating a new file and class (eg PlyImporterRuntime) as to not interfere with the editor version of the PlyImporter files.
Hope that helps! |
@septianrazi Hey. Thanks for getting back to me. I tried your method but I still run into the same issue. This is my process. -I import (one way or the other) the PCX project into unity
-I prepare a gameobject with a meshfilter that i reference in the script below, where I also write the following: It works perfectly in play mode in the editor, but as soon as i build i get "the type of namespace "PlyImporterRuntime" name could not be found" If I change PCX.Editor to also work at windows(64) builds, i get a host of other errors instead. Could you perhaps take me through the process or let me know where I'm missing something. My assumption lies with how ScriptedImporters seem to be something that's for editor use only. Thanks again. |
@Blabab Hello, did you solve the problems? I have exactly identical problems with you.... Thank you again |
@septianrazi Hello I'm trying to build run-time by following your process. However, there are several errors in my project..
Could you help me by explaining your method again..? Thanks again. |
So I'm not entirely sure what these issues are unfortunately Best thing I can offer is the project that ive made public in which i did use this technique, feel free to have a look at it and see if you can find out the issue/just copy the technique: |
Hello. Thanks to you! These are the errors. It seems to be the streamreader can't read the header of the point cloud data. It was confirmed that the file was well stored in the storage location. The same error came out when I tried another Ply file (for example, all-basil) file in your project, so I'd like to ask you again if there's a way to solve it. Thank you for your help. There's an error message `Error Unity at Pcx.PlyImporterRuntime.ReadDataHeader (System.IO.StreamReader reader) [0x00000] in <00000000000000000000000000000000>:0 ' ` Error Unity at Pcx.PlyImporterRuntime.ImportAsMesh (System.String path) [0x00000] in <00000000000000000000000000000000>:0 ' |
I found way how to build it, issue is that you need UnityEditor.AssetImporters in PlyImporter but that is only avilible in editor, not in builded version. BUT you dont need all of the PlyImporter. So you can remove parts requiring inaccesible namespaces. Granted, it works only on Mesh import, but better then nothing. |
I have PLY files in the correct format that work in the editor, but how can I load them via script during runtime?
I searched the available issues here, but didn't find a solution yet.
The text was updated successfully, but these errors were encountered: