diff --git a/3DSMax/Alembic.aps b/3DSMax/Alembic.aps index e97343c7..b344e3f5 100644 Binary files a/3DSMax/Alembic.aps and b/3DSMax/Alembic.aps differ diff --git a/3DSMax/AlembicCameraModifier.h b/3DSMax/AlembicCameraModifier.h index bc2e8d90..8b85e0f3 100644 --- a/3DSMax/AlembicCameraModifier.h +++ b/3DSMax/AlembicCameraModifier.h @@ -1,114 +1,114 @@ -#ifndef __ALEMBIC_CAMERA_MODIFIER__H -#define __ALEMBIC_CAMERA_MODIFIER__H - - - -#include "resource.h" -#include "AlembicDefinitions.h" -#include "AlembicNames.h" - - -class AlembicCameraModifier : public Modifier { -public: - IParamBlock2 *pblock; - - // Parameters in first block: - enum - { - ID_PATH, - ID_IDENTIFIER, - ID_TIME, - ID_HFOV, - ID_VFOV, - ID_FOCAL, - ID_HAPERATURE, - ID_VAPERATURE, - ID_HFILMOFFSET, - ID_VFILMOFFSET, - ID_LSRATIO, - ID_OVERSCANL, - ID_OVERSCANR, - ID_OVERSCANT, - ID_OVERSCANB, - ID_FSTOP, - ID_FOCUSDIST, - ID_SHUTTEROPEN, - ID_SHUTTERCLOSE, - ID_NEARCLIPPINGPLANE, ID_FARCLIPPINGPLANE - }; - - static IObjParam *ip; - static AlembicCameraModifier *editMod; - - AlembicCameraModifier(); - ~AlembicCameraModifier(); - - // From Animatable - virtual Class_ID ClassID() { return ALEMBIC_CAMERA_MODIFIER_CLASSID; } - void GetClassName(TSTR& s) { s = _T(ALEMBIC_CAMERA_MODIFIER_NAME); } - CONST_2013 TCHAR *GetObjectName() { return _T(ALEMBIC_CAMERA_MODIFIER_NAME); } - - void DeleteThis() { delete this; } - RefTargetHandle Clone(RemapDir& remap); - - void EnumAuxFiles(AssetEnumCallback& nameEnum, DWORD flags); - - // From Modifier - ChannelMask ChannelsUsed() { return DISP_ATTRIB_CHANNEL; } - ChannelMask ChannelsChanged() { return DISP_ATTRIB_CHANNEL; } - Class_ID InputType() { return defObjectClassID; } - void ModifyObject (TimeValue t, ModContext &mc, ObjectState *os, INode *node); - //Interval LocalValidity(TimeValue t) { return GetValidity(t); } - //Interval GetValidity (TimeValue t); - BOOL DependOnTopology(ModContext &mc) { return FALSE; } - - // From BaseObject - CreateMouseCallBack* GetCreateMouseCallBack() {return NULL;} - - void BeginEditParams( IObjParam *ip, ULONG flags,Animatable *prev); - void EndEditParams( IObjParam *ip, ULONG flags,Animatable *next); - - int NumParamBlocks () { return 1; } - IParamBlock2 *GetParamBlock (int i) { return pblock; } - IParamBlock2 *GetParamBlockByID (short id) { return (pblock->ID() == id) ? pblock : NULL; } - - int NumRefs() { return 1; } - RefTargetHandle GetReference(int i) { return pblock; } - - int NumSubs() { return 1; } - Animatable* SubAnim(int i) { return GetReference(i); } - TSTR SubAnimName(int i) { return _T("IDS_PROPS"); } - -#if crate_Max_Version == 2015 - RefResult NotifyRefChanged( const Interval& changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message, BOOL propagate); -#else - RefResult NotifyRefChanged( Interval changeInt,RefTargetHandle hTarget, PartID& partID, RefMessage message); -#endif - -private: - virtual void SetReference(int i, RefTargetHandle rtarg) { pblock = (IParamBlock2 *) rtarg; } -private: - std::string m_CachedAbcFile; -}; - - - -class AlembicCameraModifierClassDesc : public ClassDesc2 -{ -public: - AlembicCameraModifierClassDesc() {} - ~AlembicCameraModifierClassDesc() {} - - int IsPublic() { return TRUE; } - const TCHAR * ClassName() { return _T(ALEMBIC_CAMERA_MODIFIER_NAME); } - SClass_ID SuperClassID() { return OSM_CLASS_ID; } - void * Create(BOOL loading = FALSE) { return new AlembicCameraModifier; } - Class_ID ClassID() { return ALEMBIC_CAMERA_MODIFIER_CLASSID; } - const TCHAR* Category() { return EXOCORTEX_ALEMBIC_CATEGORY; } - const TCHAR* InternalName() { return _T(ALEMBIC_CAMERA_MODIFIER_SCRIPTNAME); } // returns fixed parsable name (scripter-visible name) - HINSTANCE HInstance() { return hInstance; } // returns owning module handle -}; - -ClassDesc2 *GetAlembicCameraModifierClassDesc(); - -#endif +#ifndef __ALEMBIC_CAMERA_MODIFIER__H +#define __ALEMBIC_CAMERA_MODIFIER__H + + + +#include "resource.h" +#include "AlembicDefinitions.h" +#include "AlembicNames.h" + + +class AlembicCameraModifier : public Modifier { +public: + IParamBlock2 *pblock; + + // Parameters in first block: + enum + { + ID_PATH, + ID_IDENTIFIER, + ID_TIME, + ID_HFOV, + ID_VFOV, + ID_FOCAL, + ID_HAPERATURE, + ID_VAPERATURE, + ID_HFILMOFFSET, + ID_VFILMOFFSET, + ID_LSRATIO, + ID_OVERSCANL, + ID_OVERSCANR, + ID_OVERSCANT, + ID_OVERSCANB, + ID_FSTOP, + ID_FOCUSDIST, + ID_SHUTTEROPEN, + ID_SHUTTERCLOSE, + ID_NEARCLIPPINGPLANE, ID_FARCLIPPINGPLANE + }; + + static IObjParam *ip; + static AlembicCameraModifier *editMod; + + AlembicCameraModifier(); + ~AlembicCameraModifier(); + + // From Animatable + virtual Class_ID ClassID() { return ALEMBIC_CAMERA_MODIFIER_CLASSID; } + void GetClassName(TSTR& s) { s = _T(ALEMBIC_CAMERA_MODIFIER_NAME); } + CONST_2013 TCHAR *GetObjectName() { return _T(ALEMBIC_CAMERA_MODIFIER_NAME); } + + void DeleteThis() { delete this; } + RefTargetHandle Clone(RemapDir& remap); + + void EnumAuxFiles(AssetEnumCallback& nameEnum, DWORD flags); + + // From Modifier + ChannelMask ChannelsUsed() { return DISP_ATTRIB_CHANNEL; } + ChannelMask ChannelsChanged() { return DISP_ATTRIB_CHANNEL; } + Class_ID InputType() { return defObjectClassID; } + void ModifyObject (TimeValue t, ModContext &mc, ObjectState *os, INode *node); + //Interval LocalValidity(TimeValue t) { return GetValidity(t); } + //Interval GetValidity (TimeValue t); + BOOL DependOnTopology(ModContext &mc) { return FALSE; } + + // From BaseObject + CreateMouseCallBack* GetCreateMouseCallBack() {return NULL;} + + void BeginEditParams( IObjParam *ip, ULONG flags,Animatable *prev); + void EndEditParams( IObjParam *ip, ULONG flags,Animatable *next); + + int NumParamBlocks () { return 1; } + IParamBlock2 *GetParamBlock (int i) { return pblock; } + IParamBlock2 *GetParamBlockByID (short id) { return (pblock->ID() == id) ? pblock : NULL; } + + int NumRefs() { return 1; } + RefTargetHandle GetReference(int i) { return pblock; } + + int NumSubs() { return 1; } + Animatable* SubAnim(int i) { return GetReference(i); } + TSTR SubAnimName(int i) { return _T("IDS_PROPS"); } + +#if crate_Max_Version == 2015 + RefResult NotifyRefChanged( const Interval& changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message, BOOL propagate); +#else + RefResult NotifyRefChanged( Interval changeInt,RefTargetHandle hTarget, PartID& partID, RefMessage message); +#endif + +private: + virtual void SetReference(int i, RefTargetHandle rtarg) { pblock = (IParamBlock2 *) rtarg; } +private: + std::string m_CachedAbcFile; +}; + + + +class AlembicCameraModifierClassDesc : public ClassDesc2 +{ +public: + AlembicCameraModifierClassDesc() {} + ~AlembicCameraModifierClassDesc() {} + + int IsPublic() { return TRUE; } + const TCHAR * ClassName() { return _T(ALEMBIC_CAMERA_MODIFIER_NAME); } + SClass_ID SuperClassID() { return OSM_CLASS_ID; } + void * Create(BOOL loading = FALSE) { return new AlembicCameraModifier; } + Class_ID ClassID() { return ALEMBIC_CAMERA_MODIFIER_CLASSID; } + const TCHAR* Category() { return EXOCORTEX_ALEMBIC_CATEGORY; } + const TCHAR* InternalName() { return _T(ALEMBIC_CAMERA_MODIFIER_SCRIPTNAME); } // returns fixed parsable name (scripter-visible name) + HINSTANCE HInstance() { return hInstance; } // returns owning module handle +}; + +ClassDesc2 *GetAlembicCameraModifierClassDesc(); + +#endif diff --git a/3DSMax/AlembicExport.aps b/3DSMax/AlembicExport.aps index 0c86fd99..ef0d96b2 100644 Binary files a/3DSMax/AlembicExport.aps and b/3DSMax/AlembicExport.aps differ diff --git a/3DSMax/AlembicXform.cpp b/3DSMax/AlembicXform.cpp index d3ae1358..3fd2e9f1 100644 --- a/3DSMax/AlembicXform.cpp +++ b/3DSMax/AlembicXform.cpp @@ -1,94 +1,94 @@ -#include "stdafx.h" -#include "Alembic.h" - -#include "SceneEnumProc.h" -#include "AlembicXform.h" -#include "Utility.h" -#include "AlembicMetadataUtils.h" -#include "AlembicPropertyUtils.h" - - -AlembicXForm::AlembicXForm(SceneNodePtr eNode, AlembicWriteJob * in_Job, Abc::OObject oParent) : AlembicObject(eNode, in_Job, oParent), customAttributes("User Properties") -{ - AbcG::OXform xform(GetOParent(), eNode->name, GetCurrentJob()->GetAnimatedTs()); - - mXformSchema = xform.getSchema(); - - mOVisibility = CreateVisibilityProperty(xform, GetCurrentJob()->GetAnimatedTs()); - - if(!bMergedSubtreeNodeParent){ - Abc::OCompoundProperty userProperties = mXformSchema.getUserProperties(); - customAttributes.defineCustomAttributes(mMaxNode, userProperties, mXformSchema.getMetaData(), GetCurrentJob()->GetAnimatedTs()); - } -} - -AlembicXForm::~AlembicXForm() -{ - // we have to clear this prior to destruction this is a workaround for issue-171 - mOVisibility.reset(); -} - -bool AlembicXForm::Save(double time, bool bLastFrame) -{ - ESS_PROFILE_FUNC(); - - const bool bTransCache = GetCurrentJob()->GetOption("transformCache"); - bool bGlobalSpace = GetCurrentJob()->GetOption("globalSpace"); - const bool bFlatten = GetCurrentJob()->GetOption("flattenHierarchy"); - - - if(this->mExoSceneNode->type == SceneNode::ITRANSFORM){ - - // Set the bounding box to be used to draw the dummy object on import - TimeValue ticks = GetTimeValueFromFrame(time); - Object *obj = mMaxNode->EvalWorldState(ticks).obj; - DummyObject *pDummyObject = static_cast(obj); - Box3 maxBox = pDummyObject->GetBox(); - - //Abc::V3d minpoint(maxBox.pmin.x, maxBox.pmin.y, maxBox.pmin.z); //Abc::V3d maxpoint(maxBox.pmax.x, maxBox.pmax.y, maxBox.pmax.z); - - Abc::V3d minpoint( ConvertMaxPointToAlembicPoint4(maxBox.pmin) ); - Abc::V3d maxpoint( ConvertMaxPointToAlembicPoint4(maxBox.pmax) ); - - // max point -> alembic point: (x, y, z) -> (x, z, -y) - // thus, since Zmin < zMax, then -Zmin > -Zmax. So we need to swap the z components - std::swap(minpoint.z, maxpoint.z); - - mXformSchema.getChildBoundsProperty().set( Abc::Box3d(minpoint, maxpoint) ); - - } - - //const bool bFirstFrame = mNumSamples == 0; - - if(!bMergedSubtreeNodeParent){ - customAttributes.exportCustomAttributes(mMaxNode, time); - } - - //SaveUserProperties(mExoSceneNode, mXformSchema, GetCurrentJob()->GetAnimatedTs(), time, bFirstFrame); - - if(bFlatten){//a hack needed to handle namespace xforms - mXformSample.setMatrix(mExoSceneNode->getGlobalTransDouble(time)); - mXformSchema.set(mXformSample); - } - else{ - Imath::M44d parentGlobalTransInv = mExoSceneNode->parent->getGlobalTransDouble(time).invert(); - Imath::M44d transform = mExoSceneNode->getGlobalTransDouble(time) * parentGlobalTransInv; - mXformSample.setMatrix(transform); - mXformSchema.set(mXformSample); - } - - bool bVisibility = mExoSceneNode->getVisibility(time); - mOVisibility.set(bVisibility ?AbcG::kVisibilityVisible :AbcG::kVisibilityHidden); - - if(mXformSchema.getNumSamples() == 0) - { - SaveMetaData(mMaxNode, this); - } - - return true; -} - -Abc::OCompoundProperty AlembicXForm::GetCompound() -{ - return mXformSchema; +#include "stdafx.h" +#include "Alembic.h" + +#include "SceneEnumProc.h" +#include "AlembicXform.h" +#include "Utility.h" +#include "AlembicMetadataUtils.h" +#include "AlembicPropertyUtils.h" + + +AlembicXForm::AlembicXForm(SceneNodePtr eNode, AlembicWriteJob * in_Job, Abc::OObject oParent) : AlembicObject(eNode, in_Job, oParent), customAttributes("User Properties") +{ + AbcG::OXform xform(GetOParent(), eNode->name, GetCurrentJob()->GetAnimatedTs()); + + mXformSchema = xform.getSchema(); + + mOVisibility = CreateVisibilityProperty(xform, GetCurrentJob()->GetAnimatedTs()); + + if(!bMergedSubtreeNodeParent){ + Abc::OCompoundProperty userProperties = mXformSchema.getUserProperties(); + customAttributes.defineCustomAttributes(mMaxNode, userProperties, mXformSchema.getMetaData(), GetCurrentJob()->GetAnimatedTs()); + } +} + +AlembicXForm::~AlembicXForm() +{ + // we have to clear this prior to destruction this is a workaround for issue-171 + mOVisibility.reset(); +} + +bool AlembicXForm::Save(double time, bool bLastFrame) +{ + ESS_PROFILE_FUNC(); + + const bool bTransCache = GetCurrentJob()->GetOption("transformCache"); + bool bGlobalSpace = GetCurrentJob()->GetOption("globalSpace"); + const bool bFlatten = GetCurrentJob()->GetOption("flattenHierarchy"); + + + if(this->mExoSceneNode->type == SceneNode::ITRANSFORM){ + + // Set the bounding box to be used to draw the dummy object on import + TimeValue ticks = GetTimeValueFromFrame(time); + Object *obj = mMaxNode->EvalWorldState(ticks).obj; + DummyObject *pDummyObject = static_cast(obj); + Box3 maxBox = pDummyObject->GetBox(); + + //Abc::V3d minpoint(maxBox.pmin.x, maxBox.pmin.y, maxBox.pmin.z); //Abc::V3d maxpoint(maxBox.pmax.x, maxBox.pmax.y, maxBox.pmax.z); + + Abc::V3d minpoint( ConvertMaxPointToAlembicPoint4(maxBox.pmin) ); + Abc::V3d maxpoint( ConvertMaxPointToAlembicPoint4(maxBox.pmax) ); + + // max point -> alembic point: (x, y, z) -> (x, z, -y) + // thus, since Zmin < zMax, then -Zmin > -Zmax. So we need to swap the z components + std::swap(minpoint.z, maxpoint.z); + + mXformSchema.getChildBoundsProperty().set( Abc::Box3d(minpoint, maxpoint) ); + + } + + //const bool bFirstFrame = mNumSamples == 0; + + if(!bMergedSubtreeNodeParent){ + customAttributes.exportCustomAttributes(mMaxNode, time); + } + + //SaveUserProperties(mExoSceneNode, mXformSchema, GetCurrentJob()->GetAnimatedTs(), time, bFirstFrame); + + if(bFlatten){//a hack needed to handle namespace xforms + mXformSample.setMatrix(mExoSceneNode->getGlobalTransDouble(time)); + mXformSchema.set(mXformSample); + } + else{ + Imath::M44d parentGlobalTransInv = mExoSceneNode->parent->getGlobalTransDouble(time).invert(); + Imath::M44d transform = mExoSceneNode->getGlobalTransDouble(time) * parentGlobalTransInv; + mXformSample.setMatrix(transform); + mXformSchema.set(mXformSample); + } + + bool bVisibility = mExoSceneNode->getVisibility(time); + mOVisibility.set(bVisibility ?AbcG::kVisibilityVisible :AbcG::kVisibilityHidden); + + if(mXformSchema.getNumSamples() == 0) + { + SaveMetaData(mMaxNode, this); + } + + return true; +} + +Abc::OCompoundProperty AlembicXForm::GetCompound() +{ + return mXformSchema; } \ No newline at end of file diff --git a/Shared/CMakeLists.txt b/Shared/CMakeLists.txt index 5e8f02c4..76de4a14 100644 --- a/Shared/CMakeLists.txt +++ b/Shared/CMakeLists.txt @@ -1,5 +1,26 @@ -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required (VERSION 2.6) -ADD_SUBDIRECTORY ( ${ALEMBIC_ROOT_DIR} ) -ADD_SUBDIRECTORY ( "${CMAKE_CURRENT_SOURCE_DIR}/CommonUtils" "${CMAKE_CURRENT_BINARY_DIR}/CommonUtils" ) +project ( CommonUtils ) +INCLUDE(../../ExocortexCMakeShared.txt NO_POLICY_SCOPE) + +file(GLOB Sources ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +file(GLOB Includes ${CMAKE_CURRENT_SOURCE_DIR}/*.h) + +SOURCE_GROUP("Source Files" FILES ${Sources}) +SOURCE_GROUP("Header Files" FILES ${Includes}) + +add_library( ${PROJECT_NAME} STATIC ${Sources} ${Includes} ) + +TARGET_LINK_LIBRARIES( ${PROJECT_NAME} + ${ALL_ALEMBIC_LIBS} + ) + +ADD_DEPENDENCIES(${PROJECT_NAME} AlembicAbcGeom) + + +SET( DocSource_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../Doc ) +SET( DocInstall_DIR ${Exocortex_INSTALL_BASE_DIR}/Doc ) + +remove_dir( ${DocInstall_DIR} ) +copy_directory( ${DocSource_DIR} ${DocInstall_DIR} ) diff --git a/Shared/CommonUtils/CommonImport.cpp b/Shared/CommonUtils/CommonImport.cpp index 1369770e..34707f31 100644 --- a/Shared/CommonUtils/CommonImport.cpp +++ b/Shared/CommonUtils/CommonImport.cpp @@ -48,8 +48,6 @@ bool IJobStringParser::parse(const std::string& jobString) std::vector valuePair; boost::split(valuePair, tokens[j], boost::is_any_of("=")); - boost::trim(valuePair[0]); - boost::trim(valuePair[1]); if(valuePair.size() != 2) { @@ -57,10 +55,17 @@ bool IJobStringParser::parse(const std::string& jobString) continue; } + boost::trim(valuePair[0]); + boost::trim(valuePair[1]); + + if(boost::iequals(valuePair[0], "filename")) { filename = valuePair[1]; } + if(boost::iequals(valuePair[0], "prefix")){ + prefix = valuePair[1]; + } else if(boost::iequals(valuePair[0], "normals")) { importNormals = parseBool(valuePair[1]); @@ -592,7 +597,28 @@ bool AttachSceneFile(SceneNodeAlembicPtr fileRoot, SceneNodeAppPtr appRoot, cons --count; - const std::string& appNodeName = removeXfoSuffix(currAppNode->name); + + + const std::string& appNodeNameWithPrefix = removeXfoSuffix(currAppNode->name); + + + std::string appNodeName = ""; + + //Logic to control prefix + if(!jobParams.prefix.empty()){ + + std::size_t pos = appNodeNameWithPrefix.find(jobParams.prefix); + if (pos== std::string::npos){ + appNodeName = appNodeNameWithPrefix; + }else + { + appNodeName = appNodeNameWithPrefix.substr(jobParams.prefix.length(), appNodeNameWithPrefix.length()); + } + }else + { + appNodeName = appNodeNameWithPrefix; + } + bool bChildAttached = false; NodeMap::iterator fileNodeIt = childMapPtr->find(appNodeName);