Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ObjFileReader"/> class.
        /// </summary>
        /// <param name="resource">The resource to be loaded.</param>
        /// <param name="targetContainer">The target ModelContainer into which to put the generated objects and resources.</param>
        /// <param name="importOptions">Current import settings.</param>
        public ObjFileReader(ResourceLink resource, ImportedModelContainer targetContainer, ObjImportOptions importOptions)
        {
            resource.EnsureNotNull(nameof(resource));
            targetContainer.EnsureNotNull(nameof(targetContainer));
            importOptions.EnsureNotNull(nameof(importOptions));

            m_resource        = resource;
            m_targetContainer = targetContainer;
            m_importOptions   = importOptions;

            m_rawVertices           = new List <Vector3>(1024);
            m_rawNormals            = new List <Vector3>(1014);
            m_rawTextureCoordinates = new List <Vector2>(1024);
            m_targetVertexStructure = new VertexStructure();

            // Apply transform matrix in case of a different coordinate system (switched coordinate axes)
            Matrix4x4 coordSpaceTransformMatrix = importOptions.GetTransformMatrixForCoordinateSystem();

            if (coordSpaceTransformMatrix != Matrix4x4.Identity)
            {
                m_targetVertexStructure.EnableBuildTimeTransform(coordSpaceTransformMatrix);
            }
        }