diff --git a/include/obj/NiControllerSequence.h b/include/obj/NiControllerSequence.h index 56fbb5c960566eeba0e216ce6864c1ffa36c4af8..310126b00999af19ac83bdfc78826b5c81c2ea78 100644 --- a/include/obj/NiControllerSequence.h +++ b/include/obj/NiControllerSequence.h @@ -107,7 +107,7 @@ public: NIFLIB_API void AddController( string const & targetName, NiTimeController * obj ); /*! - * Attatches an interpolator to this KF file for a KF file of version greater than 10.2.0.0. Versions below this use controllers. + * Attaches 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. * \sa NiControllerSequence::ClearChildren, NiControllerSequence::AddController @@ -115,7 +115,7 @@ 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. + * Attaches 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 @@ -123,6 +123,17 @@ public: */ NIFLIB_API void AddInterpolator( NiSingleInterpController * obj, byte priority , bool include_string_pallete ); + /*! + * Attaches a generic interpolator to this KF file for a KF file of version greater than 10.2.0.0. Versions below this use controllers. + * \param[in] interpolator A reference to the new interpolator to insert into the controllersequence + * \param[in] target The target object that the controller which held the interpolator would act on + * \param[in] controller_type_name The name of the type of the controller that held the interpolator + * \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 AddGenericInterpolator( NiInterpolator * interpolator, NiObjectNET* target, string controller_type_name, byte priority = 0, bool include_string_pallete = true); + /*! * 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 38e001617b232928a39e4b1db9561e5dd3b19e7d..cf6e3eb06685abd38d721f36819451f046f38ee3 100644 --- a/src/obj/NiControllerSequence.cpp +++ b/src/obj/NiControllerSequence.cpp @@ -433,6 +433,53 @@ void NiControllerSequence::AddInterpolator( NiSingleInterpController * obj, byte } +void NiControllerSequence::AddGenericInterpolator( NiInterpolator * interpolator, NiObjectNET* target, string controller_type_name, byte priority /*= 0*/, bool include_string_pallete /*= true*/ ) { + //Make sure the parameters aren't null + + if(interpolator == NULL) { + throw runtime_error("Attempted to add a null interpolator to the controller sequence"); + } + + if(target == NULL) { + throw runtime_error("Attempted to add a null target to the controller sequence"); + } + + //Make a new ControllerLink and fill out necessary data + ControllerLink cl; + + NiPropertyRef prop = DynamicCast<NiProperty>(target); + + cl.interpolator = interpolator; + 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( controller_type_name ); + + } else { + cl.stringPalette = NULL; + cl.nodeName = target->GetName(); + if(prop != NULL) { + cl.propertyType = prop->GetType().GetTypeName(); + } + cl.controllerType = controller_type_name; + } + + //Add finished ControllerLink to list + controlledBlocks.push_back( cl ); +} + + void NiControllerSequence::ClearControllerData() {