Make complete GLB model viewable inside slide
Hi,
I have to import GLB 3d model file in powerpoint and make full model visible using my python script. I could import file to powerpoint but full model is not visible.
After unzip powerpoint file, we get slide.xml file. In this XML file, we have node named 'camera'. I have pasted below sample camera node content.
<am3d:pos x="0" y="0" z="11713743"/>
<am3d:up dx="0" dy="36000000" dz="0"/>
<am3d:lookAt x="0" y="0" z="0"/>
<am3d:perspective fov="2700000"/>
</am3d:camera>
I need to compute z attribute of 'am3d:pos' node. My logic to compute this value does not show full model. Camera gets placed very closed to model. Theoretically, my logic will work but actual output is not correct. Should i need to add/multiply any scale factor ?
I have kept FOV is fixed at 45degree. Below code has '36000000' to convert meter to powerpoint unit.
My code
glb_scene = trimesh.load(glb_path)
radius = math.sqrt(glb_scene.bounding_sphere.area/(4 * math.pi))
z_distance = (radius)/math.tan(math.radians(45/2))
camera_posz = int(z_distance * 36000000)