/////////////////////////////////////////////////////////////////////////////// // 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 _U3D2PRCIMPORT_INCLUDED_ #define _U3D2PRCIMPORT_INCLUDED_ #include "RxModule.h" #include "RxDictionary.h" #include "DynamicLinker.h" #include "Ge/GeMatrix3d.h" #include "Ge/GeQuaternion.h" #include ////////////////////////////////////////////////////////////////////////// #include "OdPlatformSettings.h" #ifdef U3D2PRCIMPORT_EXPORTS #define U3D2PRCIMPORT_TOOLKIT OD_TOOLKIT_EXPORT #define U3D2PRCIMPORT_TOOLKIT_STATIC OD_STATIC_EXPORT #else #define U3D2PRCIMPORT_TOOLKIT OD_TOOLKIT_IMPORT #define U3D2PRCIMPORT_TOOLKIT_STATIC OD_STATIC_IMPORT #endif ////////////////////////////////////////////////////////////////////////// //DD:EXPORT_ON /** \details This struct represents a information about the light sources. */ struct OdU3DLightInfo { /** \details Enumeration that defines the types of light source. */ enum LightType { /** Light provides uniform non-directional light to the scene. */ AMBIENT, /** Light provides uniform directional light to the scene. */ DIRECTIONAL, /** Light is emitted from a specific point in the scene. */ POINT, /** Like point light, but constrained to specific directions. */ SPOT } /** \details Enumeration that defines the types of attenuation factor. */; enum LightAttenuationFactors { /** Constant attenuation factor (unaffected by distance). */ CONSTANT, /** Attenuation factor relative to distance. */ LINEAR, /** Attenuation factor relative to distance squared. */ QUADRADIC }; /** Light type value. */ LightType lightType{ AMBIENT }; /** This flag determines whether light source is enabled. */ bool isEnabled{false}; /** This flag determines whether light source provides specular highlights. */ bool isSpecular{false}; /** This flag determines whether light source has smooth or hard edge cutoffs. */ bool isSpotdecay{false}; /** Light source color value. */ ODCOLORREF color{0}; /** Spot angle value for LightType::SPOT type light source. */ double spotAngle{0.}; /** Attenuation factor value. */ LightAttenuationFactors attenuation{CONSTANT}; /** Light source intensity value. */ double intensity{0.}; /** Light source name. */ OdString name; /** Light source position matrix. */ OdGeMatrix3d matrix; }; /** \details This struct represents a information about the motion (animation) in U3D. */ struct OdU3DMotionInfo { /** \details This struct represents a information about the motion resource in U3D. */ struct OdU3DMotionResInfo { /** \details This struct represents a information about the motion frame in U3D. */ struct OdU3dFrameInfo { /** Time of this frame. */ float time{ 0. }; /** Location component of this frame. */ OdGePoint3d location; /** Rotation component of this frame. */ OdGeQuaternion rotation; /** Scale component of this frame. */ OdGeVector3d scale; }; /** \details A data type that represents an array of OdU3dFrameInfo objects. */ typedef OdArray OdU3DTrackInfo; /** An array of track names for the this motion resource. */ OdArray track_names; /** An array of tracks for the this motion resource. */ OdArray track_info; /** The name of the motion resource. */ OdString name; /** The full duration of the motion resource. */ double duration{ 0. }; }; /** \details This struct represents a information about the motion mixer object in U3D. */ struct OdU3DMixerResInfo { /** Index of the related motion resource. */ OdUInt32 res_info{ 0 }; /** An array of indexes of related motion mixer object. */ OdArray mixer_construct_list; /** The name of the motion mixer object. */ OdString mixer_name; }; /** \details This struct represents a information about the motion info items. */ struct OdU3DMotionInfoItem { OdInt32 mixerID; OdGeMatrix3d matrix; }; /** An array of motion resources for the this motion. */ OdArray motion_res_info; /** An array of motion mixer objects for the this motion. */ OdArray mixer_res_info; /** The map for connection between imported Prc objects and motion mixer objects, for this motion . */ std::map motion_info_map; }; /** \details An abstract class that the represents the interface for the import from a U3D file. */ class OdU3D2PrcImport : public OdRxObject { public: /** \details Imports a .u3d file contents to a prc database with specified properties. This method should be reimplemented to provide the import from a .u3d file functionality. \returns Returns a value of the OdResult enumeration that contains the result of the import process. \remarks To specify import properties, use the method to get access to the import properties dictionary object. */ virtual OdResult import() = 0; /** \details Retrieves a dictionary object that contains the set of .u3d import properties. \returns Returns a smart pointer to the dictionary object that contains properties used for the import of a .u3d file contents to a prc database. \remarks The list of supported properties for the U3D import operation is represented in the table below. Property Name Description Database A target database object (an instance of the OdPrcFile class). The contents of the U3D file are imported to this database. SourceType A method that determines the source of the U3D data. 0 - U3DPath is used. 1 - InputStream is used. The default value is 0. U3DPath A full path to the imported U3D file. InputStream A stream containing imported U3D data. TransformMatrix A transformation matrix that will be applied to all elements of the imported U3D file.
*/ virtual OdRxDictionaryPtr properties() = 0; /** \details Retrieves information about lighting sources in the imported .u3d file . \returns Returns an array of structures OdU3DLightInfo that describes the light sources in the .u3d file. \remarks Information about light sources can be obtained only after calling the import() function. */ virtual const OdArray& getLights() = 0; /** \details Retrieves information about motion (animation) in the imported .u3d file . \returns Returns a structure OdU3DMotionInfo that describes the motion in the .u3d file. \remarks Information about motion can be obtained only after calling the import() function. */ virtual const OdU3DMotionInfo& getMotionInfo() = 0; }; /** \details A data type that represents a smart pointer to an object. */ typedef OdSmartPtr OdU3D2PrcImportPtr; /** \details The abstract class that provides an interface for the U3D import module. */ class OdU3D2PrcImportModule : public OdRxModule { public: /** \details Creates an instance of the U3D import module if it was not created yet; otherwise, provides an access to the previously created module. \returns Returns a smart pointer to the . */ virtual OdU3D2PrcImportPtr create () = 0; }; /** \details A data type that represents a smart pointer to a . */ typedef OdSmartPtr OdU3D2PrcImportModulePtr; /** \details Creates an instance of the class. \returns Returns a smart pointer to the . */ inline OdU3D2PrcImportPtr createImporter() { OdU3D2PrcImportModulePtr pModule = ::odrxDynamicLinker()->loadApp(OdU3D2PrcImportModuleName); if ( !pModule.isNull() ) return pModule->create (); return (OdU3D2PrcImport*)0; } //DD:EXPORT_OFF #endif // _U3D2PRCIMPORT_INCLUDED_