ParticleAssetEmitter_ScriptBinding.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. //-----------------------------------------------------------------------------
  23. /// Particle emitter accessors.
  24. //-----------------------------------------------------------------------------
  25. ConsoleMethod(ParticleAssetEmitter, getOwner, const char*, 2, 2, "() Gets the asset owner of the emitter.\n"
  26. "@return The asset owner of the emitter or nothing if no owner assigned." )
  27. {
  28. // Fetch the owner.
  29. ParticleAsset* pParticleAsset = object->getOwner();
  30. return pParticleAsset == NULL ? StringTable->EmptyString : pParticleAsset->getIdString();
  31. }
  32. //-----------------------------------------------------------------------------
  33. ConsoleMethod(ParticleAssetEmitter, setEmitterName, void, 3, 3, "(emitterName) Sets the name of the emitter.\n"
  34. "@param emitterName The name to set the emitter to.\n"
  35. "@return No return value." )
  36. {
  37. object->setEmitterName( argv[2] );
  38. }
  39. //-----------------------------------------------------------------------------
  40. ConsoleMethod(ParticleAssetEmitter, getEmitterName, const char*, 2, 2, "() Gets the name of the emitter.\n"
  41. "@return The name of the emitter." )
  42. {
  43. return object->getEmitterName();
  44. }
  45. //-----------------------------------------------------------------------------
  46. ConsoleMethod(ParticleAssetEmitter, setEmitterType, void, 3, 3, "(emitterType) Sets the type of the emitter.\n"
  47. "@param emitterType The type to set the emitter. Either 'POINT', 'LINE', 'BOX' or 'DISK', 'ELLIPSE' or 'TORUS'.\n"
  48. "An emitter-type of 'POINT' creates the particles at the position of the particle asset.\n"
  49. "An emitter-type of 'LINE' creates the particles along a line defined by the particle width.\n"
  50. "An emitter-type of 'BOX' creates the particles within the dimensions defined by the particle size.\n"
  51. "An emitter-type of 'DISK' creates the particles within a disk with radii defined by the particle size.\n"
  52. "An emitter-type of 'ELLIPSE' creates the particles on an ellipse with the radii defined by the particle size.\n"
  53. "An emitter-type of 'TORUS' creates the particles within a torus with a maximum and minimum radii defined by the particle width and height respectively.\n"
  54. "@return No return value." )
  55. {
  56. object->setEmitterType( ParticleAssetEmitter::getEmitterTypeEnum(argv[2]) );
  57. }
  58. //-----------------------------------------------------------------------------
  59. ConsoleMethod(ParticleAssetEmitter, getEmitterType, const char*, 2, 2, "() Gets the type of the emitter.\n"
  60. "@return The type of the emitter." )
  61. {
  62. return ParticleAssetEmitter::getEmitterTypeDescription( object->getEmitterType() );
  63. }
  64. //-----------------------------------------------------------------------------
  65. ConsoleMethod(ParticleAssetEmitter, setFixedAspect, void, 3, 3, "(fixedAspect) Sets the emitter to used a fixed-aspect for particles.\n"
  66. "@param fixedAspect Whether to use a fixed-aspect or not.\n"
  67. "@return No return value." )
  68. {
  69. object->setFixedAspect( dAtob(argv[2]) );
  70. }
  71. //-----------------------------------------------------------------------------
  72. ConsoleMethod(ParticleAssetEmitter, getFixedAspect, bool, 2, 2, "() Gets whether the emitter uses a fixed-aspect for particles or not.\n"
  73. "@return Whether the emitter uses a fixed-aspect for particles or not." )
  74. {
  75. return object->getFixedAspect();
  76. }
  77. //-----------------------------------------------------------------------------
  78. ConsoleMethod(ParticleAssetEmitter, setFixedForceAngle, void, 3, 3, "(fixedForceAngle) Sets the emitter fixed-force angle for particles.\n"
  79. "@param fixedForceAngle The fixed-force angle for particles.\n"
  80. "@return No return value." )
  81. {
  82. object->setFixedForceAngle( dAtof(argv[2]) );
  83. }
  84. //-----------------------------------------------------------------------------
  85. ConsoleMethod(ParticleAssetEmitter, getFixedForceAngle, F32, 2, 2, "() Gets the emitter fixed-force angle for particles.\n"
  86. "@return The fixed-force angle for particles." )
  87. {
  88. return object->getFixedForceAngle();
  89. }
  90. //-----------------------------------------------------------------------------
  91. ConsoleMethod(ParticleAssetEmitter, setOrientationType, void, 3, 3, "(orientationType) Sets the orientation-type of the emitter.\n"
  92. "@param orientationType The orientation-type to set the emitter to. Either 'FIXED', 'ALIGNED' or 'RANDOM'.\n"
  93. "An orientation-type of 'FIXED' causes the particles to be orientation at a fixed angle.\n"
  94. "An orientation-type of 'ALIGNED' causes the particles to be orientation at the current emission angle.\n"
  95. "An orientation-type of 'RANDOM' causes the particles to be orientation at a fixed angle.\n"
  96. "@return No return value." )
  97. {
  98. object->setOrientationType( ParticleAssetEmitter::getOrientationTypeEnum(argv[2]) );
  99. }
  100. //-----------------------------------------------------------------------------
  101. ConsoleMethod(ParticleAssetEmitter, getOrientationType, const char*, 2, 2, "() Gets the orientation-type of the emitter.\n"
  102. "@return The orientation-type of the emitter." )
  103. {
  104. return ParticleAssetEmitter::getOrientationTypeDescription( object->getOrientationType() );
  105. }
  106. //------------------------------------------------------------------------------
  107. ConsoleMethod(ParticleAssetEmitter, setKeepAligned, void, 3, 3, "(keepAligned) Sets whether to keep emitted particles aligned or not."
  108. "@keepAligned Whether to keep emitted particles aligned or not.\n"
  109. "@return No return value." )
  110. {
  111. object->setKeepAligned( dAtob(argv[2]) );
  112. }
  113. //------------------------------------------------------------------------------
  114. ConsoleMethod(ParticleAssetEmitter, getKeepAligned, bool, 2, 2, "() Gets whether to keep emitted particles aligned or not.\n"
  115. "@return Whether to keep emitted particles aligned or not." )
  116. {
  117. return object->getKeepAligned();
  118. }
  119. //------------------------------------------------------------------------------
  120. ConsoleMethod(ParticleAssetEmitter, setAlignedAngleOffset, void, 3, 3, "(alignAngleOffset) Sets the aligned angle offset.\n"
  121. "@param alignAngleOffset The aligned angle offset.\n"
  122. "@return No return value." )
  123. {
  124. object->setAlignedAngleOffset( dAtof(argv[2]) );
  125. }
  126. //------------------------------------------------------------------------------
  127. ConsoleMethod(ParticleAssetEmitter, getAlignedAngleOffset, F32, 2, 2, "() Gets the aligned angle offset.\n"
  128. "@return The aligned angle offset." )
  129. {
  130. return object->getAlignedAngleOffset();
  131. }
  132. //------------------------------------------------------------------------------
  133. ConsoleMethod(ParticleAssetEmitter, setRandomAngleOffset, void, 3, 3, "(randomAngle) - Set Random-Orientation Angle-Offset.")
  134. {
  135. object->setRandomAngleOffset( dAtof(argv[2]) );
  136. }
  137. //------------------------------------------------------------------------------
  138. ConsoleMethod(ParticleAssetEmitter, getRandomAngleOffset, F32, 2, 2, "Get Random-Orientation Angle-Offset.")
  139. {
  140. return object->getRandomAngleOffset();
  141. }
  142. //------------------------------------------------------------------------------
  143. ConsoleMethod(ParticleAssetEmitter, setRandomArc, void, 3, 3, "(randomArc) - Set Random-Orientation Arc.")
  144. {
  145. object->setRandomArc( dAtof(argv[2]) );
  146. }
  147. //------------------------------------------------------------------------------
  148. ConsoleMethod(ParticleAssetEmitter, getRandomArc, F32, 2, 2, "Get Random-Orientation Arc.")
  149. {
  150. return object->getRandomArc();
  151. }
  152. //------------------------------------------------------------------------------
  153. ConsoleMethod(ParticleAssetEmitter, setFixedAngleOffset, void, 3, 3, "(randomAngle) - Set Fixed-Orientation Angle-Offset.")
  154. {
  155. object->setFixedAngleOffset( dAtof(argv[2]) );
  156. }
  157. //------------------------------------------------------------------------------
  158. ConsoleMethod(ParticleAssetEmitter, getFixedAngleOffset, F32, 2, 2, "Get Fixed-Orientation Angle-Offset.")
  159. {
  160. return object->getFixedAngleOffset();
  161. }
  162. //------------------------------------------------------------------------------
  163. ConsoleMethod(ParticleAssetEmitter, setPivotPoint, void, 3, 4, "(pivotX / pivotY) - Set the Pivot-Point.")
  164. {
  165. // Grab the element count.
  166. U32 elementCount =Utility::mGetStringElementCount(argv[2]);
  167. // ("pivotX pivotY")
  168. if ( (elementCount == 2) && (argc < 4) )
  169. {
  170. object->setPivotPoint( Vector2( argv[2] ) );
  171. return;
  172. }
  173. // (pivotX, pivotY)
  174. if ( (elementCount == 1) && (argc > 3) )
  175. {
  176. object->setPivotPoint( Vector2( dAtof(argv[2]), dAtof(argv[3]) ) );
  177. return;
  178. }
  179. // Warn.
  180. Con::warnf( "ParticleAssetEmitter::setPivotPoint() - Invalid number of parameters!" );
  181. }
  182. //------------------------------------------------------------------------------
  183. ConsoleMethod(ParticleAssetEmitter, getPivotPoint, const char*, 2, 2, "Get Pivot-Point.")
  184. {
  185. return object->getPivotPoint().scriptThis();
  186. }
  187. //------------------------------------------------------------------------------
  188. ConsoleMethod(ParticleAssetEmitter, setLinkEmissionRotation, void, 3, 3, "(linkEmissionRotation) - Set Link-Emission-Rotation Flag.")
  189. {
  190. object->setLinkEmissionRotation( dAtob(argv[2]) );
  191. }
  192. //------------------------------------------------------------------------------
  193. ConsoleMethod(ParticleAssetEmitter, getLinkEmissionRotation, bool, 2, 2, "Get Link-Emission-Rotation Flag.")
  194. {
  195. return object->getLinkEmissionRotation();
  196. }
  197. //------------------------------------------------------------------------------
  198. ConsoleMethod(ParticleAssetEmitter, setIntenseParticles, void, 3, 3, "(intenseParticles) - Set Intense-Particles Flag.")
  199. {
  200. object->setIntenseParticles( dAtob(argv[2]) );
  201. }
  202. //------------------------------------------------------------------------------
  203. ConsoleMethod(ParticleAssetEmitter, getIntenseParticles, bool, 2, 2, "Get Intense-Particles Flag.")
  204. {
  205. return object->getIntenseParticles();
  206. }
  207. //------------------------------------------------------------------------------
  208. ConsoleMethod(ParticleAssetEmitter, setSingleParticle, void, 3, 3, "(singleParticle) - Set Single-Particle Flag.")
  209. {
  210. // Set Single Particle.
  211. object->setSingleParticle( dAtob(argv[2]) );
  212. }
  213. //------------------------------------------------------------------------------
  214. ConsoleMethod(ParticleAssetEmitter, getSingleParticle, bool, 2, 2, "Get Single-Particle Flag.")
  215. {
  216. return object->getSingleParticle();
  217. }
  218. //------------------------------------------------------------------------------
  219. ConsoleMethod(ParticleAssetEmitter, setAttachPositionToEmitter, void, 3, 3, "(attachPositionToEmitter) - Set Attach-Position-To-Emitter Flag.")
  220. {
  221. object->setAttachPositionToEmitter( dAtob(argv[2]) );
  222. }
  223. //------------------------------------------------------------------------------
  224. ConsoleMethod(ParticleAssetEmitter, getAttachPositionToEmitter, bool, 2, 2, "Get Attach-Position-To-Emitter Flag.")
  225. {
  226. return object->getAttachPositionToEmitter();
  227. }
  228. //------------------------------------------------------------------------------
  229. ConsoleMethod(ParticleAssetEmitter, setAttachRotationToEmitter, void, 3, 3, "(attachRotationToEmitter) - Set Attach-Rotation-To-Emitter Flag.")
  230. {
  231. object->setAttachRotationToEmitter( dAtob(argv[2]) );
  232. }
  233. //------------------------------------------------------------------------------
  234. ConsoleMethod(ParticleAssetEmitter, getAttachRotationToEmitter, bool, 2, 2, "Get Attach-Rotation-To-Emitter Flag.")
  235. {
  236. return object->getAttachRotationToEmitter();
  237. }
  238. //------------------------------------------------------------------------------
  239. ConsoleMethod(ParticleAssetEmitter, setOldestInFront, void, 3, 3, "(oldestInFront) Sets whether to render particles as oldest on front or not.\n"
  240. "@param oldestInFront Whether to render particles as oldest on front or not.\n"
  241. "@return No return value." )
  242. {
  243. object->setOldestInFront( dAtob(argv[2]) );
  244. }
  245. //------------------------------------------------------------------------------
  246. ConsoleMethod(ParticleAssetEmitter, getOldestInFront, bool, 2, 2, "() Gets whether to render particles as oldest on front or not.\n"
  247. "@return Whether to render particles as oldest on front or not." )
  248. {
  249. return object->getOldestInFront();
  250. }
  251. //------------------------------------------------------------------------------
  252. ConsoleMethod(ParticleAssetEmitter, setImage, bool, 3, 4, "(imageAssetId, [frame]) Sets the emitter to use the specified image asset Id and optional frame.\n"
  253. "@param imageAssetId The image asset Id to use.\n"
  254. "@param frame The frame of the image asset Id to use. Optional.\n"
  255. "@return Whether the operation was successful or not." )
  256. {
  257. // Fetch the frame.
  258. const U32 frame = argc >= 4 ? dAtoi(argv[3]) : 0;
  259. return object->setImage( argv[2], frame );
  260. }
  261. //------------------------------------------------------------------------------
  262. ConsoleMethod(ParticleAssetEmitter, getImage, const char*, 2, 2, "() Gets the asset Id of the image asset assigned to the emitter.\n"
  263. "@return The asset Id of the image asset assigned to the emitter or nothing if no image is assigned." )
  264. {
  265. return object->getImage();
  266. }
  267. //------------------------------------------------------------------------------
  268. ConsoleMethod(ParticleAssetEmitter, setImageFrame, bool, 3, 3, "(frame) Sets the emitter to use the specified image frame.\n"
  269. "@param frame The frame of the image to use..\n"
  270. "@return Whether the operation was successful or not." )
  271. {
  272. return object->setImageFrame( dAtoi(argv[2]) );
  273. }
  274. //------------------------------------------------------------------------------
  275. ConsoleMethod(ParticleAssetEmitter, getImageFrame, S32, 2, 2, "() Gets the asset Id of the image asset assigned to the emitter.\n"
  276. "@return The asset Id of the image asset assigned to the emitter or nothing if no image is assigned." )
  277. {
  278. return object->getImageFrame();
  279. }
  280. //------------------------------------------------------------------------------
  281. ConsoleMethod(ParticleAssetEmitter, setAnimation, bool, 3, 3, "(animationAssetId) Sets the emitter to use the specified animation asset Id.\n"
  282. "@param animationAssetId The animation asset Id to use.\n"
  283. "@return Whether the operation was successful or not." )
  284. {
  285. return object->setAnimation( argv[2] );
  286. }
  287. //------------------------------------------------------------------------------
  288. ConsoleMethod(ParticleAssetEmitter, getAnimation, const char*, 2, 2, "() Gets the asset Id of the animation asset assigned to the emitter.\n"
  289. "@return The asset Id of the animation asset assigned to the emitter or nothing if no animation is assigned." )
  290. {
  291. return object->getAnimation();
  292. }
  293. //------------------------------------------------------------------------------
  294. ConsoleMethod(ParticleAssetEmitter, setBlendMode, void, 3, 3, "(blendMode) Sets whether to use render blending or not.\n"
  295. "@param blendMode Whether to use render blending or not.\n"
  296. "@return No return value." )
  297. {
  298. object->setBlendMode( dAtob(argv[2]) );
  299. }
  300. //------------------------------------------------------------------------------
  301. ConsoleMethod(ParticleAssetEmitter, getBlendMode, bool, 2, 2, "() Gets whether to use render blending or not.\n"
  302. "@return Whether to use render blending or not." )
  303. {
  304. return object->getBlendMode();
  305. }
  306. //-----------------------------------------------------------------------------
  307. ConsoleMethod(ParticleAssetEmitter, setSrcBlendFactor, void, 3, 3, "(srcBlend) - Sets the source blend factory.\n"
  308. "@param srcBlend The source blend factor.\n"
  309. "@return No return Value.")
  310. {
  311. // Fetch source blend factor.
  312. const GLenum blendFactor = SceneObject::getSrcBlendFactorEnum(argv[2]);
  313. object->setSrcBlendFactor( blendFactor );
  314. }
  315. //-----------------------------------------------------------------------------
  316. ConsoleMethod(ParticleAssetEmitter, getSrcBlendFactor, const char*, 2, 2, "() - Gets the source render blend factor.\n"
  317. "@return (srcBlend) The source render blend factor.")
  318. {
  319. return SceneObject::getSrcBlendFactorDescription(object->getSrcBlendFactor());
  320. }
  321. //-----------------------------------------------------------------------------
  322. ConsoleMethod(ParticleAssetEmitter, setDstBlendFactor, void, 3, 3, "(dstBlend) - Sets the destination render blend factor.\n"
  323. "@param dstBlend The destination render blend factor.\n"
  324. "@return No return Value.")
  325. {
  326. // Fetch destination blend factor.
  327. const GLenum blendFactor = SceneObject::getDstBlendFactorEnum(argv[2]);
  328. object->setDstBlendFactor( blendFactor );
  329. }
  330. //-----------------------------------------------------------------------------
  331. ConsoleMethod(ParticleAssetEmitter, getDstBlendFactor, const char*, 2, 2, "() - Gets the destination render blend factor.\n"
  332. "@return (dstBlend) The destination render blend factor.")
  333. {
  334. return SceneObject::getDstBlendFactorDescription(object->getDstBlendFactor());
  335. }
  336. //-----------------------------------------------------------------------------
  337. ConsoleMethod(ParticleAssetEmitter, setAlphaTest, void, 3, 3, "(float alpha) - Set the render alpha test threshold.\n"
  338. "@param alpha The alpha test threshold in the range of 0.0 to 1.0. Less than zero to disable alpha testing.\n"
  339. "@return No return value." )
  340. {
  341. object->setAlphaTest(dAtof(argv[2]));
  342. }
  343. //-----------------------------------------------------------------------------
  344. ConsoleMethod(ParticleAssetEmitter, getAlphaTest, F32, 2, 2, "() - Gets the render alpha test threshold.\n"
  345. "@return The render alpha test threshold in the range of 0.0f to 1.0. Less than zero represents disabled alpha testing.")
  346. {
  347. return object->getAlphaTest();
  348. }
  349. //-----------------------------------------------------------------------------
  350. /// Particle emitter fields.
  351. //-----------------------------------------------------------------------------
  352. ConsoleMethod(ParticleAssetEmitter, getSelectableFieldCount, S32, 2, 2, "() Gets the number of available selectable fields.\n"
  353. "@return The number of available selectable fields." )
  354. {
  355. return object->getParticleFields().getFields().size();
  356. }
  357. //-----------------------------------------------------------------------------
  358. ConsoleMethod(ParticleAssetEmitter, getSelectableFieldName, const char*, 3, 3, "(fieldIndex) Gets the selectable field at the specified index.\n"
  359. "@return The selectable field name at the specified index." )
  360. {
  361. // Fetch the field hash.
  362. const ParticleAssetFieldCollection::typeFieldHash& fieldHash = object->getParticleFields().getFields();
  363. // Fetch the index.
  364. S32 fieldIndex = dAtoi( argv[2] );
  365. // Is the field index valid?
  366. if ( fieldIndex >= 0 && fieldIndex < (S32)fieldHash.size() )
  367. {
  368. // Yes, but because the fields are in a hash-table, we'll have to iterate and get O(index).
  369. for( ParticleAssetFieldCollection::typeFieldHash::const_iterator fieldItr = fieldHash.begin(); fieldItr != fieldHash.end(); ++fieldItr, --fieldIndex )
  370. {
  371. // Skip if this is not the field index we're looking for?
  372. if ( fieldIndex != 0 )
  373. continue;
  374. // Found it so return the field name.
  375. return fieldItr->value->getFieldName();
  376. }
  377. }
  378. // Warn.
  379. Con::warnf( "ParticleAssetEmitter::getSelectableFieldName() - Index '%d' is out of range.", fieldIndex );
  380. return StringTable->EmptyString;
  381. }
  382. //-----------------------------------------------------------------------------
  383. ConsoleMethod(ParticleAssetEmitter, selectField, bool, 3, 3, "(fieldName) Select the specified field by its name.\n"
  384. "@param fieldName The field name to use for the selection. Use an empty name to deselect to stop accidental changes.\n"
  385. "@return Whether the field was successfully selected or not.")
  386. {
  387. return object->getParticleFields().selectField( argv[2] ) != NULL;
  388. }
  389. //-----------------------------------------------------------------------------
  390. ConsoleMethod(ParticleAssetEmitter, deselectField, void, 2, 2, "() Deselect any selected field. If no field is selected then nothing happens.\n"
  391. "@return No return value.")
  392. {
  393. object->getParticleFields().deselectField();
  394. }
  395. //-----------------------------------------------------------------------------
  396. ConsoleMethod(ParticleAssetEmitter, getSelectedField, bool, 2, 2, "() Gets the selected field name or nothing if no field is selected.\n"
  397. "@return The selected field name or nothing if no fields is selected.")
  398. {
  399. // Get the selected field.
  400. const ParticleAssetField* pParticleAssetField = object->getParticleFields().getSelectedField();
  401. return pParticleAssetField == NULL ? StringTable->EmptyString : pParticleAssetField->getFieldName();
  402. }
  403. //-----------------------------------------------------------------------------
  404. ConsoleMethod(ParticleAssetEmitter, setSingleDataKey, S32, 3, 3, "(value) Sets a single data-key at time-zero with the specified value. All existing keys are cleared.\n"
  405. "@param value The value to set the key to.\n"
  406. "@return Returns the index of the new data-key (always zero) or -1 on failure.")
  407. {
  408. return object->getParticleFields().setSingleDataKey( dAtof(argv[2]) );
  409. }
  410. //-----------------------------------------------------------------------------
  411. ConsoleMethod(ParticleAssetEmitter, addDataKey, S32, 4, 4, "(time, value) Add Data-Key to Graph.\n"
  412. "@param time The key time.\n"
  413. "@param value The value at specified time\n"
  414. "@return Returns the index of the new data-key or -1 on failure.")
  415. {
  416. return object->getParticleFields().addDataKey( dAtof(argv[2]), dAtof(argv[3]) );
  417. }
  418. //-----------------------------------------------------------------------------
  419. ConsoleMethod(ParticleAssetEmitter, removeDataKey, bool, 3, 3, "(keyIndex) Remove the data-key from the field.\n"
  420. "@param keyIndex The index of the data-key you want to remove.\n"
  421. "@return Whether the operation was successful or not.")
  422. {
  423. return object->getParticleFields().removeDataKey( dAtoi(argv[2]) );
  424. }
  425. //-----------------------------------------------------------------------------
  426. ConsoleMethod(ParticleAssetEmitter, clearDataKeys, bool, 2, 2, "() Clears all data-key(s) from the field.\n"
  427. "@return Whether the operation was successful or not.")
  428. {
  429. return object->getParticleFields().clearDataKeys();
  430. }
  431. //-----------------------------------------------------------------------------
  432. ConsoleMethod(ParticleAssetEmitter, setDataKeyValue, bool, 4, 4, "(keyIndex, value) Set data-key value for the field.\n"
  433. "@param keyIndex The index of the key to be modified.\n"
  434. "@param value The value to change the key to.\n"
  435. "@return Whether the operation was successful or not.")
  436. {
  437. // Set Data Key.
  438. return object->getParticleFields().setDataKey( dAtoi(argv[2]), dAtof(argv[3]) );
  439. }
  440. //-----------------------------------------------------------------------------
  441. ConsoleMethod(ParticleAssetEmitter, getDataKeyCount, S32, 2, 2, "() Gets the data-key count.\n"
  442. "@return The number of data-keys in the currently selected field or -1 if no field is selected.")
  443. {
  444. // Get Data Key Count.
  445. return object->getParticleFields().getDataKeyCount();
  446. }
  447. //-----------------------------------------------------------------------------
  448. ConsoleMethod(ParticleAssetEmitter, getDataKey, const char*, 3, 3, "(keyIndex) Gets the data-key at the specified index from the field.\n"
  449. "@param keyIndex The index of the data-key to be retrieved.\n"
  450. "@return The data-key comprising both the time and value or nothing if the key is invalid.")
  451. {
  452. // Fetch the key index.
  453. const S32 keyIndex = dAtoi(argv[2]);
  454. // Fetch the data-key.
  455. const ParticleAssetField::DataKey dataKey = object->getParticleFields().getDataKey( keyIndex );
  456. // Finish if the data-key is bad.
  457. if ( dataKey == ParticleAssetField::BadDataKey )
  458. return StringTable->EmptyString;
  459. // Create Returnable Buffer.
  460. char* pBuffer = Con::getReturnBuffer(32);
  461. // Format Buffer.
  462. dSprintf(pBuffer, 32, "%f %f", dataKey.mTime, dataKey.mValue );
  463. // Return buffer.
  464. return pBuffer;
  465. }
  466. //-----------------------------------------------------------------------------
  467. ConsoleMethod(ParticleAssetEmitter, getMinValue, F32, 2, 2, "() Get the minimum value for the field.\n"
  468. "@return The minimum value for the field or always 0.0 if no field is selected." )
  469. {
  470. return object->getParticleFields().getMinValue();
  471. }
  472. //-----------------------------------------------------------------------------
  473. ConsoleMethod(ParticleAssetEmitter, getMaxValue, F32, 2, 2, "() Get the maximum value for the field.\n"
  474. "@return The maximum value for the field or always 0.0 if no field is selected." )
  475. {
  476. return object->getParticleFields().getMaxValue();
  477. }
  478. //-----------------------------------------------------------------------------
  479. ConsoleMethod(ParticleAssetEmitter, getMinTime, F32, 2, 2, "() Get the minimum time for the field.\n"
  480. "@return The minimum time for the field or always 0.0 if no field is selected." )
  481. {
  482. return object->getParticleFields().getMinTime();
  483. }
  484. //-----------------------------------------------------------------------------
  485. ConsoleMethod(ParticleAssetEmitter, getMaxTime, F32, 2, 2, "() Get the maximum time for the field.\n"
  486. "@return The maximum time for the field or always 0.0 if no field is selected." )
  487. {
  488. return object->getParticleFields().getMaxTime();
  489. }
  490. //-----------------------------------------------------------------------------
  491. ConsoleMethod(ParticleAssetEmitter, getFieldValue, F32, 3, 3, "(time) Get the fields' value at the specified time.\n"
  492. "@param time The time to sample the field value at.\n"
  493. "@return The fields' value at the specified time or always 0.0 if no field is selected.")
  494. {
  495. return object->getParticleFields().getFieldValue( dAtof(argv[2]) );
  496. }
  497. //-----------------------------------------------------------------------------
  498. ConsoleMethod(ParticleAssetEmitter, setRepeatTime, bool, 3, 3, "(repeatTime) Sets the time period to repeat (cycle) the fields' values at.\n"
  499. "@return Whether the operation was successful or not.")
  500. {
  501. return object->getParticleFields().setRepeatTime( dAtof(argv[2]) );
  502. }
  503. //-----------------------------------------------------------------------------
  504. ConsoleMethod(ParticleAssetEmitter, getRepeatTime, F32, 2, 2, "() Gets the time period that the fields' value repeat (cycle) at.\n"
  505. "@return The time period that the fields' value repeat (cycle) at.\n" )
  506. {
  507. return object->getParticleFields().getRepeatTime();
  508. }
  509. //-----------------------------------------------------------------------------
  510. ConsoleMethod(ParticleAssetEmitter, setValueScale, bool, 3, 3, "(valueScale) Set the scaling of field values retrieved from the field. This does not alter the actual data-key values.\n"
  511. "@param valueScale The scale for field values retrieved from the field.\n"
  512. "@return Whether the operation was successful or not.")
  513. {
  514. return object->getParticleFields().setValueScale( dAtof(argv[2]) );
  515. }
  516. //-----------------------------------------------------------------------------
  517. ConsoleMethod(ParticleAssetEmitter, getValueScale, F32, 2, 2, "() Gets the scaling of field values' retrieved from the field.\n"
  518. "@return The scaling of field values' retrieved from the field." )
  519. {
  520. return object->getParticleFields().getValueScale();
  521. }