PtexImporter/PtexImporter.h


//**************************************************************************/

// Copyright (c) 2011 Autodesk, Inc.

// All rights reserved.

//

// Use of this software is subject to the terms of the Autodesk license

// agreement provided at the time of installation or download, or which

// otherwise accompanies this software in either electronic or hard copy form.

//

//**************************************************************************/

// DESCRIPTION:

// CREATED: January 2011

//**************************************************************************/



#if defined(JAMBUILD)

#include <Mudbox/mudbox.h>

#include <UVlessPainting/UVGeneratorInterface.h>

#include <EdgeBleeding/EdgeBleeding.h>

#else

#include "../../include/Mudbox/mudbox.h"

#include "../../include/UVlessPainting/UVGeneratorInterface.h"

#include "../../include/EdgeBleeding/EdgeBleeding.h"

#endif



#include "ptex/Ptexture.h"



using namespace mudbox;



class PtexImporter : public Importer

{

    Q_DECLARE_TR_FUNCTIONS(PtexImporter);

    DECLARE_CLASS;



    // Returns the supported extension by the plugin.

    virtual QString Extension( void ) const { return NTR("ptx"); };

    // Returns the description of the file supported by the plugin.

    virtual QString Description( void ) const { return tr("Ptex File"); };

    // Returns the file extension and description of the supported file by the plugin.

    QVector<FileExtension> SupportedExtensions( void ) const { QVector<FileExtension> ret; ret.push_back(FileExtension(NTR("ptx"), tr("Ptex File"), FileExtension::flagNoTextureCoordinates)); return ret; };



    // Import a file, main function of the class.

    virtual void Import( const QString &sFileName, Scene::LoadData &cData );

    // This function creates a mesh from the metadata in a ptex file.

    Mesh *CreateMeshFromMetaData( PtexMetaData *pSource ) const;

    // This function reads the texture data from a ptex file to an existing mesh with existing compatible UV layout.

    void LoadPtexTexture( PtexTexture *, TexturePool *, Mesh *, UVGeneratorNode * );

    // Load the color data from a ptex texture for a given face.

    template <typename eFormat, int iMax>

    void *PrepareFaceBuffer( PtexTexture *pTexture, unsigned int iFaceIndex, char iDirection );

};