Model incomplete when loading with Forge AR/VR Toolkit

元气小坏坏 提交于 2019-12-11 16:07:25

问题


I have an IFC model, and I use the sample script 'test-2legged' in Scene Preparation (http://forgetoolkit.com/#/scenePrepration) to upload it to Forge. Then I loaded it with AR/VR toolkit (ForgeARKit-update-6-2018.1). However the downloaded model is incomplete (see below pictures). There is no external links in the model.

Please also note that I did some minor modification in 'test-2legged', as the original sample does not work directly with the new beta server 'https://developer-api-beta.autodesk.io' (please refer to another post: Forge ARKit: Cannot load model in Unity).

It seems for some components in the model it is visible but for some others it 's not, one thing I noticed is that some components has non-Unicode(Finnish) value in properties such as Type/Type name, not sure if that is the root-cause.

Can anyone help to check what can be wrong? I can upload the sample model.

Thank you in advance!


回答1:


For anyone running into a similar issue, there was a problem with how affine transforms from https://developer-api-beta.autodesk.io were being parsed in Unity. If you're seeing similar issues (meshes in the scene having positions/rotations/scales all set to zeros), go to Assets/Forge/CodeBase/InstanceTreeRequest.cs and replace the "AffineMatrix" switch case with the following code:

case "AffineMatrix":
    Matrix4x4 mat = new Matrix4x4 ();

    var elements = node["mt"]["elements"].AsArray;
    mat.m00 = elements[0].AsFloat;
    mat.m10 = elements[1].AsFloat;
    mat.m20 = elements[2].AsFloat;
    mat.m01 = elements[3].AsFloat;
    mat.m11 = elements[4].AsFloat;
    mat.m21 = elements[5].AsFloat;
    mat.m02 = elements[6].AsFloat;
    mat.m12 = elements[7].AsFloat;
    mat.m22 = elements[8].AsFloat;

    mat.m03 = node["tr"]["x"].AsFloat;
    mat.m13 = node["tr"]["y"].AsFloat;
    mat.m23 = node["tr"]["z"].AsFloat;
    mat.m33 = 1.0f;

    obj.transform.localScale = ScaleFromMatrix (mat);
    obj.transform.rotation = RotationFromMatrix (mat);
    obj.transform.position = TranslationFromMatrix (mat);
    break;


来源:https://stackoverflow.com/questions/56440193/model-incomplete-when-loading-with-forge-ar-vr-toolkit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!