Using particle effects from other versions
by Laban · in iTorque 2D · 05/26/2011 (9:29 am) · 28 replies
Is it just me or is there some sort of format difference with the .eff-files for iPhone2D? I've tried quite a few older ones and they appear without emitters or anything. Tutorial .effs for the iPhone examples work perfectly.
About the author
#22
This hack will allow you to load "old" effects but not new ones. With this hack in place, load your old effect files from script then re-save them -- they'll be saved in the new format. Then undo the hack and you'll be good to go.
As you can see, the root cause was the addition of the 'usesPhysics' field without changing the file format version.
07/14/2011 (12:16 pm)
@Kevin, here's a quick, temporary hack you can use (there are 2 parts). Put this in around line 10135 in t2dSceneObject.ccThis hack will allow you to load "old" effects but not new ones. With this hack in place, load your old effect files from script then re-save them -- they'll be saved in the new format. Then undo the hack and you'll be good to go.
As you can see, the root cause was the addition of the 'usesPhysics' field without changing the file format version.
// Core Info.
// BEGIN HACK
// Effects from 1.1 don't have the 'usesPhysics' field, yet the serialization version
// wasn't changed from 11 (in v1.1). This little temporary hack allows 1.1 effects to be loaded.
const char* className = object->getClassName();
if (dStrcmp(className, "t2dParticleEffect") == 0)
{
if ( !stream.read( &initialUpdate ) ||
!stream.read( &enabled ) ||
!stream.read( &paused ) ||
!stream.read( &visible ) ||
!stream.read( &mountRotation ) ||
!stream.read( &flipX ) ||
!stream.read( &flipY ) ||
!stream.read( &sortPoint.mX ) ||
!stream.read( &sortPoint.mY ) ||
!stream.read( &layer ) ||
!stream.read( &group ) ||
!stream.read( &lifetime ) ||
!stream.read( (S32*)&worldLimitMode ) ||
!stream.read( &worldLimitMin.mX ) ||
!stream.read( &worldLimitMin.mY ) ||
!stream.read( &worldLimitMax.mX ) ||
!stream.read( &worldLimitMax.mY ) ||
!stream.read( &worldLimitCallback ) ||
!stream.read( &autoMountRotation ) ||
//!stream.read( &usesPhysics ) || /* this was added in 1.4, but the format version # wasn't bumped */
!stream.read( &collisionActiveSend ) ||
!stream.read( &collisionActiveReceive ) ||
!stream.read( &collisionPhysicsSend ) ||
!stream.read( &collisionPhysicsReceive ) ||
!stream.read( &collisionLayerMask ) ||
!stream.read( &collisionGroupMask ) ||
!stream.read( &collisionCallback ) ||
!stream.read( &collisionSuppress ) ||
!stream.read( &blending ) ||
!stream.read( &srcBlendFactor ) ||
!stream.read( &dstBlendFactor ) ||
!stream.read( &blendColour ) ||
!stream.read( &layerOrder ) ||
!stream.read( &useMouseEvents ) )
// Error.
return false;
}
else
{
// END HACK
// Core Info.
if ( !stream.read( &initialUpdate ) ||
!stream.read( &enabled ) ||
!stream.read( &paused ) ||
!stream.read( &visible ) ||
!stream.read( &mountRotation ) ||
!stream.read( &flipX ) ||
!stream.read( &flipY ) ||
!stream.read( &sortPoint.mX ) ||
!stream.read( &sortPoint.mY ) ||
!stream.read( &layer ) ||
!stream.read( &group ) ||
!stream.read( &lifetime ) ||
!stream.read( (S32*)&worldLimitMode ) ||
!stream.read( &worldLimitMin.mX ) ||
!stream.read( &worldLimitMin.mY ) ||
!stream.read( &worldLimitMax.mX ) ||
!stream.read( &worldLimitMax.mY ) ||
!stream.read( &worldLimitCallback ) ||
!stream.read( &autoMountRotation ) ||
!stream.read( &usesPhysics ) ||
!stream.read( &collisionActiveSend ) ||
!stream.read( &collisionActiveReceive ) ||
!stream.read( &collisionPhysicsSend ) ||
!stream.read( &collisionPhysicsReceive ) ||
!stream.read( &collisionLayerMask ) ||
!stream.read( &collisionGroupMask ) ||
!stream.read( &collisionCallback ) ||
!stream.read( &collisionSuppress ) ||
!stream.read( &blending ) ||
!stream.read( &srcBlendFactor ) ||
!stream.read( &dstBlendFactor ) ||
!stream.read( &blendColour ) ||
!stream.read( &layerOrder ) ||
!stream.read( &useMouseEvents ) )
// Error.
return false;
// BEGIN HACK
}
// END HACK
// Physics.
if ( !object->getParentPhysics().loadStream( T2D_SERIALISE_LOAD_ARGS_PASS ) )
return false;
#23
07/14/2011 (1:37 pm)
Thanks Andy, I'm going to try this out, one last question, what do you mean by "load your old effect files from script", Do I have to write a small script to load them up and put them on a scene ?, I was thinking just openning the project using a recompiled TGB editor, make sure particles are working then hit save to get the new format, have you tested that last ?
#24
07/14/2011 (3:19 pm)
Yes, it seems like that *should* work. I haven't tested it that way, however.
#25
07/14/2011 (9:27 pm)
Thanks Andy Worked beautifully, now Im concerned about the performance on the iDevices when using particles, If you have some advice will be greatly appreciated.
#26
07/16/2011 (8:13 am)
Glad it worked. Sorry, I don't have much other advice to share re: particle performance. I only have 1-2 particles going at a time which holds up OK. Not sure how well an action game with many simultaneous effects would perform - depends on # of emitters and their complexity. The usual beat: Test, tune, test, tune...
#27
07/16/2011 (8:33 am)
@Kevin, particle effects on anything older than iPhone4 are poor performing - number of particles will be the choker.
#28
We are working on the functionality now, but if all goes well we will automate this process for 1.5 final. Be sure to read through the entire thread if you want the full story. You can thank Daniel for pushing us over the edge to make this happen. If you are feeling really appreciative, I'm sure he'd love the support via a purchase of Space Fart, powered by iTorque 2D.
08/10/2011 (12:01 pm)
Hey everyone. I have an update related to the problems addressed in this thread. Read through my reply to the iT2D engine efficiency boost.We are working on the functionality now, but if all goes well we will automate this process for 1.5 final. Be sure to read through the entire thread if you want the full story. You can thank Daniel for pushing us over the edge to make this happen. If you are feeling really appreciative, I'm sure he'd love the support via a purchase of Space Fart, powered by iTorque 2D.
Torque Owner Hugo Munoz
Tinkuq Games
Finally Im lost on step 6: Change the code for IMPLEMENT_T2D_LOAD_METHOD(t2dSceneObject, 12) to support the new stream, I guess that's what you did on step 2 by "Copying the loading from 8, 9, or 10 into IMPLEMENT_T2D_LOAD_METHOD(t2dSceneObject, 12)"
Thanks for your time and patience on this.