marklinmao
marklinmao

Reputation: 163

Model incomplete when loading with Forge AR/VR Toolkit

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.

The downloaded model is incomplete, only some components are visible

What it should be like

Thank you in advance!

Upvotes: 0

Views: 174

Answers (1)

Petr Broz
Petr Broz

Reputation: 9942

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;

Upvotes: 1

Related Questions