What is the meaning of return value of z component of View.screen_coords(point3d)

I would like to explore the model view projection matrices (used for rendering in OpenGL) of Sketchup View. The model matrix is simply the transformation of a group (component), the view matrix can be derived from the API of Camera. The projection matrix, however is unknown, which may relate to the screen_coords API.

Although the document says that

The screen_coords method is used to retrieve the screen coordinates of the given point on the screen.

The x and y values returned correspond to the x and y screen coordinates. Ignore the z values. 

The Z values is ignored, but I have found the z value is absolutely not random, see the following outputs from my test

view.screen_coords(ORIGIN)
Point3d(482.891, 624.479, 0.610971)
view.screen_coords(ORIGIN)
Point3d(593.434, 547.559, 0.569721)
view.screen_coords(ORIGIN)
Point3d(618.357, 607.126, 0.551426)
view.screen_coords(ORIGIN)
Point3d(605.397, 1346.42, 0.606774)
view.screen_coords(ORIGIN)
Point3d(487.177, 578.22, 0.897464)
view.screen_coords(ORIGIN)
Point3d(-275.086, -898.803, 0.9989)
view.screen_coords(ORIGIN)
Point3d(668.732, 620.059, 0.54988)
view.screen_coords(ORIGIN)
Point3d(658.804, 585.768, 0.550005)

So I would like to ask that if anyone have idea, how to relate this API to get the projection matrix in OpenGL?

Thanks,

Han

I have a vague memory of reading the view matrix got exposed so renderers can use it but I haven’t been able to find it again. I could just remember it wrong.

I’d bet the Z coordinate isn’t random but a leftover from multiplying 3D coordinates with matrices. However I don’t know enough about matrices to be able to re-create the matrix from the original and modified points. I’d probably try to manually re-create the matrix from field of view angles.

1 Like

Thanks, I think this is absolute created from something like pointCamera = modelViewProj * pointWorld , however, projection matrix is lost after SU update it’s OpenGL render system.

Was there a method to get the projection matrix before the render pipeline re-write :open_mouth: ? It’s quite unlike the SU team to remove API functionality, but maybe it was never an official feature.

Wasn’t this just a discussion at DevCamp?

Could very well be.

Is there a website or video about this? I think it is possible, (lots of rendering engine based on SketchUp absolutely have something)

I don’t think there are recordings of any DevCamp online.

1 Like