diff --git a/niflib.cpp b/niflib.cpp index fcdd24485ff9dd6a502ebac0ec07a14d7e98d3a3..b491043e978d18a404fa70608a38996285d7cdb7 100644 --- a/niflib.cpp +++ b/niflib.cpp @@ -24,6 +24,7 @@ All rights reserved. Please see niflib.h for licence. */ #include "obj/NiKeyframeController.h" #include "obj/NiKeyframeData.h" #include "obj/NiStringExtraData.h" +#include "obj/NiExtraData.h" #include "gen/header.h" #include "gen/footer.h" @@ -754,6 +755,22 @@ void MergeNifTrees( const Ref<NiNode> & target, const Ref<NiControllerSequence> map<string,NiNodeRef> name_map; MapNodeNames( name_map, target ); + //TODO: Allow this to merge a KF sequence into a file that already has + //sequences in it by appending all the keyframe data to the end of + //existing controllers + + //Get the NiTextKeyExtraData, clone it, and attach it to the target node + NiTextKeyExtraDataRef txt_key = right->GetTextKeyExtraData(); + if ( txt_key != NULL ) { + NiObjectRef tx_clone = txt_key->Clone( version, user_version ); + NiExtraDataRef ext_dat = DynamicCast<NiExtraData>(tx_clone); + if ( ext_dat != NULL ) { + target->AddExtraData( ext_dat ); + } + } + + //Atach it to + //Get the controller data vector<ControllerLink> data = right->GetControllerData(); @@ -776,7 +793,7 @@ void MergeNifTrees( const Ref<NiNode> & target, const Ref<NiControllerSequence> if ( data[i].controller != NULL ) { //Clone the controller and attached data and //add it to the named node - NiObjectRef clone = CloneNifTree( StaticCast<NiObject>(data[i].controller) ); + NiObjectRef clone = CloneNifTree( StaticCast<NiObject>(data[i].controller), version, user_version ); NiTimeControllerRef ctlr = DynamicCast<NiTimeController>(clone); if ( ctlr != NULL ) { name_map[node_name]->AddController( ctlr ); @@ -794,7 +811,7 @@ void MergeNifTrees( const Ref<NiNode> & target, const Ref<NiControllerSequence> //Clone the interpolator and attached data and //add it to controller of matching type that was //found - NiObjectRef clone = CloneNifTree( StaticCast<NiObject>(data[i].interpolator) ); + NiObjectRef clone = CloneNifTree( StaticCast<NiObject>(data[i].interpolator), version, user_version ); NiInterpolatorRef interp = DynamicCast<NiInterpolator>(clone); if ( interp != NULL ) { ctlr->SetInterpolator( interp ); @@ -808,6 +825,16 @@ void MergeNifTrees( const Ref<NiNode> & target, const Ref<NiControllerSequence> } } +//Version for merging KF Trees rooted by a NiSequenceStreamHelper +void MergeNifTrees( const Ref<NiNode> & target, const Ref<NiSequenceStreamHelper> & right, unsigned int version, unsigned int user_version ) { + //Map the node names + map<string,NiNodeRef> name_map; + MapNodeNames( name_map, target ); + + //TODO: Implement this + +} + bool IsVersionSupported(unsigned int ver) { switch (ver) diff --git a/obj/NiControllerSequence.cpp b/obj/NiControllerSequence.cpp index 978101026e018f56d0afc622aa6bf139e72aafcd..af01e0b77768717a3e5f80629f9d0ba20f450e7c 100644 --- a/obj/NiControllerSequence.cpp +++ b/obj/NiControllerSequence.cpp @@ -142,3 +142,7 @@ vector<ControllerLink> NiControllerSequence::GetControllerData() const { return controlledBlocks; } +Ref<NiTextKeyExtraData> NiControllerSequence::GetTextKeyExtraData() const { + return textKeys; +} + diff --git a/obj/NiControllerSequence.h b/obj/NiControllerSequence.h index e9bd23a0a9579c9f95582a45caad0f01415afd37..dfd1ce77e016b8627ad25da352176ae0d76af8a4 100644 --- a/obj/NiControllerSequence.h +++ b/obj/NiControllerSequence.h @@ -74,6 +74,8 @@ public: */ vector<ControllerLink> GetControllerData() const; + Ref<NiTextKeyExtraData> GetTextKeyExtraData() const; + protected: NiControllerManager * NiControllerSequence::Parent() const; NI_CONTROLLER_SEQUENCE_MEMBERS