gpvigano/AsImpL

Problems with importing own 3d models on Android device

QazyBi opened this issue · 11 comments

shows "loading FLASH.obj then failed to load" even if I checked location of 3d model and path which I wrote in object_list_test.xml (* I have deleted example 3d models), the line of code ( /storage/emulated/0/Android/data/com.QazBi.ASIMPL/files/FLASHobj/FLASH.obj)
both 3d model and "model" folders are located in "/com.QazBi.ASIMPL"

2018-01-18-00-19-47 1
2018-01-18-00-19-53 1

untitled
2018-01-18-00-23-17 1

On Android all the paths are relative to your persistentDataPath (in your case /storage/emulated/0/Android/data/com.QazBi.ASIMPL/files/), thus you should write paths relative to that path:

FLASHobj/FLASH.obj
instead of
/storage/emulated/0/Android/data/com.QazBi.ASIMPL/files/FLASHobj/FLASH.obj

The persistentDataPath (/storage/emulated/0/Android/data/com.QazBi.ASIMPL/files/) is added by AsImpL to the relative path.

I suggest you to check if your XML file is located in the same path set in the Config File field of Custom Obj Importer component (in Unity Editor), e.g.: if you copy your XML in /storage/emulated/0/Android/data/com.QazBi.ASIMPL/files/FLASHobj/object_list_test.xml you must change Config File field to FLASHobj/object_list_test.xml

I hope I did understand, let me know if it works for you.

THANKS, gpvigano I did as you said and I changed 3d model AND NOW IT WORKS AWESOME.
2 more things:
*is it possible to edit the path in .xml file at runtime? I have a filebrowser(FB) for an Android devices so I can get path from FB and put it into .xml file then project will be more flexible for a user
*how to invert uploaded file, it flipped over for 90 degrees ?
I'll send finished work to you
2018-01-18-22-19-08 1

2018-01-18-22-18-15 1

If you edit the XML at run-time (e.g. you use a text editor and save your changes) you can press the Reload button to see your changes.
Try changing the zUp element to get a rotation of 90 degrees.

Anyway please note that the example you are using is just an example: a starting point for further development, it's not a ready-to-use library feature.

Hi can you suggest me how to write a code to change only in xml ?

I really don't understand what you need to do. If you better explain what you are going to do, maybe I can help you. Please, try to write more details, do not condense your question in a single line, try to be more clear. Thanks.

Sorry, my fault. I just want to change the value of in xml file (e.g. object_list_test.xml) at runtime. for instance I get location of a file from file browser and alter existed to new one. Folowing script adds new , so I ask you help how can I edit current ?

public void WriteToXml()
{

	string filepath = Application.dataPath + @"/models/object_list_test.xml";
	XmlDocument xmlDoc = new XmlDocument();
	
	if(File.Exists (filepath))
	{
		xmlDoc.Load(filepath);
		XmlElement elmRoot = xmlDoc.DocumentElement;
		XmlElement elmNew = xmlDoc.CreateElement("ModelImportInfo"); 
		XmlElement ModelImportInfo_PATH = xmlDoc.CreateElement("path"); 
		ModelImportInfo_PATH.InnerText = path; 			
		elmNew.AppendChild(ModelImportInfo_PATH);
		elmRoot.AppendChild(elmNew); 
		xmlDoc.Save(filepath); // save file.
	}
}

I didn't understand what you want to edit (the XML file only, the scene, or both of them?), anyway the example provided in AsImpL is based on the ModelImportInfo serializable class, it has two methods UpdateFrom() and ApplyTo() to store get/set data of game objects.
If you choose another way for serialization you should implement also the synchronization with the scene.

I want to change xml file only, there is an idea to use replacechild method. Do you have any suggestions how to implement it?

Sorry, I never managed XML in that way, but I think you can find a lot of documentation in the Web, in particular at MSDN.

hi gpvigano, do know other ways to change xml element with script?

As I wrote I'm not an expert, but you can see the .NET C# documentation for this.