3D objects are now loaded directly from .obj
>10s loading time on a nexus 5x, needs rework
This commit is contained in:
@@ -34,8 +34,7 @@ namespace RothenburgAR.PointOfInterest
|
||||
{
|
||||
if (!HasModelDescription)
|
||||
return null;
|
||||
var modelPrefab = GetModelPrefab();
|
||||
var gameObject = UnityEngine.Object.Instantiate(modelPrefab);
|
||||
var gameObject = GetModelPrefab();
|
||||
gameObject.transform.localRotation = Quaternion.identity;
|
||||
gameObject.transform.localScale = ModelDescription.Scale;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.IO;
|
||||
using RothenburgAR.Common;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RothenburgAR.PointOfInterest
|
||||
@@ -7,17 +8,21 @@ namespace RothenburgAR.PointOfInterest
|
||||
{
|
||||
public GameObject LoadModel(PoiModelDescription description)
|
||||
{
|
||||
if (!File.Exists(description.ModelPath))
|
||||
var path = PathHelper.CombinePaths(PathHelper.MediaPath, description.ModelPath, description.ModelPath + ".obj");
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
throw new FileNotFoundException(description.ModelPath + " does not exist;");
|
||||
}
|
||||
|
||||
return OBJLoader.LoadOBJFile(path);
|
||||
|
||||
var asset = AssetBundle.LoadFromFile(description.ModelPath);
|
||||
if (!asset)
|
||||
{
|
||||
Debug.Log("Failed to load AssetBundle!");
|
||||
return null;
|
||||
}
|
||||
|
||||
var prefab = asset.LoadAsset(description.ModelPrefabName) as GameObject;
|
||||
|
||||
prefab.transform.localScale = description.Scale;
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace RothenburgAR.PointOfInterest
|
||||
|
||||
var poiModelDescription = new PoiModelDescription
|
||||
{
|
||||
ModelPath = Path.Combine(poiDirectory, pathNode.Attributes["value"].Value),
|
||||
ModelPath = pathNode.Attributes["value"].Value,
|
||||
ModelPrefabName = pathNode.Attributes["prefabName"].Value,
|
||||
Scale = GetVector3FromXmlNode(scaleNode).GetValueOrDefault(Vector3.one),
|
||||
Rotation = GetVector3FromXmlNode(rotationNode).GetValueOrDefault(Vector3.zero),
|
||||
|
||||
Reference in New Issue
Block a user