Hi its my first time using the HDK. My goal is to make a scene scale visualiser similar to the one from speedtree. A vertical ruler on the right of the object with the measurement shown in text at the top of it.
I am using the SceneBoundsHook.C sample scene as a base and have been able to modify it to work on selected objects and make custom geo.
What i am missing is a way to get the camera info. In cases where there is a node in the scene for it or its the default perspective camera.
With the camera world transform and its view transform i would be able to:
- Make the custom geo look at the camera at all times.
- Convert a 3d point to a viewport 2d point in order to place text.
Thank you in advance i am new to the hdk and it can be hard to know where to look at the beginning.
HDK SceneRenderHook - get camera info
888 1 0- mapoga
- Member
- 7 posts
- Joined: Feb. 2017
- Offline
- mapoga
- Member
- 7 posts
- Joined: Feb. 2017
- Offline
For those interested, is was able to get the camera position with:
And was able to convert the 3D point to screen space with:
// Parameter from DM_SceneRenderHook.render(RE_Render *r, ...) RE_Render *r; // View matrix UT_Matrix4D view_mat; r->getMatrix(view_mat); view_mat.invert(); // Camera position UT_Vector3 camera_pos = UT_Vector3(0,0,0); camera_pos = rowVecMult(camera_pos, view_mat);
And was able to convert the 3D point to screen space with:
// Parameter from DM_SceneRenderHook.render(RE_Render *r, ...) RE_Render *r; // 3D point UT_Vector3 pos3; // View matrix UT_Matrix4D view_mat; r->getMatrix(view_mat); // Projection matrix UT_Matrix4D proj_mat; r->getMatrix(proj_mat, RE_MATRIX_PROJECTION); UT_DimRect viewport = r->getViewport2DI(); // World position fpreal xw = pos3.x(); fpreal yw = pos3.y(); fpreal zw = pos3.z(); // Screen position fpreal xs; fpreal ys; r->mapScreen(xw, yw, zw, viewport, proj_mat, view_mat, &xs, &ys);
-
- Quick Links