// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include #include #include namespace frantic { namespace max3d { namespace geometry { /** * This function will copy the geometry of the supplied MNMesh in a * frantic::geometry::polymesh3. * @param source A 3ds Max SDK polygon mesh (ie. MNMesh) * @return A pointer to a new polymesh3 with the same geometry as 'source'. */ frantic::geometry::polymesh3_ptr from_max_t( MNMesh& source ); /** * This function will copy the geometry and specified channels of * the supplied MNMesh to a frantic::geometry::polymesh3. * @param source A 3ds Max SDK polygon mesh (ie. MNMesh) * @param cpp A channel_propagation_policy specifying which channels should be copied. * @return A pointer to a new polymesh3 with the same geometry as 'source'. */ frantic::geometry::polymesh3_ptr from_max_t( MNMesh& source, const frantic::channels::channel_propagation_policy& cpp ); /** * This function will copy the supplied Mesh object into a new * polymesh3 object. * @param source The source triangle mesh to copy * @return a new polymesh3 object that is a duplicate of the provided Mesh */ frantic::geometry::polymesh3_ptr from_max_t( Mesh& source ); /** * This deallocates all the data in a 3ds Max MNMesh. * * @param mesh The 3ds Max MNMesh to clear. */ void clear_polymesh( MNMesh& mesh ); /** * This function will copy the geometry of the supplied polymesh into the * MNMesh object. * @param dest The MNMesh to fill in. * @param polymesh The source polymesh3 object. */ void polymesh_copy( MNMesh& dest, frantic::geometry::polymesh3_ptr polymesh ); /** * Copy the supplied polymesh into the MNMesh object, using a time * offset in seconds to move the vertices based on the Velocity * channel. * * This is used for getting motion blur on meshes which change topology per * frame, for example when generated by marching cubes from a level set or a * particle system. * * @param[out] dest The MNMesh to fill in. * @param polymesh The source polymesh3 object. * @param timeOffset The time offset, used to move the vertices relative to * their current position, based on the Velocity channel of * the input mesh. */ void polymesh_copy_time_offset( MNMesh& dest, frantic::geometry::polymesh3_ptr polymesh, float timeOffset ); /** * This function will copy the geometry of the supplied polymesh into the * Mesh object. It will optionally triangle the polymesh if it contains any faces * that aren't triangles, or throw an exception if that behaviour is not requested. * @param dest The Mesh to fill in. * @param polymesh The source polymesh3 object * @param throwIfNotTriangles If true, and 'polymesh' has some non-triangle faces, an exception will be thrown. If * false, the polymesh will be triangulated in order to fit into the Mesh object. */ void polymesh_copy( Mesh& dest, frantic::geometry::polymesh3_ptr polymesh, bool throwIfNotTriangles = true ); /** * Copies a mesh, using the vertex motion caused by the two transforms to create a velocity channel. * * @param mesh Mesh to copy * @param firstXfrm * @param secondXfrm * @param cpp Specifies the mesh channels to copy * @param timeStepInSecs * * @return A pointer to the resulting polymesh */ frantic::geometry::polymesh3_ptr polymesh_copy( Mesh& mesh, const frantic::graphics::transform4f& firstXfrm, const frantic::graphics::transform4f& secondXfrm, const frantic::channels::channel_propagation_policy& cpp, float timeStepInSecs ); /** * Copies a mesh, using the vertex motion between the two transform/mesh pairs to create a velocity channel. * * @param firstMesh * @param secondMesh * @param firstXfrm * @param secondXfrm * @param cpp Specifies the mesh channels to copy * @param timeStepInSecs * * @return A pointer to the resulting polymesh */ frantic::geometry::polymesh3_ptr polymesh_copy( Mesh& firstMesh, Mesh& secondMesh, const frantic::graphics::transform4f& firstXfrm, const frantic::graphics::transform4f& secondXfrm, const frantic::channels::channel_propagation_policy& cpp, float timeStepInSecs ); /** * Copies a mesh, applying the specified transform. * * @param mesh Mesh to copy * @param xfrm * @param cpp Specifies the mesh channels to copy * * @return A pointer to the resulting polymesh */ frantic::geometry::polymesh3_ptr polymesh_copy( MNMesh& mesh, const frantic::graphics::transform4f& xfrm, const frantic::channels::channel_propagation_policy& cpp ); /** * Copies a mesh, using the vertex motion caused by the two transforms to create a velocity channel. * * @param mesh Mesh to copy * @param firstXfrm * @param secondXfrm * @param cpp Specifies the mesh channels to copy * @param timeStepInSecs * * @return A pointer to the resulting polymesh */ frantic::geometry::polymesh3_ptr polymesh_copy( MNMesh& mesh, const frantic::graphics::transform4f& firstXfrm, const frantic::graphics::transform4f& secondXfrm, const frantic::channels::channel_propagation_policy& cpp, float timeStepInSecs ); /** * Copies a mesh, using an existing worldSpaceVertexVelocity array to create a velocity channel. * * @param mesh Mesh to copy * @param xfrm Transform to apply to mesh * @param worldSpaceVertexVelocity world space velocity, measured in distance per tick * @param cpp Specifies the mesh channels to copy * * @return A pointer to the resulting polymesh */ frantic::geometry::polymesh3_ptr polymesh_copy( Mesh& firstMesh, const frantic::graphics::transform4f& xfrm, const Tab& worldSpaceVertexVelocity, const frantic::channels::channel_propagation_policy& cpp ); /** * Copies a mesh, using the vertex motion between the two transform/mesh pairs to create a velocity channel. * * @param firstMesh * @param secondMesh * @param firstXfrm * @param secondXfrm * @param cpp Specifies the mesh channels to copy * @param timeStepInSecs * * @return A pointer to the resulting polymesh */ frantic::geometry::polymesh3_ptr polymesh_copy( MNMesh& firstMesh, MNMesh& secondMesh, const frantic::graphics::transform4f& firstXfrm, const frantic::graphics::transform4f& secondXfrm, const frantic::channels::channel_propagation_policy& cpp, float timeStepInSecs ); /** * Copy the supplied polymesh into the MNMesh object, using a time * offset in seconds to move the vertices based on the Velocity * channel. It will optionally triangulate the polymesh if it * contains any faces that aren't triangles, or throw an exception * if that behaviour is not requested. * * This is used for getting motion blur on meshes which change topology per * frame, for example when generated by marching cubes from a level set or a * particle system. * * @param[out] dest The Mesh to fill in. * @param polymesh The source polymesh3 object. * @param timeOffset The time offset, used to move the vertices relative to * their current position, based on the Velocity channel of the input * mesh. * @param throwIfNotTriangles If true, and 'polymesh' has some non-triangle faces, an exception will be thrown. If * false, the polymesh will be triangulated in order to fit into the Mesh object. */ void polymesh_copy_time_offset( Mesh& dest, frantic::geometry::polymesh3_ptr polymesh, float timeOffset, bool throwIfNotTriangles = true ); /** * Convert the MNMesh from triangles to polygons. * * This function is intended to use the same procedure as 3ds Max * when you convert a triangle mesh to an editable poly. * * @param[in,out] mesh the mesh to convert from triangles to polygons. */ void make_polymesh( MNMesh& mesh ); } // namespace geometry } // namespace max3d } // namespace frantic