I use the following code to create a camera and add to a scene, but I could not see the elements when open it with SketchUp and I need use ‘Zoom Extents’ to show the model.
if (SU_ERROR_NONE == SUCameraCreate (&camera) && camera.ptr)
{
SUPoint3D position = ConvertPoint (&eye);
SUPoint3D newTarget = ConvertPoint (&target);
SUVector3D up_vector = ConvertVector (&up);
SU_CALL(SUCameraSetOrientation (camera, &position, &newTarget, &up_vector));
SU_CALL(SUCameraSetPerspective (camera, viewFlags.camera));
if (viewFlags.camera)
SU_CALL(SUCameraSetPerspectiveFrustumFOV (camera, fieldOfView));
else
SU_CALL(SUCameraSetOrthographicFrustumHeight (camera, height));
if (SU_ERROR_NONE == SUSceneCreate (&scene) && scene.ptr)
{
SUSceneSetName (scene, Utf8String (pName).c_str());
SUSceneSetCamera (scene, camera);
SUSceneSetUseCamera (scene, true);
SUModelAddScene (m_pDocument, -1, scene, &out_index);
}
}
How do I create a camera to show the entire model when open it with SketchUp? I use the similar data to create a camera with old COM API could show the entire model without ‘Zoom Extents’.
double nearDistance = 1.0;
double farDistance = 1000.0;
camera.Set(atlast::geometry::CPoint3d (eye.x, eye.y, eye.z),
atlast::geometry::CPoint3d (target.x, target.y, target.z),
atlast::geometry::CUnitVector3d (up.x, up.y, up.z),
nearDistance, farDistance, viewFlags.camera, fieldOfView, height);
if (NULL == pName)
m_pDocument->GetModel()->SetCamera(camera);
else
m_pDocument->GetModel()->GetPages()->AddPage(pName)->SetCamera (camera);