/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #ifndef _ODTV_REFLECTIONPLANE_H_INCLUDED_ #define _ODTV_REFLECTIONPLANE_H_INCLUDED_ #include "TvToolsExport.h" #include "TvGsView.h" #include "TvEntity.h" #include "TvGroundShadow.h" /** \details This class modifies the specified model for adding reflection plane. */ class ODTVTOOLS_EXPORT OdTvReflectionPlane { public: ODRX_HEAP_OPERATORS(); /** \details Ground plane placement. */ enum AxisPlane { kZMin, //Minimum extents XY plane kZMax, //Maximum extents XY plane kXMin, //Minimum extents YZ plane kXMax, //Maximum extents YZ plane kYMin, //Minimum extents XZ plane kYMax //Maximum extents XZ plane }; /** \details Contains availability checking result */ enum AvailabilityCheckingResult { kWrongDevice = 1 << 0, kWrongRenderMode = 1 << 1, kWrongVSDrawOrderOption = 1 << 2, kWrongVSDisplayStyleMaterialsOption = 1 << 3 }; /** \details Constructs an instance with default parameters. */ OdTvReflectionPlane(); /** \details Destroys an instance (removes Visualize objects used to create the reflection plane effect, if such objects have been added with the 'add' method but not deleted). */ virtual ~OdTvReflectionPlane(); /** \details Modifies the specified model and view for adding reflection plane. \param modelId [in] Model for which to add reflection plane. \param viewId [in] View to be modified. \param groundPlane [in] Ground plane placement. \param reflectivity [in] Reflectivity value of reflection plane (from 0 to 1). \param softness [in] Softness coefficient of reflection plane. The recommended value should be in the range [0; 16]. \returns Returns true if adding was successful, otherwise returns false. */ bool add(OdTvModelId modelId, OdTvGsViewId viewId, AxisPlane groundPlane, double reflectivity = 0.9, OdUInt8 softness = 3); /** \details Modifies the specified models for adding reflection plane. \param models [in] Models for adding reflection plane. \param viewId [in] View to be modified. \param groundPlane [in] Ground plane placement. \param reflectivity [in] Reflectivity value of reflection plane (from 0 to 1). \param softness [in] Softness coefficient of reflection plane. The recommended value should be in the range [0; 16]. \returns Returns true if adding was successful, otherwise returns false. */ bool add(OdArray models, OdTvGsViewId viewId, AxisPlane groundPlane, double reflectivity = 0.9, OdUInt8 softness = 3); /** \details Removes data which is added for reflection plane. */ void remove(); /** \details Emulator options. \remarks This object uses model extents. All offsets calculated from distance between ground plane and opposite plane. Opposite pairs: kZMin - kZMax, kXMin - kXMax, kYMin - kYMax. Default plane size is equal to extents corresponding size, size multiplier changes it. */ struct Options { /** \details Ground offset, percents. */ double m_groundOffset; /** \details Ground plane size multiplier. */ double m_diagMult; }; /** \details Emulator options access. \returns Returns reference to the emulator options. */ Options& options() { return m_options; } /** \details Emulator options access. \returns Returns constant reference to the emulator options. */ const Options& options() const { return m_options; } /** \details Checks whether the reflection plane is already added. \returns true if and only if the reflection plane was already added. */ bool isAdded() const { return m_bWasAdded; } /** \details Checks whether the specified view allows adding a reflection plane. \param viewId [in] view for checking \param iRes [out] Combination of the flags from 'AvailabilityCheckingResult' enum \returns true if and only if an incoming view allow reflection plane (has appropriate render mode or visual style). */ bool isViewAllowReflectionPlane(OdTvGsViewId viewId, OdUInt8& iRes); /** \details Tries to fix view for allowing to add a reflection plane. \param viewId [in] view for fixing \param iRes [in] Combination of the flags from 'AvailabilityCheckingResult' enum that was returned by the method 'isViewAllowReflectionPlane' \param bPermanent [in] Indicates whether the changes should be permanent of shoud be canceled after removing the reflection plane \returns true if and only if a view parameters was changed to allow to add a reflection plane, false otherwise */ bool fixViewForReflectionPlane(OdTvGsViewId viewId, OdUInt8 iRes, bool bPermanent = false); //DOM-IGNORE-BEGIN protected: AxisPlane opposite( AxisPlane plane ) const; bool getPlane( const OdTvExtents3d& exts, AxisPlane plane, OdTvPoint& pt, OdTvVector& normal, double* pDiag = NULL ); bool getCenterPlane( const OdTvExtents3d& exts, AxisPlane plane, OdTvPoint& pt, double* pDiag = NULL ); double getDistance( const OdTvExtents3d& exts, AxisPlane plane ); bool createReflectionPlane(const OdTvExtents3d& extents, OdTvGsViewId viewId, AxisPlane groundPlane, double reflectivity, OdUInt8 softness); bool revertVisualStylesChanges(); protected: Options m_options; OdTvModelId m_groundModel; OdTvGsViewId m_viewId; OdTvEntityId m_groundEntityId; OdTvMaterialId m_groundMaterialId; bool m_bWasAdded; bool m_bNeedSetTexturesVSToThePlane; bool m_bNeedRevertVSChanges; OdArray m_modifiedVisualStyles; //DOM-IGNORE-END }; #endif //_ODTV_REFLECTIONPLANE_H_INCLUDED_