by date
Enabling animation transition in ShapeBase object
Enabling animation transition in ShapeBase object
| Name: | Nerrad Weil | |
|---|---|---|
| Date Posted: | Apr 21, 2008 | |
| Rating: | Not Rated | |
| Public: | YES | |
| Comments: | YES | |
| RSS Feed: | or Subscribe with . | |
| Profile Page: | View profile page for Nerrad Weil |
Blog post
In my previous post I has discussed the technique to enable transition in ShapeBase animation, and it seems to be helpful to someone, in this post I would like to give more information about the technique i'd used
1) add a field in struct Thread in ShapeBase.h
2) initialize Thread::transit in ShapeBase constructor
3) in the exisitng ShapeBase::setThreadSequence() add this line
4) create a new method in ShapeBase, which is similar to setThreadSequence but with animation transition modification
in ShapeBase.cc
in ShapeBase.h
5) in ShapeBase::packUpdate() method
6) in ShapeBase::unpackUpdate()
hope this is more informative than my previous post ;)
1) add a field in struct Thread in ShapeBase.h
struct Thread {
...
bool transit; // transit addon
};2) initialize Thread::transit in ShapeBase constructor
ShapeBase::ShapeBase {
...
for (i = 0; i < MaxScriptThreads; i++) {
...
mScriptThread[i].transit = false; // transit addon
}
}3) in the exisitng ShapeBase::setThreadSequence() add this line
bool ShapeBase::setThreadSequence(U32 slot, S32 seq, bool reset)
{
...
if (seq < MaxSequenceIndex) {
setMaskBits(ThreadMaskN << slot);
st.sequence = seq;
st.transit = false; // transit addon
...
}
4) create a new method in ShapeBase, which is similar to setThreadSequence but with animation transition modification
in ShapeBase.cc
bool ShapeBase::setThreadTransitSequence(U32 slot,S32 seq, F32 duration, bool continuePlay, bool reset)
{
Thread& st = mScriptThread[slot];
if (st.thread && st.sequence == seq && st.state == Thread::Play)
return true;
if (seq < MaxSequenceIndex) {
setMaskBits(ThreadMaskN << slot);
st.sequence = seq;
st.transit = true;
if (reset) {
st.state = Thread::Play;
st.atEnd = false;
st.forward = true;
}
if (mShapeInstance) {
if (!st.thread)
st.thread = mShapeInstance->addThread();
stopThreadSound(st);
updateThread(st);
mShapeInstance->transitionToSequence(st.thread,seq,0, duration, continuePlay);
}
return true;
}
return false;
}
in ShapeBase.h
bool setThreadTransitSequence(U32 slot, S32 seq, F32 duration, bool continuePlay = true, bool reset = true);
5) in ShapeBase::packUpdate() method
ShapeBase::packUpdate()
{
...
if (stream->writeFlag(mask & ThreadMask)) {
...
stream->writeFlag(st.atEnd);
stream->writeFlag(st.transit); // transit addon
...
}
}
6) in ShapeBase::unpackUpdate()
void ShapeBase::unpackUpdate(NetConnection *con, BitStream *stream)
{
...
if (stream->readFlag()) {
for (S32 i = 0; i < MaxScriptThreads; i++) {
if (stream->readFlag()) {
Thread& st = mScriptThread[i];
U32 seq = stream->readInt(ThreadSequenceBits);
st.state = stream->readInt(2);
st.forward = stream->readFlag();
st.atEnd = stream->readFlag();
st.transit = stream->readFlag();
if (st.sequence != seq)
{
if (st.transit)
setThreadTransitSequence(i,seq,0.5,false,false);
else
setThreadSequence(i,seq,false);
}
else
updateThread(st);
}
}
}
}
hope this is more informative than my previous post ;)
Recent Blog Posts
| List: | 04/21/08 - Enabling animation transition in ShapeBase object 01/06/08 - Journal of a young adventurer 06/Jan/08 |
|---|
Submit your own resources!| Michael Cozzolino (Apr 21, 2008 at 21:29 GMT) |
| Clara Easson (Apr 24, 2008 at 02:00 GMT) |
You must be a member and be logged in to either append comments or rate this resource.


Not Rated


