00001 extern "C" void calc_ipo(struct Ipo *ipo, float ctime);
00002 extern "C" void execute_ipo(struct ID *id, Ipo *ipo);
00003
00004
00005
00006
00007 #include "BL_BlenderIPO.h"
00008
00009 #include "blender.h"
00010 #include "ipo.h"
00011 #include "ipo_extern.h"
00012
00013
00014 static const int BL_MAX_CHANNELS = 32;
00015
00016 float BL_ScalarInterpolator::GetValue(float currentTime) const {
00017 return IPO_GetFloatValue(m_blender_ipo, m_channel, currentTime);
00018 }
00019
00020
00021 BL_InterpolatorList::BL_InterpolatorList(struct Ipo *ipo) {
00022 IPO_Channel channels[BL_MAX_CHANNELS];
00023
00024 int num_channels = IPO_GetChannels(ipo, channels);
00025
00026 int i;
00027
00028 for (i = 0; i != num_channels; ++i) {
00029 BL_ScalarInterpolator *new_ipo =
00030 new BL_ScalarInterpolator(ipo, channels[i]);
00031
00032
00033 push_back(new_ipo);
00034 }
00035 }
00036
00037 BL_InterpolatorList::~BL_InterpolatorList() {
00038 BL_InterpolatorList::iterator i;
00039 for (i = begin(); !(i == end()); ++i) {
00040 delete *i;
00041 }
00042 }
00043
00044
00045 KX_IScalarInterpolator *BL_InterpolatorList::GetScalarInterpolator(BL_IpoChannel channel) {
00046 BL_InterpolatorList::iterator i = begin();
00047 while (!(i == end()) &&
00048 (static_cast<BL_ScalarInterpolator *>(*i))->GetChannel() !=
00049 channel) {
00050 ++i;
00051 }
00052
00053 return (i == end()) ? 0 : *i;
00054 }
00055
00056
00057
00058
00059
00060 void BL_calc_ipo(struct Object* blenderobject, float curframetime)
00061 {
00062 calc_ipo(blenderobject->ipo,curframetime);
00063 }
00064
00065
00066 bool BL_HasIPO(struct Object* blenderobj)
00067 {
00068 bool result = false;
00069 if (blenderobj)
00070 result = (blenderobj->ipo != 0);
00071 return result;
00072 }
00073
00074 void BL_execute_ipo(struct Object* blenderobject)
00075 {
00076 execute_ipo((ID *)blenderobject, blenderobject->ipo);
00077 }
00078
00079 void BL_DoDLocIPO(struct Object* blenderobject)
00080 {
00081 if(blenderobject->ipo) {
00082
00083
00084
00085
00086 blenderobject->loc[0]+=blenderobject->dloc[0];
00087 blenderobject->loc[1]+=blenderobject->dloc[1];
00088 blenderobject->loc[2]+=blenderobject->dloc[2];
00089
00090 blenderobject->dloc[0] = 0.0;
00091 blenderobject->dloc[1] = 0.0;
00092 blenderobject->dloc[2] = 0.0;
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 }
00111 }