Notifications
Clear all

[Closed] How to retrieve detailed render geometry?

I’m writing a native C++ renderer plugin for 3ds Max 2015-2017.

One of our user has reported that when rendering trees from Laubwerk Plants Kits, only the hulls of the trees are rendered, instead of the trees themselves.

Indeed, Laubwerk plants can be rendered either as hulls or as detailed trees; similarly, it’s possible to choose how they appear in the viewports (see attached screenshot).

With our renderer plugin, we seem to render the viewport geometry, instead of the render geometry (i.e. if a detailed viewport rendering is selected, then detailed trees will be rendered by our plugin.

What is the correct way using Max’s C++ API to retrieve the render geometry? Are there levels of details to be considered? If so, what are the key API methods to use?

For reference, here is our current code to retrieve a triangle mesh from a Max object:
https://github.com/appleseedhq/appleseed-max/blob/master/src/appleseed-max-impl/renderer/projectbuilder.cpp#L151-L209

Thanks,
Franz

5 Replies
 lo1

Do you call RenderBegin on all objects?

Hi dictoon,

as far as I understand the 3ds Max SDK, the way you retrieve the geometry is not ideal. All geometry objects in a 3ds Max scene are derived from GeomObject. That class implements the following functions:

GeomObject::GetRenderMesh()
GeomObject::NumberOfRenderMeshes()
GeomObject::GetMultipleRenderMesh()
GeomObject::GetMultipleRenderMeshTM()

The first function is most commonly used and just returns a Mesh* which contains the triangle mesh you are after. The latter functions are for instancing plugins (like particle systems) and return a number of meshes with transforms.

So the proper way (again, as far as I know) would be to check if the current object is an instance of GeomObject and then use the functions above.

If you use that function, you should get the mesh. From our observations it is not well-defined whether the conversion you are using returns the render version of the geometry or the one for the viewport. We have seen both behaviors, even with objects that are built into 3ds Max.

Hope this helps!

Best
Timm

Thanks to the help of Timm Dapper from Laubwerk ( http://www.laubwerk.com/ ), I was able to fix the problem.

The key was to use the GeomObject::GetRenderMesh() family of functions:
http://help.autodesk.com/cloudhelp/2017/ENU/Max-SDK/cpp_ref/class_geom_object.html#ae345bdf723ab0ed754b2ecd212d53e79

Here is my implementation (as far as I can tell, there is no other complete example of using these methods anywhere on the internet):
https://github.com/appleseedhq/appleseed-max/blob/867d008f0426481eb5a7cdff60619057e105d5ee/src/appleseed-max-impl/renderer/projectbuilder.cpp#L175-L378

For the curious, here’s a quick appleseed render of one of the free Laubwerk tree:
https://forum.appleseedhq.net/t/3ds-max-plugin-development/109/77?u=franz

Ah, your detailed answer finally appeared Thanks Timm for the help!