Model Origin Problem

I am using Unity 2019.2.6f1. I am having a problem related to the model origin. In the image when I try to position the model of a house at Vector zero. Its not going to the zero position. As you can see the cube is placed at Vector zero which is different from the building which is also placed at the vector zero. So how should I solve this problem? Is there any problem with export settings for 3d modeling software? One solution I know is to drag the house to the cube position and then make it a child of the zeroed out empty object . But I want to do it at runtime so I don’t know how to handle that.

I don’t think there’s a good way to do this at runtime because your offset just seems arbitrary. You might try the Render.bounds.center to find the actual center of the geometry
https://docs.unity3d.com/ScriptReference/Renderer-bounds.html

In that case you’d right something like:

houseRenderer = house.GetComponent<Renderer>();
house.transform.parent = cube.transform
house.transform.localPosition=Vector3.zero-houseRenderer.bounds.center;

It would be a lot easier if you were able to simply correct your model’s origin in whatever 3D modeling package that you used to create the house. Did you use Blender by any chance?

Thanks for reply.I wanted it for run-time because users are going to upload FBX file from web-panel and I have to show it in AR. If the origin is not correct than it will not spawn in front of the camera and also the problem with rotation. This object has so many objects in the hierarchy. And to bound the mesh elements only will not be a good idea I think. Is it?

Is it better to upload the FBX to server and then download and show it in the application or I should use Asset-bundles for this purpose? Currently I am having a problem i.e when I export model from unity using FBX exporter plugin. It doesn’t retain the material setting. So for example If I have made a glass material then after exporting its transparency is gone. So when I download and import it still no transparency? So which will be best for my use case FBX or Asset-bundle?

Well, what else you got? :wink:

By the way, if you have more than one renderer I think you can just average the x,y, and z of their centers to find the center of the centers.

FBX files simply do not store this type of settings. With an asset bundle you can store both the model and the material, though.

I am also struggling with another problem. For some models whenever I scale the model it’s material become black. How to prevent this? How can I know when it gets at the point where it material gets black so I prevent user from scaling further?

Is there a way to automatically generate Asset-bundles for the model? Because my user can only provide FBX.

As you can see there are objects which are placed elsewhere? I think its better to fix it in 3d modeling software.
5004122--489242--1.PNG

I don’t know, but If the user only provides FBX, then where does the material come from? Can you simply have the user upload their FBX and then maybe you could provide the interface to let the user choose their own material properties.

I think so too, but I thought you were trying to plan for if the user provides bad data.

The FBX files are with embedded materials. I am attaching a FBX . I have change the extension to rar because fbx is not allowed to upload so you can see it by changing the extension to fbx.

5004140–489245–RoadSideHouse.rar (2.11 MB)

Yes, I wanted to deal this those models. Because not every user follow the instruction.