Skip to content

Commit

Permalink
Fixed COLLADASW::Asset
Browse files Browse the repository at this point in the history
  • Loading branch information
jerome-jacob committed Feb 29, 2016
1 parent 05bdf47 commit 95bfdbd
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 46 deletions.
37 changes: 33 additions & 4 deletions COLLADAMaya/src/COLLADAMayaDocumentExporter.cpp
Expand Up @@ -297,9 +297,41 @@ namespace COLLADAMaya
}

//---------------------------------------------------------------
class MayaAsset : public COLLADASW::Asset
{
public:
MayaAsset(COLLADASW::StreamWriter* sw)
: COLLADASW::Asset(sw)
{}

protected:
virtual void addExtra()
{
mSW->openElement(COLLADASW::CSWC::CSW_ELEMENT_EXTRA);
{
mSW->openElement(COLLADASW::CSWC::CSW_ELEMENT_TECHNIQUE);
mSW->appendAttribute(COLLADASW::CSWC::CSW_ATTRIBUTE_PROFILE, COLLADAMaya::PROFILE_MAYA);
{
mSW->openElement(COLLADASW::CSWC::CSW_ELEMENT_PLUGIN_VERSION);
mSW->appendValues(COLLADAMaya::CURRENT_REVISION);
mSW->closeElement();

if (COLLADAMaya::CURRENT_SHA1.compare("undefined") != 0)
{
mSW->openElement(COLLADASW::CSWC::CSW_ELEMENT_SHA1);
mSW->appendValues(COLLADAMaya::CURRENT_SHA1);
mSW->closeElement();
}
}
mSW->closeElement();
}
mSW->closeElement();
}
};

void DocumentExporter::exportAsset()
{
COLLADASW::Asset asset ( &mStreamWriter );
MayaAsset asset ( &mStreamWriter );

// Add contributor information
// Set the author
Expand Down Expand Up @@ -389,10 +421,7 @@ namespace COLLADAMaya
asset.setUnit ( linearUnitName, colladaConversionFactor );

// Asset heraus schreiben
asset.openAsset();
asset.add();
asset.addVersionNumber(COLLADAMaya::CURRENT_REVISION, COLLADAMaya::CURRENT_SHA1, COLLADAMaya::PROFILE_MAYA);
asset.closeAsset();
}

//---------------------------------------------------------------
Expand Down
14 changes: 2 additions & 12 deletions COLLADAStreamWriter/include/COLLADASWAsset.h
Expand Up @@ -93,24 +93,13 @@ namespace COLLADASW
to the right, and which is considered inward. */
UpAxisType mUpAxisType;

TagCloser assetCloser;

public:
/** Constructor that sets the stream the asset should be written to*/
Asset ( StreamWriter * streamWriter );

/** Adds the asset to the stream, i.e. performes the actual writing*/
void add();

/** Writes the opening @a \<asset\> tag */
void openAsset();

/** Closes the tag opened by openAsset()*/
void closeAsset();

/** add versionNumber/ Build Version from jenkins into extra attribute pluginVersion*/
void addVersionNumber(const String& versionNumber, const String& sha1, const String& extraAttributeProfile);

/** Returns a reference to the contributor of th asset*/
Contributor& getContributor()
{
Expand Down Expand Up @@ -208,7 +197,8 @@ namespace COLLADASW
return mUpAxisType;
}


protected:
virtual void addExtra() {}
};

} //namespace COLLADASW
Expand Down
36 changes: 6 additions & 30 deletions COLLADAStreamWriter/src/COLLADASWAsset.cpp
Expand Up @@ -24,39 +24,11 @@ namespace COLLADASW
mUpAxisType ( NONE )
{}

void Asset::closeAsset()
{
assetCloser.close();
}

void Asset::openAsset()
{
assetCloser = mSW->openElement(CSWC::CSW_ELEMENT_ASSET);
}

void Asset::addVersionNumber(const String& versionNumber, const String& sha1, const String& extraAttributeProfile)
{
mSW->openElement(COLLADASW::CSWC::CSW_ELEMENT_EXTRA);
mSW->openElement(COLLADASW::CSWC::CSW_ELEMENT_TECHNIQUE);
mSW->appendAttribute(COLLADASW::CSWC::CSW_ATTRIBUTE_PROFILE, extraAttributeProfile);
mSW->openElement(COLLADASW::CSWC::CSW_ELEMENT_PLUGIN_VERSION);
mSW->appendValues(versionNumber);
mSW->closeElement();

if (sha1.compare("undefined") != 0)
{
mSW->openElement(COLLADASW::CSWC::CSW_ELEMENT_SHA1);
mSW->appendValues(sha1);
mSW->closeElement();
}

mSW->closeElement();
mSW->closeElement();
}

//---------------------------------------------------------------
void Asset::add()
{
TagCloser asset = mSW->openElement(CSWC::CSW_ELEMENT_ASSET);

// add contributor only if at least one attribute is not empty

if ( !mContributor.mAuthor.empty() ||
Expand Down Expand Up @@ -147,6 +119,10 @@ namespace COLLADASW
default:
mSW->appendTextElement ( CSWC::CSW_ELEMENT_UP_AXIS, CSWC::CSW_TEXT_Z_UP );
}

addExtra();

asset.close();
}

} //namespace COLLADASW
Expand Down

0 comments on commit 95bfdbd

Please sign in to comment.