Exporting a mesh to a file
The Mesh Export dialog
The .vrmesh file format
Creating a proxy object
Search Keywords:proxy, mesh, VRayMesh, .vrmesh
VRayProxy allows you to import geometry from an external mesh at render time only. The geometry is not present in the 3ds Max scene and does not take any resources. This allows the rendering of scenes with many millions of triangles - more than 3ds Max itself can handle.
Before you can import a mesh through a VRayProxy object, you need to create the mesh file first. You can do this in two ways:
- Through the quad-menu: select the meshes you want to export, right-click in the viewport and select the V-Ray mesh export option. This will cause the Mesh Export dialog to appear.
- Dialog from MaxScript: select the meshes you want to export and then type
in the MaxScript Listener window. This will cause the Mesh Export dialog to appear.
- Direct export from MaxScript: select the meshes you want to export and then use the vrayMeshExport() function:
vrayMeshExport [meshFile:"<mesh file>"] [autoCreateProxies:true|false] [exportMultiple:true|false] [animation:on|off] [animationRange:#scene|#explicit] [animationStart:<integer>] [animationEnd:<integer>] [animationRedrawViews:true|false] [maxPreviewFaces:<integer>]
where <mesh file> is the name of the desired .vrmesh file. If the name does not contain a path, the default 3ds Max mesh path is used. If the name does not contain an extension, a .vrmesh extension is automatically appended. If the name does not contain a file name, the scene node name is used instead. If the autoCreateProxies option is not specified, by default the meshes are just exported, no proxies are created in the scene. If the exportMultiple option is not specified, the meshes are exported to multiple files by default. If the animation option is set to on, an animated proxy file is created. In that case, the range of the animation is determined by the animationRange option - if set to #explicit, then the frame range for the export is specified by the animationStart and animationEnd options (in frames), otherwise the current scene animation range is used. If the animationRedrawViews option is set to true then the viewports will be updated during the animation export process. If the maxPreviewFaces parameter is specified, then the exported .vrmesh file will contain a preview with the specified maximum of triangles, otherwise a default value of 10000 triangles is used.
The function returns ok if the .vrmesh file was exported successfully, and undefined otherwise.
The Mesh Export dialog allows you to specify the mesh file as well as some export options.
Folder - this is the folder where the mesh file(s) will be created.
Export as single file - this option will take all selected objects and will merge them into one mesh file. This option also stores the transformations of the selected objects. When you import the file with a proxy object, it must be centered at the origin, if you want the objects to be in the same place. Also, since the imported mesh is rendered using the material of the proxy object, all meshes from the file will render with that material. You must use subobject materials and different material IDs if you want them to have different materials.
File - this is the name of the file, if you have selected the Export as single file option. You don't need to specify a path - the Folder path will be used.
Export as multiple files - this option will create one file for each selected object. The name of each file is derived from the name of the correspondig 3ds max node. The transformation of an object is not included in its mesh file, and the corresponding proxy must have the same transformation as the original object, if it is to appear in the same place. Note that you can use this option even with a single object, which will cause the object pivot to be preserved in the exported .vrmesh file.
Export animation - if the mesh is animated you can export that animation in the .vrmesh file with the animation by enabling this option.
Frame range - specify what part of the animation to be exported into the .vrmesh file.
-Scene animation range - the whole animation will be exported into the .vrmesh file.
-Frame range - specify exactly which frames are going to be exported by setting values for the Start Frame and the End Frame parameters.
Redraw views during export - when this option is selected you will be able to see the animation playing in the view port while it is being exported. This is an easy way to monitor the progress of the export.
Automatically create proxies - this option will create proxy objects for the exported meshes. The proxies will have the correct transformations and materials derived from the original objects. The original objects will be deleted.
Faces in preview - allows you specify how many faces are going to be used to show a preview of the proxy in the view port.
Warn for existing files - when this option is selected V-Ray will warn you if you are saving over an existing file
Pressing the OK button will create the mesh files and the proxy objects. The export process may take some time, depending on the amount of geometry that must be processed.
Meshes are exported to a special .vrmesh file format. It contains all geometric information for a mesh - vertices and face topology as well as texture channels, face material IDs, smoothing groups, normals - in short, everything that is needed to render the mesh. In addition, the mesh is preprocessed and subdivided into chunks for easier access. The file also contains a simplified version of the mesh used for preview purposes in the viewports.
It is important to realize that the mesh is in a "ready to render" format. No further modifications to the mesh are expected. You can't apply modifiers to the mesh, or animate it in any way except if you animate the position/orientation of the proxy object. If you need to make changes to the mesh, you can import it back as an Editable mesh (see the Import section below) and re-export it back to a .vrmesh file.
After you export a mesh to a .vrmesh file, you need a proxy object to represent it in the 3dsmax scene. To create a proxy object, go to the Create panel and choose the V-Ray category; click the VRayProxy button and then click in a viewport to create the actual proxy object. A dialog box will appear that allows you to choose the .vrmesh file to import.
Mesh file - this is the source .vrmesh file.
Display - controls the display of the proxy in the viewports:
bounding box - the mesh is represented as a box in the viewports.
preview from file(edges) - displays the mesh preview info that is stored in the .vrmesh file showing only the edges of the object.
preview from file(faces) - displays the mesh preview info that is stored in the .vrmesh file showing only the faces of the object.
point - the mesh is represented as a point
Animation - holds the settings for animated proxies
Playback - select a playback mode from the drop down menu
- Loop - the animation is looped by skipping to the first frame once it has finished
-Play once - the animation is played just once
-Ping-pong - the animation is looped by playing it backwards once the last frame has been reached and then playing it forward again when the first frame is reached
-Still - the animation is not played. Instead just one frame of the animation is shown. You can select which that frame is with the help of the Offset parameter.
Offset(frames) - use this parameter to offset the beginning of the animation by given number of frames. You can use positive as well as negative values here.
Speed - this is a multiplier for the speed of the animation. Putting negative numbers here will make the animation play backwards.
Import - holds the settings for importing back a proxy as a mesh.
Import as mesh - imports the geometry from the .vrmesh as an Editable mesh object. Note that the new mesh will be created at the coordinate system origin (0,0,0), and not at the current place of the VRayProxy object.
Use explicit normals - in cases where the original mesh has explicit information about the vertex normals, that information is also saved in the .vrmesh file when the mesh is exported. Checking this option makes sure that the explicit normals information contained in the proxy is taken into account during the import.
Weld vertices in result - during a .vrmesh file export, V-Ray may split the original mesh in smaller chunks that can be loaded independently of one another. This may cause some vertices to be duplicated in more than one chunk. Checking this option will cause V-Ray to perform a weld operation after the mesh is imported, so that split vertices are merged.