diff --git a/include/obj/NiControllerSequence.h b/include/obj/NiControllerSequence.h index 107ea1e282a4185c65693047204b5023e4bcda6d..56fbb5c960566eeba0e216ce6864c1ffa36c4af8 100644 --- a/include/obj/NiControllerSequence.h +++ b/include/obj/NiControllerSequence.h @@ -114,6 +114,15 @@ public: */ NIFLIB_API void AddInterpolator( NiSingleInterpController * obj, byte priority = 0 ); + /*! + * Attatches an interpolator to this KF file for a KF file of version greater than 10.2.0.0. Versions below this use controllers. + * \param[in] obj A reference to the new controller which has an interpolator to attach. + * \param[in] priority Used only in Oblivion to set the priority of one controller over another when the two are merged. + * \param[in] include_string_pallete Indicates if the resulting ControllerLinks will hold reference to the NiStringPallete in the NiControllerSequence + * \sa NiControllerSequence::ClearChildren, NiControllerSequence::AddController + */ + NIFLIB_API void AddInterpolator( NiSingleInterpController * obj, byte priority , bool include_string_pallete ); + /*! * Removes all controllers and interpolators from this Kf file root object. * \sa NiControllerSequence::AddController, NiControllerSequence::AddInterpolator diff --git a/src/obj/NiControllerSequence.cpp b/src/obj/NiControllerSequence.cpp index 7fcde4ee9271b0312b087bbe0fa9030e6897b33e..38e001617b232928a39e4b1db9561e5dd3b19e7d 100644 --- a/src/obj/NiControllerSequence.cpp +++ b/src/obj/NiControllerSequence.cpp @@ -377,6 +377,63 @@ void NiControllerSequence::AddInterpolator( NiSingleInterpController * obj, byte controlledBlocks.push_back( cl ); } + +void NiControllerSequence::AddInterpolator( NiSingleInterpController * obj, byte priority , bool include_string_pallete ) { + //Make sure the link isn't null + if ( obj == NULL ) { + throw runtime_error("Attempted to add a null controller to NiControllerSequence block."); + } + + NiInterpolatorRef interp = obj->GetInterpolator(); + if ( interp == NULL ) { + throw runtime_error("Controller must have an interpolator attached to be added to a NiControllerSequence with the AddInterpolator function."); + } + + NiObjectNETRef target = obj->GetTarget(); + if ( target == NULL ) { + throw runtime_error("Controller must have a target to be added to a NiControllerSequence."); + } + + + + //Make a new ControllerLink and fill out necessary data + ControllerLink cl; + + NiPropertyRef prop = DynamicCast<NiProperty>(target); + + cl.interpolator = interp; + cl.priority = priority; + if(include_string_pallete == true) { + //If there are existing ControllerLinks, use the same StringPalette they're using + if ( stringPalette == NULL ) { + stringPalette = new NiStringPalette; + } + + cl.stringPalette = stringPalette; + cl.nodeNameOffset = stringPalette->AddSubStr( target->GetName() ); + + if ( prop != NULL ) { + cl.propertyTypeOffset = stringPalette->AddSubStr( prop->GetType().GetTypeName() ); + } + + cl.controllerTypeOffset = stringPalette->AddSubStr( obj->GetType().GetTypeName() ); + + } else { + cl.stringPalette = NULL; + cl.nodeName = target->GetName(); + if(prop != NULL) { + cl.propertyType = prop->GetType().GetTypeName(); + } + cl.controllerType = obj->GetType().GetTypeName(); + } + + + //Add finished ControllerLink to list + controlledBlocks.push_back( cl ); +} + + + void NiControllerSequence::ClearControllerData() { throw runtime_error("The AddInterpolator function cannot be implemented until problems in the XML are solved.");