I think it's only possible with the limb rotation commands.
I'd like to return to the previous topic for a while, and post an improved object animation method, in case someone is interested.
The problem with the animation function I posted above is that it's constrained by the FPS value, because the object cannot possibly animate faster than the time elapsed between two refresh loops. The method is also a bit inaccurate, since the time elapsed will never be exactly equal to frame time.
I was looking for a solution where you can control how many frames the object animates in one second. This way, it can animate in real-time with different FPS values, and can animate fast even if the FPS is low - at the price that it will skip some frames. Here is the code.
//
class myAnimObject
{
public:
myAnimObject();
~myAnimObject() {};
void setID(int ID) {m_ID = ID;}
void initAnim(int startFrame, int endFrame, float framesPerSec);
void animateObject(int curTime);
private:
int m_ID;
int m_startFrame, m_endFrame, m_numFrames;
float m_curFrame, m_fPerSec;
int m_prevTime;
};
//
myAnimObject::myAnimObject()
:m_startFrame(0), m_endFrame(0), m_numFrames(0),
m_curFrame(0), m_fPerSec(0),
m_prevTime(0)
{
}
//
void myAnimObject::initAnim(int startFrame, int endFrame, float framesPerSec)
{
m_startFrame = startFrame;
m_curFrame = startFrame;
m_endFrame = endFrame;
m_numFrames = m_endFrame - m_startFrame + 1;
m_fPerSec = framesPerSec;
m_prevTime = dbTimer();
dbSetObjectFrame(m_ID, startFrame);
}
//
void myAnimObject::animateObject(int curTime)
{
// curTime - prevTime is in milliseconds
float frameProgress = float(curTime - m_prevTime) * m_fPerSec / 1000.0;
m_curFrame += frameProgress;
while (m_curFrame > m_endFrame) m_curFrame -= m_numFrames; // wrap around
m_prevTime = curTime;
dbSetObjectFrame(m_ID, int(m_curFrame + 0.5));
}
EDIT: The function could be further optimized by sending the function the elapsed time and not storing prevTime within every object.