ParticleAssetEmitter_ScriptBinding.h 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800
  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, setEmitterOffset, void, 3, 4, "(float X / float Y) - Offsets the position of the emitter relative to the effect or player position.\n"
  66. "@return No return value.")
  67. {
  68. // Grab the element count.
  69. U32 elementCount =Utility::mGetStringElementCount(argv[2]);
  70. // ("positionX positionY")
  71. if ( (elementCount == 2) && (argc < 4) )
  72. {
  73. object->setEmitterOffset( Vector2( argv[2] ) );
  74. return;
  75. }
  76. // (positionX, positionY)
  77. if ( (elementCount == 1) && (argc > 3) )
  78. {
  79. object->setEmitterOffset( Vector2( dAtof(argv[2]), dAtof(argv[3]) ) );
  80. return;
  81. }
  82. // Warn.
  83. Con::warnf( "ParticleAssetEmitter::setEmitterOffset() - Invalid number of parameters!" );
  84. }
  85. //------------------------------------------------------------------------------
  86. ConsoleMethod(ParticleAssetEmitter, getEmitterOffset, const char*, 2, 2, "Gets the emitter offset position.\n"
  87. "@return (float x/float y) The offset of the emitter relative to the effect or player position.")
  88. {
  89. return object->getEmitterOffset().scriptThis();
  90. }
  91. //------------------------------------------------------------------------------
  92. ConsoleMethod(ParticleAssetEmitter, setEmitterSize, void, 3, 4, "(float width / float height) - Sets the emitter size.\n"
  93. "@param width The width of the emitter.\n"
  94. "@param height The height of the emitter.\n"
  95. "@return No return value.")
  96. {
  97. F32 width, height;
  98. const U32 elementCount = Utility::mGetStringElementCount(argv[2]);
  99. // ("width height")
  100. if ((elementCount == 2) && (argc == 3))
  101. {
  102. width = dAtof(Utility::mGetStringElement(argv[2], 0));
  103. height = dAtof(Utility::mGetStringElement(argv[2], 1));
  104. }
  105. // (width, [height])
  106. else if (elementCount == 1)
  107. {
  108. width = dAtof(argv[2]);
  109. if (argc > 3)
  110. height = dAtof(argv[3]);
  111. else
  112. height = width;
  113. }
  114. // Invalid
  115. else
  116. {
  117. Con::warnf("ParticleAssetEmitter::setEmitterSize() - Invalid number of parameters!");
  118. return;
  119. }
  120. // Set Size.
  121. object->setEmitterSize(Vector2(width, height));
  122. }
  123. //------------------------------------------------------------------------------
  124. ConsoleMethod(ParticleAssetEmitter, getEmitterSize, const char*, 2, 2, "Gets the emitter size.\n"
  125. "@return (float width/float height) The width and height of the emitter.")
  126. {
  127. return object->getEmitterSize().scriptThis();
  128. }
  129. //------------------------------------------------------------------------------
  130. ConsoleMethod(ParticleAssetEmitter, setEmitterAngle, void, 3, 3, "(float angle) - Sets the emitter angle.\n"
  131. "@param angle The angle of the emitter."
  132. "@return No return value.")
  133. {
  134. // Set Rotation.
  135. object->setEmitterAngle( mDegToRad( dAtof(argv[2]) ) );
  136. }
  137. //-----------------------------------------------------------------------------
  138. ConsoleMethod(ParticleAssetEmitter, getEmitterAngle, F32, 2, 2, "() Gets the emitter angle.\n"
  139. "@return (float angle) The emitter's current angle.")
  140. {
  141. // Return angle.
  142. return mRadToDeg( object->getEmitterAngle());
  143. }
  144. //-----------------------------------------------------------------------------
  145. ConsoleMethod(ParticleAssetEmitter, setFixedAspect, void, 3, 3, "(fixedAspect) Sets the emitter to used a fixed-aspect for particles.\n"
  146. "@param fixedAspect Whether to use a fixed-aspect or not.\n"
  147. "@return No return value." )
  148. {
  149. object->setFixedAspect( dAtob(argv[2]) );
  150. }
  151. //-----------------------------------------------------------------------------
  152. ConsoleMethod(ParticleAssetEmitter, getFixedAspect, bool, 2, 2, "() Gets whether the emitter uses a fixed-aspect for particles or not.\n"
  153. "@return Whether the emitter uses a fixed-aspect for particles or not." )
  154. {
  155. return object->getFixedAspect();
  156. }
  157. //-----------------------------------------------------------------------------
  158. ConsoleMethod(ParticleAssetEmitter, setFixedForceAngle, void, 3, 3, "(fixedForceAngle) Sets the emitter fixed-force angle for particles.\n"
  159. "@param fixedForceAngle The fixed-force angle for particles.\n"
  160. "@return No return value." )
  161. {
  162. object->setFixedForceAngle( dAtof(argv[2]) );
  163. }
  164. //-----------------------------------------------------------------------------
  165. ConsoleMethod(ParticleAssetEmitter, getFixedForceAngle, F32, 2, 2, "() Gets the emitter fixed-force angle for particles.\n"
  166. "@return The fixed-force angle for particles." )
  167. {
  168. return object->getFixedForceAngle();
  169. }
  170. //-----------------------------------------------------------------------------
  171. ConsoleMethod(ParticleAssetEmitter, setOrientationType, void, 3, 3, "(orientationType) Sets the orientation-type of the emitter.\n"
  172. "@param orientationType The orientation-type to set the emitter to. Either 'FIXED', 'ALIGNED' or 'RANDOM'.\n"
  173. "An orientation-type of 'FIXED' causes the particles to be orientation at a fixed angle.\n"
  174. "An orientation-type of 'ALIGNED' causes the particles to be orientation at the current emission angle.\n"
  175. "An orientation-type of 'RANDOM' causes the particles to be orientation at a fixed angle.\n"
  176. "@return No return value." )
  177. {
  178. object->setOrientationType( ParticleAssetEmitter::getOrientationTypeEnum(argv[2]) );
  179. }
  180. //-----------------------------------------------------------------------------
  181. ConsoleMethod(ParticleAssetEmitter, getOrientationType, const char*, 2, 2, "() Gets the orientation-type of the emitter.\n"
  182. "@return The orientation-type of the emitter." )
  183. {
  184. return ParticleAssetEmitter::getOrientationTypeDescription( object->getOrientationType() );
  185. }
  186. //------------------------------------------------------------------------------
  187. ConsoleMethod(ParticleAssetEmitter, setKeepAligned, void, 3, 3, "(keepAligned) Sets whether to keep emitted particles aligned or not."
  188. "@keepAligned Whether to keep emitted particles aligned or not.\n"
  189. "@return No return value." )
  190. {
  191. object->setKeepAligned( dAtob(argv[2]) );
  192. }
  193. //------------------------------------------------------------------------------
  194. ConsoleMethod(ParticleAssetEmitter, getKeepAligned, bool, 2, 2, "() Gets whether to keep emitted particles aligned or not.\n"
  195. "@return Whether to keep emitted particles aligned or not." )
  196. {
  197. return object->getKeepAligned();
  198. }
  199. //------------------------------------------------------------------------------
  200. ConsoleMethod(ParticleAssetEmitter, setAlignedAngleOffset, void, 3, 3, "(alignAngleOffset) Sets the aligned angle offset.\n"
  201. "@param alignAngleOffset The aligned angle offset.\n"
  202. "@return No return value." )
  203. {
  204. object->setAlignedAngleOffset( dAtof(argv[2]) );
  205. }
  206. //------------------------------------------------------------------------------
  207. ConsoleMethod(ParticleAssetEmitter, getAlignedAngleOffset, F32, 2, 2, "() Gets the aligned angle offset.\n"
  208. "@return The aligned angle offset." )
  209. {
  210. return object->getAlignedAngleOffset();
  211. }
  212. //------------------------------------------------------------------------------
  213. ConsoleMethod(ParticleAssetEmitter, setRandomAngleOffset, void, 3, 3, "(randomAngle) - Set Random-Orientation Angle-Offset.")
  214. {
  215. object->setRandomAngleOffset( dAtof(argv[2]) );
  216. }
  217. //------------------------------------------------------------------------------
  218. ConsoleMethod(ParticleAssetEmitter, getRandomAngleOffset, F32, 2, 2, "Get Random-Orientation Angle-Offset.")
  219. {
  220. return object->getRandomAngleOffset();
  221. }
  222. //------------------------------------------------------------------------------
  223. ConsoleMethod(ParticleAssetEmitter, setRandomArc, void, 3, 3, "(randomArc) - Set Random-Orientation Arc.")
  224. {
  225. object->setRandomArc( dAtof(argv[2]) );
  226. }
  227. //------------------------------------------------------------------------------
  228. ConsoleMethod(ParticleAssetEmitter, getRandomArc, F32, 2, 2, "Get Random-Orientation Arc.")
  229. {
  230. return object->getRandomArc();
  231. }
  232. //------------------------------------------------------------------------------
  233. ConsoleMethod(ParticleAssetEmitter, setFixedAngleOffset, void, 3, 3, "(randomAngle) - Set Fixed-Orientation Angle-Offset.")
  234. {
  235. object->setFixedAngleOffset( dAtof(argv[2]) );
  236. }
  237. //------------------------------------------------------------------------------
  238. ConsoleMethod(ParticleAssetEmitter, getFixedAngleOffset, F32, 2, 2, "Get Fixed-Orientation Angle-Offset.")
  239. {
  240. return object->getFixedAngleOffset();
  241. }
  242. //------------------------------------------------------------------------------
  243. ConsoleMethod(ParticleAssetEmitter, setPivotPoint, void, 3, 4, "(pivotX / pivotY) - Set the Pivot-Point.")
  244. {
  245. // Grab the element count.
  246. U32 elementCount =Utility::mGetStringElementCount(argv[2]);
  247. // ("pivotX pivotY")
  248. if ( (elementCount == 2) && (argc < 4) )
  249. {
  250. object->setPivotPoint( Vector2( argv[2] ) );
  251. return;
  252. }
  253. // (pivotX, pivotY)
  254. if ( (elementCount == 1) && (argc > 3) )
  255. {
  256. object->setPivotPoint( Vector2( dAtof(argv[2]), dAtof(argv[3]) ) );
  257. return;
  258. }
  259. // Warn.
  260. Con::warnf( "ParticleAssetEmitter::setPivotPoint() - Invalid number of parameters!" );
  261. }
  262. //------------------------------------------------------------------------------
  263. ConsoleMethod(ParticleAssetEmitter, getPivotPoint, const char*, 2, 2, "Get Pivot-Point.")
  264. {
  265. return object->getPivotPoint().scriptThis();
  266. }
  267. //------------------------------------------------------------------------------
  268. ConsoleMethod(ParticleAssetEmitter, setLinkEmissionRotation, void, 3, 3, "(linkEmissionRotation) - Set Link-Emission-Rotation Flag.")
  269. {
  270. object->setLinkEmissionRotation( dAtob(argv[2]) );
  271. }
  272. //------------------------------------------------------------------------------
  273. ConsoleMethod(ParticleAssetEmitter, getLinkEmissionRotation, bool, 2, 2, "Get Link-Emission-Rotation Flag.")
  274. {
  275. return object->getLinkEmissionRotation();
  276. }
  277. //------------------------------------------------------------------------------
  278. ConsoleMethod(ParticleAssetEmitter, setIntenseParticles, void, 3, 3, "(intenseParticles) - Set Intense-Particles Flag.")
  279. {
  280. object->setIntenseParticles( dAtob(argv[2]) );
  281. }
  282. //------------------------------------------------------------------------------
  283. ConsoleMethod(ParticleAssetEmitter, getIntenseParticles, bool, 2, 2, "Get Intense-Particles Flag.")
  284. {
  285. return object->getIntenseParticles();
  286. }
  287. //------------------------------------------------------------------------------
  288. ConsoleMethod(ParticleAssetEmitter, setSingleParticle, void, 3, 3, "(singleParticle) - Set Single-Particle Flag.")
  289. {
  290. // Set Single Particle.
  291. object->setSingleParticle( dAtob(argv[2]) );
  292. }
  293. //------------------------------------------------------------------------------
  294. ConsoleMethod(ParticleAssetEmitter, getSingleParticle, bool, 2, 2, "Get Single-Particle Flag.")
  295. {
  296. return object->getSingleParticle();
  297. }
  298. //------------------------------------------------------------------------------
  299. ConsoleMethod(ParticleAssetEmitter, setAttachPositionToEmitter, void, 3, 3, "(attachPositionToEmitter) - Set Attach-Position-To-Emitter Flag.")
  300. {
  301. object->setAttachPositionToEmitter( dAtob(argv[2]) );
  302. }
  303. //------------------------------------------------------------------------------
  304. ConsoleMethod(ParticleAssetEmitter, getAttachPositionToEmitter, bool, 2, 2, "Get Attach-Position-To-Emitter Flag.")
  305. {
  306. return object->getAttachPositionToEmitter();
  307. }
  308. //------------------------------------------------------------------------------
  309. ConsoleMethod(ParticleAssetEmitter, setAttachRotationToEmitter, void, 3, 3, "(attachRotationToEmitter) - Set Attach-Rotation-To-Emitter Flag.")
  310. {
  311. object->setAttachRotationToEmitter( dAtob(argv[2]) );
  312. }
  313. //------------------------------------------------------------------------------
  314. ConsoleMethod(ParticleAssetEmitter, getAttachRotationToEmitter, bool, 2, 2, "Get Attach-Rotation-To-Emitter Flag.")
  315. {
  316. return object->getAttachRotationToEmitter();
  317. }
  318. //------------------------------------------------------------------------------
  319. ConsoleMethod(ParticleAssetEmitter, setOldestInFront, void, 3, 3, "(oldestInFront) Sets whether to render particles as oldest on front or not.\n"
  320. "@param oldestInFront Whether to render particles as oldest on front or not.\n"
  321. "@return No return value." )
  322. {
  323. object->setOldestInFront( dAtob(argv[2]) );
  324. }
  325. //------------------------------------------------------------------------------
  326. ConsoleMethod(ParticleAssetEmitter, getOldestInFront, bool, 2, 2, "() Gets whether to render particles as oldest on front or not.\n"
  327. "@return Whether to render particles as oldest on front or not." )
  328. {
  329. return object->getOldestInFront();
  330. }
  331. //------------------------------------------------------------------------------
  332. ConsoleMethod(ParticleAssetEmitter, setImage, bool, 3, 4, "(imageAssetId, [frame]) Sets the emitter to use the specified image asset Id and optional frame.\n"
  333. "@param imageAssetId The image asset Id to use.\n"
  334. "@param frame The frame of the image asset Id to use. Optional.\n"
  335. "@return Whether the operation was successful or not." )
  336. {
  337. // Fetch the frame.
  338. const U32 frame = argc >= 4 ? dAtoi(argv[3]) : 0;
  339. return object->setImage( argv[2], frame );
  340. }
  341. //------------------------------------------------------------------------------
  342. ConsoleMethod(ParticleAssetEmitter, getImage, const char*, 2, 2, "() Gets the asset Id of the image asset assigned to the emitter.\n"
  343. "@return The asset Id of the image asset assigned to the emitter or nothing if no image is assigned." )
  344. {
  345. return object->getImage();
  346. }
  347. //------------------------------------------------------------------------------
  348. ConsoleMethod(ParticleAssetEmitter, setImageFrame, bool, 3, 3, "(frame) Sets the emitter to use the specified image frame.\n"
  349. "@param frame The frame of the image to use..\n"
  350. "@return Whether the operation was successful or not." )
  351. {
  352. return object->setImageFrame( dAtoi(argv[2]) );
  353. }
  354. //------------------------------------------------------------------------------
  355. ConsoleMethod(ParticleAssetEmitter, getImageFrame, S32, 2, 2, "() Gets the asset Id of the image asset assigned to the emitter.\n"
  356. "@return The asset Id of the image asset assigned to the emitter or nothing if no image is assigned." )
  357. {
  358. return object->getImageFrame();
  359. }
  360. //------------------------------------------------------------------------------
  361. ConsoleMethod(ParticleAssetEmitter, setRandomImageFrame, void, 3, 3, "(randomImageFrame) Disables the Frame field and uses a random frame from the specified ImageAsset.\n"
  362. "@param randomImageFrame Whether to use a random image frame or not.\n"
  363. "@return No return value." )
  364. {
  365. object->setRandomImageFrame( dAtob(argv[2]) );
  366. }
  367. //------------------------------------------------------------------------------
  368. ConsoleMethod(ParticleAssetEmitter, getRandomImageFrame, bool, 2, 2, "() Gets whether a random frame from the specified ImageAsset is being used or not.\n"
  369. "@return Whether to use a random image frame or not." )
  370. {
  371. return object->getRandomImageFrame();
  372. }
  373. //-----------------------------------------------------------------------------
  374. ConsoleMethod(ParticleAssetEmitter, setAnimation, bool, 3, 3, "(animationAssetId) Sets the emitter to use the specified animation asset Id.\n"
  375. "@param animationAssetId The animation asset Id to use.\n"
  376. "@return Whether the operation was successful or not." )
  377. {
  378. return object->setAnimation( argv[2] );
  379. }
  380. //------------------------------------------------------------------------------
  381. ConsoleMethod(ParticleAssetEmitter, getAnimation, const char*, 2, 2, "() Gets the asset Id of the animation asset assigned to the emitter.\n"
  382. "@return The asset Id of the animation asset assigned to the emitter or nothing if no animation is assigned." )
  383. {
  384. return object->getAnimation();
  385. }
  386. //------------------------------------------------------------------------------
  387. ConsoleMethod(ParticleAssetEmitter, setBlendMode, void, 3, 3, "(blendMode) Sets whether to use render blending or not.\n"
  388. "@param blendMode Whether to use render blending or not.\n"
  389. "@return No return value." )
  390. {
  391. object->setBlendMode( dAtob(argv[2]) );
  392. }
  393. //------------------------------------------------------------------------------
  394. ConsoleMethod(ParticleAssetEmitter, getBlendMode, bool, 2, 2, "() Gets whether to use render blending or not.\n"
  395. "@return Whether to use render blending or not." )
  396. {
  397. return object->getBlendMode();
  398. }
  399. //-----------------------------------------------------------------------------
  400. ConsoleMethod(ParticleAssetEmitter, setSrcBlendFactor, void, 3, 3, "(srcBlend) - Sets the source blend factory.\n"
  401. "@param srcBlend The source blend factor.\n"
  402. "@return No return Value.")
  403. {
  404. // Fetch source blend factor.
  405. const GLenum blendFactor = SceneObject::getSrcBlendFactorEnum(argv[2]);
  406. object->setSrcBlendFactor( blendFactor );
  407. }
  408. //-----------------------------------------------------------------------------
  409. ConsoleMethod(ParticleAssetEmitter, getSrcBlendFactor, const char*, 2, 2, "() - Gets the source render blend factor.\n"
  410. "@return (srcBlend) The source render blend factor.")
  411. {
  412. return SceneObject::getSrcBlendFactorDescription(object->getSrcBlendFactor());
  413. }
  414. //-----------------------------------------------------------------------------
  415. ConsoleMethod(ParticleAssetEmitter, setDstBlendFactor, void, 3, 3, "(dstBlend) - Sets the destination render blend factor.\n"
  416. "@param dstBlend The destination render blend factor.\n"
  417. "@return No return Value.")
  418. {
  419. // Fetch destination blend factor.
  420. const GLenum blendFactor = SceneObject::getDstBlendFactorEnum(argv[2]);
  421. object->setDstBlendFactor( blendFactor );
  422. }
  423. //-----------------------------------------------------------------------------
  424. ConsoleMethod(ParticleAssetEmitter, getDstBlendFactor, const char*, 2, 2, "() - Gets the destination render blend factor.\n"
  425. "@return (dstBlend) The destination render blend factor.")
  426. {
  427. return SceneObject::getDstBlendFactorDescription(object->getDstBlendFactor());
  428. }
  429. //-----------------------------------------------------------------------------
  430. ConsoleMethod(ParticleAssetEmitter, setAlphaTest, void, 3, 3, "(float alpha) - Set the render alpha test threshold.\n"
  431. "@param alpha The alpha test threshold in the range of 0.0 to 1.0. Less than zero to disable alpha testing.\n"
  432. "@return No return value." )
  433. {
  434. object->setAlphaTest(dAtof(argv[2]));
  435. }
  436. //-----------------------------------------------------------------------------
  437. ConsoleMethod(ParticleAssetEmitter, getAlphaTest, F32, 2, 2, "() - Gets the render alpha test threshold.\n"
  438. "@return The render alpha test threshold in the range of 0.0f to 1.0. Less than zero represents disabled alpha testing.")
  439. {
  440. return object->getAlphaTest();
  441. }
  442. //-----------------------------------------------------------------------------
  443. /// Particle emitter fields.
  444. //-----------------------------------------------------------------------------
  445. ConsoleMethod(ParticleAssetEmitter, getSelectableFieldCount, S32, 2, 2, "() Gets the number of available selectable fields.\n"
  446. "@return The number of available selectable fields." )
  447. {
  448. return object->getParticleFields().getFields().size();
  449. }
  450. //-----------------------------------------------------------------------------
  451. ConsoleMethod(ParticleAssetEmitter, getSelectableFieldName, const char*, 3, 3, "(fieldIndex) Gets the selectable field at the specified index.\n"
  452. "@return The selectable field name at the specified index." )
  453. {
  454. // Fetch the field hash.
  455. const ParticleAssetFieldCollection::typeFieldHash& fieldHash = object->getParticleFields().getFields();
  456. // Fetch the index.
  457. S32 fieldIndex = dAtoi( argv[2] );
  458. // Is the field index valid?
  459. if ( fieldIndex >= 0 && fieldIndex < (S32)fieldHash.size() )
  460. {
  461. // Yes, but because the fields are in a hash-table, we'll have to iterate and get O(index).
  462. for( ParticleAssetFieldCollection::typeFieldHash::const_iterator fieldItr = fieldHash.begin(); fieldItr != fieldHash.end(); ++fieldItr, --fieldIndex )
  463. {
  464. // Skip if this is not the field index we're looking for?
  465. if ( fieldIndex != 0 )
  466. continue;
  467. // Found it so return the field name.
  468. return fieldItr->value->getFieldName();
  469. }
  470. }
  471. // Warn.
  472. Con::warnf( "ParticleAssetEmitter::getSelectableFieldName() - Index '%d' is out of range.", fieldIndex );
  473. return StringTable->EmptyString;
  474. }
  475. //-----------------------------------------------------------------------------
  476. ConsoleMethod(ParticleAssetEmitter, selectField, bool, 3, 3, "(fieldName) Select the specified field by its name.\n"
  477. "@param fieldName The field name to use for the selection. Use an empty name to deselect to stop accidental changes.\n"
  478. "@return Whether the field was successfully selected or not.")
  479. {
  480. return object->getParticleFields().selectField( argv[2] ) != NULL;
  481. }
  482. //-----------------------------------------------------------------------------
  483. ConsoleMethod(ParticleAssetEmitter, deselectField, void, 2, 2, "() Deselect any selected field. If no field is selected then nothing happens.\n"
  484. "@return No return value.")
  485. {
  486. object->getParticleFields().deselectField();
  487. }
  488. //-----------------------------------------------------------------------------
  489. ConsoleMethod(ParticleAssetEmitter, getSelectedField, const char*, 2, 2, "() Gets the selected field name or nothing if no field is selected.\n"
  490. "@return The selected field name or nothing if no fields is selected.")
  491. {
  492. // Get the selected field.
  493. const ParticleAssetField* pParticleAssetField = object->getParticleFields().getSelectedField();
  494. return pParticleAssetField == NULL ? StringTable->EmptyString : pParticleAssetField->getFieldName();
  495. }
  496. //-----------------------------------------------------------------------------
  497. 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"
  498. "@param value The value to set the key to.\n"
  499. "@return Returns the index of the new data-key (always zero) or -1 on failure.")
  500. {
  501. return object->getParticleFields().setSingleDataKey( dAtof(argv[2]) );
  502. }
  503. //-----------------------------------------------------------------------------
  504. ConsoleMethod(ParticleAssetEmitter, addDataKey, S32, 4, 4, "(time, value) Add Data-Key to Graph.\n"
  505. "@param time The key time.\n"
  506. "@param value The value at specified time\n"
  507. "@return Returns the index of the new data-key or -1 on failure.")
  508. {
  509. return object->getParticleFields().addDataKey( dAtof(argv[2]), dAtof(argv[3]) );
  510. }
  511. //-----------------------------------------------------------------------------
  512. ConsoleMethod(ParticleAssetEmitter, removeDataKey, bool, 3, 3, "(keyIndex) Remove the data-key from the field.\n"
  513. "@param keyIndex The index of the data-key you want to remove.\n"
  514. "@return Whether the operation was successful or not.")
  515. {
  516. return object->getParticleFields().removeDataKey( dAtoi(argv[2]) );
  517. }
  518. //-----------------------------------------------------------------------------
  519. ConsoleMethod(ParticleAssetEmitter, clearDataKeys, bool, 2, 2, "() Clears all data-key(s) from the field.\n"
  520. "@return Whether the operation was successful or not.")
  521. {
  522. return object->getParticleFields().clearDataKeys();
  523. }
  524. //-----------------------------------------------------------------------------
  525. ConsoleMethod(ParticleAssetEmitter, setDataKeyValue, bool, 4, 4, "(keyIndex, value) Set data-key value for the field.\n"
  526. "@param keyIndex The index of the key to be modified.\n"
  527. "@param value The value to change the key to.\n"
  528. "@return Whether the operation was successful or not.")
  529. {
  530. // Set Data Key.
  531. return object->getParticleFields().setDataKey( dAtoi(argv[2]), dAtof(argv[3]) );
  532. }
  533. //-----------------------------------------------------------------------------
  534. ConsoleMethod(ParticleAssetEmitter, getDataKeyCount, S32, 2, 2, "() Gets the data-key count.\n"
  535. "@return The number of data-keys in the currently selected field or -1 if no field is selected.")
  536. {
  537. // Get Data Key Count.
  538. return object->getParticleFields().getDataKeyCount();
  539. }
  540. //-----------------------------------------------------------------------------
  541. ConsoleMethod(ParticleAssetEmitter, getDataKey, const char*, 3, 3, "(keyIndex) Gets the data-key at the specified index from the field.\n"
  542. "@param keyIndex The index of the data-key to be retrieved.\n"
  543. "@return The data-key comprising both the time and value or nothing if the key is invalid.")
  544. {
  545. // Fetch the key index.
  546. const S32 keyIndex = dAtoi(argv[2]);
  547. // Fetch the data-key.
  548. const ParticleAssetField::DataKey dataKey = object->getParticleFields().getDataKey( keyIndex );
  549. // Finish if the data-key is bad.
  550. if ( dataKey == ParticleAssetField::BadDataKey )
  551. return StringTable->EmptyString;
  552. // Create Returnable Buffer.
  553. char* pBuffer = Con::getReturnBuffer(32);
  554. // Format Buffer.
  555. dSprintf(pBuffer, 32, "%f %f", dataKey.mTime, dataKey.mValue );
  556. // Return buffer.
  557. return pBuffer;
  558. }
  559. //-----------------------------------------------------------------------------
  560. ConsoleMethod(ParticleAssetEmitter, getMinValue, F32, 2, 2, "() Get the minimum value for the field.\n"
  561. "@return The minimum value for the field or always 0.0 if no field is selected." )
  562. {
  563. return object->getParticleFields().getMinValue();
  564. }
  565. //-----------------------------------------------------------------------------
  566. ConsoleMethod(ParticleAssetEmitter, getMaxValue, F32, 2, 2, "() Get the maximum value for the field.\n"
  567. "@return The maximum value for the field or always 0.0 if no field is selected." )
  568. {
  569. return object->getParticleFields().getMaxValue();
  570. }
  571. //-----------------------------------------------------------------------------
  572. ConsoleMethod(ParticleAssetEmitter, getMinTime, F32, 2, 2, "() Get the minimum time for the field.\n"
  573. "@return The minimum time for the field or always 0.0 if no field is selected." )
  574. {
  575. return object->getParticleFields().getMinTime();
  576. }
  577. //-----------------------------------------------------------------------------
  578. ConsoleMethod(ParticleAssetEmitter, getMaxTime, F32, 2, 2, "() Get the maximum time for the field.\n"
  579. "@return The maximum time for the field or always 0.0 if no field is selected." )
  580. {
  581. return object->getParticleFields().getMaxTime();
  582. }
  583. //-----------------------------------------------------------------------------
  584. ConsoleMethod(ParticleAssetEmitter, getFieldValue, F32, 3, 3, "(time) Get the fields' value at the specified time.\n"
  585. "@param time The time to sample the field value at.\n"
  586. "@return The fields' value at the specified time or always 0.0 if no field is selected.")
  587. {
  588. return object->getParticleFields().getFieldValue( dAtof(argv[2]) );
  589. }
  590. //-----------------------------------------------------------------------------
  591. ConsoleMethod(ParticleAssetEmitter, setRepeatTime, bool, 3, 3, "(repeatTime) Sets the time period to repeat (cycle) the fields' values at.\n"
  592. "@return Whether the operation was successful or not.")
  593. {
  594. return object->getParticleFields().setRepeatTime( dAtof(argv[2]) );
  595. }
  596. //-----------------------------------------------------------------------------
  597. ConsoleMethod(ParticleAssetEmitter, getRepeatTime, F32, 2, 2, "() Gets the time period that the fields' value repeat (cycle) at.\n"
  598. "@return The time period that the fields' value repeat (cycle) at.\n" )
  599. {
  600. return object->getParticleFields().getRepeatTime();
  601. }
  602. //-----------------------------------------------------------------------------
  603. 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"
  604. "@param valueScale The scale for field values retrieved from the field.\n"
  605. "@return Whether the operation was successful or not.")
  606. {
  607. return object->getParticleFields().setValueScale( dAtof(argv[2]) );
  608. }
  609. //-----------------------------------------------------------------------------
  610. ConsoleMethod(ParticleAssetEmitter, getValueScale, F32, 2, 2, "() Gets the scaling of field values' retrieved from the field.\n"
  611. "@return The scaling of field values' retrieved from the field." )
  612. {
  613. return object->getParticleFields().getValueScale();
  614. }