ParticleAssetEmitter_ScriptBinding.h 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130
  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. ConsoleMethodGroupBeginWithDocs(ParticleAssetEmitter, SimObject)
  23. //-----------------------------------------------------------------------------
  24. /// Particle emitter accessors.
  25. //-----------------------------------------------------------------------------
  26. /*! Gets the asset owner of the emitter.
  27. @return The asset owner of the emitter or nothing if no owner assigned.
  28. */
  29. ConsoleMethodWithDocs(ParticleAssetEmitter, getOwner, ConsoleString, 2, 2, ())
  30. {
  31. // Fetch the owner.
  32. ParticleAsset* pParticleAsset = object->getOwner();
  33. return pParticleAsset == NULL ? StringTable->EmptyString : pParticleAsset->getIdString();
  34. }
  35. //-----------------------------------------------------------------------------
  36. /*! Sets the name of the emitter.
  37. @param emitterName The name to set the emitter to.
  38. @return No return value.
  39. */
  40. ConsoleMethodWithDocs(ParticleAssetEmitter, setEmitterName, ConsoleVoid, 3, 3, (emitterName))
  41. {
  42. object->setEmitterName( argv[2] );
  43. }
  44. //-----------------------------------------------------------------------------
  45. /*! Gets the name of the emitter.
  46. @return The name of the emitter.
  47. */
  48. ConsoleMethodWithDocs(ParticleAssetEmitter, getEmitterName, ConsoleString, 2, 2, ())
  49. {
  50. return object->getEmitterName();
  51. }
  52. //-----------------------------------------------------------------------------
  53. /*! Sets the type of the emitter.
  54. @param emitterType The type to set the emitter. Either 'POINT', 'LINE', 'BOX' or 'DISK', 'ELLIPSE' or 'TORUS'.
  55. An emitter-type of 'POINT' creates the particles at the position of the particle asset.
  56. An emitter-type of 'LINE' creates the particles along a line defined by the particle width.
  57. An emitter-type of 'BOX' creates the particles within the dimensions defined by the particle size.
  58. An emitter-type of 'DISK' creates the particles within a disk with radii defined by the particle size.
  59. An emitter-type of 'ELLIPSE' creates the particles on an ellipse with the radii defined by the particle size.
  60. 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.
  61. @return No return value.
  62. */
  63. ConsoleMethodWithDocs(ParticleAssetEmitter, setEmitterType, ConsoleVoid, 3, 3, (emitterType))
  64. {
  65. object->setEmitterType( ParticleAssetEmitter::getEmitterTypeEnum(argv[2]) );
  66. }
  67. //-----------------------------------------------------------------------------
  68. /*! Gets the type of the emitter.
  69. @return The type of the emitter.
  70. */
  71. ConsoleMethodWithDocs(ParticleAssetEmitter, getEmitterType, ConsoleString, 2, 2, ())
  72. {
  73. return ParticleAssetEmitter::getEmitterTypeDescription( object->getEmitterType() );
  74. }
  75. //-----------------------------------------------------------------------------
  76. /*! Offsets the position of the emitter relative to the effect or player position.
  77. @return No return value.
  78. */
  79. ConsoleMethodWithDocs(ParticleAssetEmitter, setEmitterOffset, ConsoleVoid, 3, 4, (float X / float Y))
  80. {
  81. // Grab the element count.
  82. U32 elementCount =Utility::mGetStringElementCount(argv[2]);
  83. // ("positionX positionY")
  84. if ( (elementCount == 2) && (argc < 4) )
  85. {
  86. object->setEmitterOffset( Vector2( argv[2] ) );
  87. return;
  88. }
  89. // (positionX, positionY)
  90. if ( (elementCount == 1) && (argc > 3) )
  91. {
  92. object->setEmitterOffset( Vector2( dAtof(argv[2]), dAtof(argv[3]) ) );
  93. return;
  94. }
  95. // Warn.
  96. Con::warnf( "ParticleAssetEmitter::setEmitterOffset() - Invalid number of parameters!" );
  97. }
  98. //------------------------------------------------------------------------------
  99. /*! Gets the emitter offset position.
  100. @return (float x/float y) The offset of the emitter relative to the effect or player position.
  101. */
  102. ConsoleMethodWithDocs(ParticleAssetEmitter, getEmitterOffset, ConsoleString, 2, 2, ())
  103. {
  104. return object->getEmitterOffset().scriptThis();
  105. }
  106. /*! Sets if the emitter targets a point.
  107. @param target The point that the emitter's particles will be drawn to.
  108. @return No return value.
  109. */
  110. ConsoleMethodWithDocs(ParticleAssetEmitter, setIsTargeting, ConsoleVoid, 3, 3, (target))
  111. {
  112. object->setIsTargeting(dAtob(argv[2]));
  113. }
  114. //-----------------------------------------------------------------------------
  115. /*! Gets whether the emitter targets a point.
  116. @return True if the emitter uses a target for particles.
  117. */
  118. ConsoleMethodWithDocs(ParticleAssetEmitter, getIsTargeting, ConsoleBool, 2, 2, ())
  119. {
  120. return object->getIsTargeting();
  121. }
  122. /* Sets the world point that the emitter will target. Targeting must be turned on with setIsTargeting().
  123. @param Position The world point that will be the target.
  124. @return No return value.
  125. */
  126. ConsoleMethodWithDocs(ParticleAssetEmitter, setTargetPosition, ConsoleVoid, 3, 4, (float X / float Y))
  127. {
  128. // Grab the element count.
  129. U32 elementCount = Utility::mGetStringElementCount(argv[2]);
  130. // ("positionX positionY")
  131. if ((elementCount == 2) && (argc < 4))
  132. {
  133. object->setTargetPosition(Vector2(argv[2]));
  134. return;
  135. }
  136. // (positionX, positionY)
  137. if ((elementCount == 1) && (argc > 3))
  138. {
  139. object->setTargetPosition(Vector2(dAtof(argv[2]), dAtof(argv[3])));
  140. return;
  141. }
  142. // Warn.
  143. Con::warnf("ParticleAssetEmitter::setTargetPosition() - Invalid number of parameters!");
  144. }
  145. //------------------------------------------------------------------------------
  146. /*! Gets the emitter target position.
  147. @return (float x/float y) The position of the target of the emitter.
  148. */
  149. ConsoleMethodWithDocs(ParticleAssetEmitter, getTargetPosition, ConsoleString, 2, 2, ())
  150. {
  151. return object->getTargetPosition().scriptThis();
  152. }
  153. //------------------------------------------------------------------------------
  154. /*! Sets the emitter size.
  155. @param width The width of the emitter.
  156. @param height The height of the emitter.
  157. @return No return value.
  158. */
  159. ConsoleMethodWithDocs(ParticleAssetEmitter, setEmitterSize, ConsoleVoid, 3, 4, (width / height))
  160. {
  161. F32 width, height;
  162. const U32 elementCount = Utility::mGetStringElementCount(argv[2]);
  163. // ("width height")
  164. if ((elementCount == 2) && (argc == 3))
  165. {
  166. width = dAtof(Utility::mGetStringElement(argv[2], 0));
  167. height = dAtof(Utility::mGetStringElement(argv[2], 1));
  168. }
  169. // (width, [height])
  170. else if (elementCount == 1)
  171. {
  172. width = dAtof(argv[2]);
  173. if (argc > 3)
  174. height = dAtof(argv[3]);
  175. else
  176. height = width;
  177. }
  178. // Invalid
  179. else
  180. {
  181. Con::warnf("ParticleAssetEmitter::setEmitterSize() - Invalid number of parameters!");
  182. return;
  183. }
  184. // Set Size.
  185. object->setEmitterSize(Vector2(width, height));
  186. }
  187. //------------------------------------------------------------------------------
  188. /*! Gets the emitter size.
  189. @return (float width/float height) The width and height of the emitter.
  190. */
  191. ConsoleMethodWithDocs(ParticleAssetEmitter, getEmitterSize, ConsoleString, 2, 2, ())
  192. {
  193. return object->getEmitterSize().scriptThis();
  194. }
  195. //------------------------------------------------------------------------------
  196. /*! Sets the emitter angle.
  197. @param angle The angle of the emitter.
  198. @return No return value.
  199. */
  200. ConsoleMethodWithDocs(ParticleAssetEmitter, setEmitterAngle, ConsoleVoid, 3, 3, (angle))
  201. {
  202. // Set Rotation.
  203. object->setEmitterAngle( mDegToRad( dAtof(argv[2]) ) );
  204. }
  205. //-----------------------------------------------------------------------------
  206. /*! Gets the emitter angle.
  207. @return (float angle) The emitter's current angle.
  208. */
  209. ConsoleMethodWithDocs(ParticleAssetEmitter, getEmitterAngle, ConsoleFloat, 2, 2, ())
  210. {
  211. // Return angle.
  212. return mRadToDeg( object->getEmitterAngle());
  213. }
  214. //-----------------------------------------------------------------------------
  215. /*! Sets the emitter to used a fixed-aspect for particles.
  216. @param fixedAspect Whether to use a fixed-aspect or not.
  217. @return No return value.
  218. */
  219. ConsoleMethodWithDocs(ParticleAssetEmitter, setFixedAspect, ConsoleVoid, 3, 3, (fixedAspect))
  220. {
  221. object->setFixedAspect( dAtob(argv[2]) );
  222. }
  223. //-----------------------------------------------------------------------------
  224. /*! Gets whether the emitter uses a fixed-aspect for particles or not.
  225. @return Whether the emitter uses a fixed-aspect for particles or not.
  226. */
  227. ConsoleMethodWithDocs(ParticleAssetEmitter, getFixedAspect, ConsoleBool, 2, 2, ())
  228. {
  229. return object->getFixedAspect();
  230. }
  231. //-----------------------------------------------------------------------------
  232. /*! Sets the emitter fixed-force angle for particles.
  233. @param fixedForceAngle The fixed-force angle for particles.
  234. @return No return value.
  235. */
  236. ConsoleMethodWithDocs(ParticleAssetEmitter, setFixedForceAngle, ConsoleVoid, 3, 3, (fixedForceAngle))
  237. {
  238. object->setFixedForceAngle( dAtof(argv[2]) );
  239. }
  240. //-----------------------------------------------------------------------------
  241. /*! Gets the emitter fixed-force angle for particles.
  242. @return The fixed-force angle for particles.
  243. */
  244. ConsoleMethodWithDocs(ParticleAssetEmitter, getFixedForceAngle, ConsoleFloat, 2, 2, ())
  245. {
  246. return object->getFixedForceAngle();
  247. }
  248. //-----------------------------------------------------------------------------
  249. /*! Sets the orientation-type of the emitter.
  250. @param orientationType The orientation-type to set the emitter to. Either 'FIXED', 'ALIGNED' or 'RANDOM'.
  251. An orientation-type of 'FIXED' causes the particles to be orientation at a fixed angle.
  252. An orientation-type of 'ALIGNED' causes the particles to be orientation at the current emission angle.
  253. An orientation-type of 'RANDOM' causes the particles to be orientation at a fixed angle.
  254. @return No return value.
  255. */
  256. ConsoleMethodWithDocs(ParticleAssetEmitter, setOrientationType, ConsoleVoid, 3, 3, (orientationType))
  257. {
  258. object->setOrientationType( ParticleAssetEmitter::getOrientationTypeEnum(argv[2]) );
  259. }
  260. //-----------------------------------------------------------------------------
  261. /*! Gets the orientation-type of the emitter.
  262. @return The orientation-type of the emitter.
  263. */
  264. ConsoleMethodWithDocs(ParticleAssetEmitter, getOrientationType, ConsoleString, 2, 2, ())
  265. {
  266. return ParticleAssetEmitter::getOrientationTypeDescription( object->getOrientationType() );
  267. }
  268. //------------------------------------------------------------------------------
  269. /*! Sets whether to keep emitted particles aligned or not.
  270. @keepAligned Whether to keep emitted particles aligned or not.
  271. @return No return value.
  272. */
  273. ConsoleMethodWithDocs(ParticleAssetEmitter, setKeepAligned, ConsoleVoid, 3, 3, (keepAligned))
  274. {
  275. object->setKeepAligned( dAtob(argv[2]) );
  276. }
  277. //------------------------------------------------------------------------------
  278. /*! Gets whether to keep emitted particles aligned or not.
  279. @return Whether to keep emitted particles aligned or not.
  280. */
  281. ConsoleMethodWithDocs(ParticleAssetEmitter, getKeepAligned, ConsoleBool, 2, 2, ())
  282. {
  283. return object->getKeepAligned();
  284. }
  285. //------------------------------------------------------------------------------
  286. /*! Sets the aligned angle offset.
  287. @param alignAngleOffset The aligned angle offset.
  288. @return No return value.
  289. */
  290. ConsoleMethodWithDocs(ParticleAssetEmitter, setAlignedAngleOffset, ConsoleVoid, 3, 3, (alignAngleOffset))
  291. {
  292. object->setAlignedAngleOffset( dAtof(argv[2]) );
  293. }
  294. //------------------------------------------------------------------------------
  295. /*! Gets the aligned angle offset.
  296. @return The aligned angle offset.
  297. */
  298. ConsoleMethodWithDocs(ParticleAssetEmitter, getAlignedAngleOffset, ConsoleFloat, 2, 2, ())
  299. {
  300. return object->getAlignedAngleOffset();
  301. }
  302. //------------------------------------------------------------------------------
  303. /*! Set Random-Orientation Angle-Offset.
  304. */
  305. ConsoleMethodWithDocs(ParticleAssetEmitter, setRandomAngleOffset, ConsoleVoid, 3, 3, (randomAngle))
  306. {
  307. object->setRandomAngleOffset( dAtof(argv[2]) );
  308. }
  309. //------------------------------------------------------------------------------
  310. /*! Get Random-Orientation Angle-Offset.
  311. */
  312. ConsoleMethodWithDocs(ParticleAssetEmitter, getRandomAngleOffset, ConsoleFloat, 2, 2, ())
  313. {
  314. return object->getRandomAngleOffset();
  315. }
  316. //------------------------------------------------------------------------------
  317. /*! Set Random-Orientation Arc.
  318. */
  319. ConsoleMethodWithDocs(ParticleAssetEmitter, setRandomArc, ConsoleVoid, 3, 3, (randomArc))
  320. {
  321. object->setRandomArc( dAtof(argv[2]) );
  322. }
  323. //------------------------------------------------------------------------------
  324. /*! Get Random-Orientation Arc.
  325. */
  326. ConsoleMethodWithDocs(ParticleAssetEmitter, getRandomArc, ConsoleFloat, 2, 2, ())
  327. {
  328. return object->getRandomArc();
  329. }
  330. //------------------------------------------------------------------------------
  331. /*! Set Fixed-Orientation Angle-Offset.
  332. */
  333. ConsoleMethodWithDocs(ParticleAssetEmitter, setFixedAngleOffset, ConsoleVoid, 3, 3, (randomAngle))
  334. {
  335. object->setFixedAngleOffset( dAtof(argv[2]) );
  336. }
  337. //------------------------------------------------------------------------------
  338. /*! Get Fixed-Orientation Angle-Offset.
  339. */
  340. ConsoleMethodWithDocs(ParticleAssetEmitter, getFixedAngleOffset, ConsoleFloat, 2, 2, ())
  341. {
  342. return object->getFixedAngleOffset();
  343. }
  344. //------------------------------------------------------------------------------
  345. /*! Set the Pivot-Point.
  346. */
  347. ConsoleMethodWithDocs(ParticleAssetEmitter, setPivotPoint, ConsoleVoid, 3, 4, (pivotX / pivotY))
  348. {
  349. // Grab the element count.
  350. U32 elementCount =Utility::mGetStringElementCount(argv[2]);
  351. // ("pivotX pivotY")
  352. if ( (elementCount == 2) && (argc < 4) )
  353. {
  354. object->setPivotPoint( Vector2( argv[2] ) );
  355. return;
  356. }
  357. // (pivotX, pivotY)
  358. if ( (elementCount == 1) && (argc > 3) )
  359. {
  360. object->setPivotPoint( Vector2( dAtof(argv[2]), dAtof(argv[3]) ) );
  361. return;
  362. }
  363. // Warn.
  364. Con::warnf( "ParticleAssetEmitter::setPivotPoint() - Invalid number of parameters!" );
  365. }
  366. //------------------------------------------------------------------------------
  367. /*! Get Pivot-Point.
  368. */
  369. ConsoleMethodWithDocs(ParticleAssetEmitter, getPivotPoint, ConsoleString, 2, 2, ())
  370. {
  371. return object->getPivotPoint().scriptThis();
  372. }
  373. //------------------------------------------------------------------------------
  374. /*! Set Link-Emission-Rotation Flag.
  375. */
  376. ConsoleMethodWithDocs(ParticleAssetEmitter, setLinkEmissionRotation, ConsoleVoid, 3, 3, (linkEmissionRotation))
  377. {
  378. object->setLinkEmissionRotation( dAtob(argv[2]) );
  379. }
  380. //------------------------------------------------------------------------------
  381. /*! Get Link-Emission-Rotation Flag.
  382. */
  383. ConsoleMethodWithDocs(ParticleAssetEmitter, getLinkEmissionRotation, ConsoleBool, 2, 2, ())
  384. {
  385. return object->getLinkEmissionRotation();
  386. }
  387. //------------------------------------------------------------------------------
  388. /*! Set Intense-Particles Flag.
  389. */
  390. ConsoleMethodWithDocs(ParticleAssetEmitter, setIntenseParticles, ConsoleVoid, 3, 3, (intenseParticles))
  391. {
  392. object->setIntenseParticles( dAtob(argv[2]) );
  393. }
  394. //------------------------------------------------------------------------------
  395. /*! Get Intense-Particles Flag.
  396. */
  397. ConsoleMethodWithDocs(ParticleAssetEmitter, getIntenseParticles, ConsoleBool, 2, 2, ())
  398. {
  399. return object->getIntenseParticles();
  400. }
  401. //------------------------------------------------------------------------------
  402. /*! Set Single-Particle Flag.
  403. */
  404. ConsoleMethodWithDocs(ParticleAssetEmitter, setSingleParticle, ConsoleVoid, 3, 3, (singleParticle))
  405. {
  406. // Set Single Particle.
  407. object->setSingleParticle( dAtob(argv[2]) );
  408. }
  409. //------------------------------------------------------------------------------
  410. /*! Get Single-Particle Flag.
  411. */
  412. ConsoleMethodWithDocs(ParticleAssetEmitter, getSingleParticle, ConsoleBool, 2, 2, ())
  413. {
  414. return object->getSingleParticle();
  415. }
  416. //------------------------------------------------------------------------------
  417. /*! Set Attach-Position-To-Emitter Flag.
  418. */
  419. ConsoleMethodWithDocs(ParticleAssetEmitter, setAttachPositionToEmitter, ConsoleVoid, 3, 3, (attachPositionToEmitter))
  420. {
  421. object->setAttachPositionToEmitter( dAtob(argv[2]) );
  422. }
  423. //------------------------------------------------------------------------------
  424. /*! Get Attach-Position-To-Emitter Flag.
  425. */
  426. ConsoleMethodWithDocs(ParticleAssetEmitter, getAttachPositionToEmitter, ConsoleBool, 2, 2, ())
  427. {
  428. return object->getAttachPositionToEmitter();
  429. }
  430. //------------------------------------------------------------------------------
  431. /*! Set Attach-Rotation-To-Emitter Flag.
  432. */
  433. ConsoleMethodWithDocs(ParticleAssetEmitter, setAttachRotationToEmitter, ConsoleVoid, 3, 3, (attachRotationToEmitter))
  434. {
  435. object->setAttachRotationToEmitter( dAtob(argv[2]) );
  436. }
  437. //------------------------------------------------------------------------------
  438. /*! Get Attach-Rotation-To-Emitter Flag.
  439. */
  440. ConsoleMethodWithDocs(ParticleAssetEmitter, getAttachRotationToEmitter, ConsoleBool, 2, 2, ())
  441. {
  442. return object->getAttachRotationToEmitter();
  443. }
  444. //------------------------------------------------------------------------------
  445. /*! Sets whether to render particles as oldest on front or not.
  446. @param oldestInFront Whether to render particles as oldest on front or not.
  447. @return No return value.
  448. */
  449. ConsoleMethodWithDocs(ParticleAssetEmitter, setOldestInFront, ConsoleVoid, 3, 3, (oldestInFront))
  450. {
  451. object->setOldestInFront( dAtob(argv[2]) );
  452. }
  453. //------------------------------------------------------------------------------
  454. /*! Gets whether to render particles as oldest on front or not.
  455. @return Whether to render particles as oldest on front or not.
  456. */
  457. ConsoleMethodWithDocs(ParticleAssetEmitter, getOldestInFront, ConsoleBool, 2, 2, ())
  458. {
  459. return object->getOldestInFront();
  460. }
  461. //------------------------------------------------------------------------------
  462. /*! Sets the emitter to use the specified image asset Id and optional frame.
  463. @param imageAssetId The image asset Id to use.
  464. @param frame The frame of the image asset Id to use. Optional.
  465. @return Whether the operation was successful or not.
  466. */
  467. ConsoleMethodWithDocs(ParticleAssetEmitter, setImage, ConsoleBool, 3, 4, (imageAssetId, [frame]))
  468. {
  469. // Was a frame specified?
  470. if (argc >= 4)
  471. {
  472. // Was it a number or a string?
  473. if (!dIsalpha(*argv[3]))
  474. {
  475. // Fetch the numerical frame and set the image
  476. const U32 frame = argc >= 4 ? dAtoi(argv[3]) : 0;
  477. return object->setImage(argv[2], frame);
  478. }
  479. else
  480. {
  481. // Set the image and pass the named frame string
  482. return object->setImage(argv[2], argv[3]);
  483. }
  484. }
  485. else
  486. {
  487. // Frame was not specified, use default 0 and set the image
  488. const U32 frame = 0;
  489. return object->setImage( argv[2], frame);
  490. }
  491. }
  492. //------------------------------------------------------------------------------
  493. /*! Gets the asset Id of the image asset assigned to the emitter.
  494. @return The asset Id of the image asset assigned to the emitter or nothing if no image is assigned.
  495. */
  496. ConsoleMethodWithDocs(ParticleAssetEmitter, getImage, ConsoleString, 2, 2, ())
  497. {
  498. return object->getImage();
  499. }
  500. //------------------------------------------------------------------------------
  501. /*! Sets the emitter to use the specified numerical image frame.
  502. @param frame The frame index of the image to use..
  503. @return Whether the operation was successful or not.
  504. */
  505. ConsoleMethodWithDocs(ParticleAssetEmitter, setImageFrame, ConsoleBool, 3, 3, (frame))
  506. {
  507. // Are we in static mode?
  508. if ( !object->isStaticFrameProvider() )
  509. {
  510. // No, so warn.
  511. Con::warnf( "ParticleAssetEmitter::setImageFrame() - Method invalid, not in static mode." );
  512. return false;
  513. }
  514. // Are we using named frames?
  515. if ( object->isUsingNamedImageFrame() )
  516. {
  517. // Yes, so warn.
  518. Con::warnf( "ParticleAssetEmitter::setImageFrame() - Method invalid, using named frames." );
  519. return false;
  520. }
  521. return object->setImageFrame( dAtoi(argv[2]) );
  522. }
  523. //------------------------------------------------------------------------------
  524. /*! Gets the frame index of the image asset assigned to the emitter.
  525. @return The frame index of the image asset assigned to the emitter or nothing if no image is assigned.
  526. */
  527. ConsoleMethodWithDocs(ParticleAssetEmitter, getImageFrame, ConsoleInt, 2, 2, ())
  528. {
  529. // Are we in static mode?
  530. if ( !object->isStaticFrameProvider() )
  531. {
  532. // No, so warn.
  533. Con::warnf( "ParticleAssetEmitter::getImageFrame() - Method invalid, not in static mode." );
  534. return -1;
  535. }
  536. // Are we using named frames?
  537. if ( object->isUsingNamedImageFrame() )
  538. {
  539. // Yes, so warn.
  540. Con::warnf( "ParticleAssetEmitter::getImageFrame() - Method invalid, using named frames." );
  541. return -1;
  542. }
  543. return object->getImageFrame();
  544. }
  545. //------------------------------------------------------------------------------
  546. /*! Disables the Frame and NamedFrame fields and uses a random frame from the specified ImageAsset.
  547. @param randomImageFrame Whether to use a random image frame or not.
  548. @return No return value.
  549. */
  550. ConsoleMethodWithDocs(ParticleAssetEmitter, setRandomImageFrame, ConsoleVoid, 3, 3, (randomImageFrame))
  551. {
  552. object->setRandomImageFrame( dAtob(argv[2]) );
  553. }
  554. //------------------------------------------------------------------------------
  555. /*! Gets whether a random frame from the specified ImageAsset is being used or not.
  556. @return Whether to use a random image frame or not.
  557. */
  558. ConsoleMethodWithDocs(ParticleAssetEmitter, getRandomImageFrame, ConsoleBool, 2, 2, ())
  559. {
  560. return object->getRandomImageFrame();
  561. }
  562. //------------------------------------------------------------------------------
  563. /*! Sets the emitter to use the specified image frame by name.
  564. @param frame String containing the name of the frame in the image to use.
  565. @return Whether the operation was successful or not.
  566. */
  567. ConsoleMethodWithDocs(ParticleAssetEmitter, setNamedImageFrame, ConsoleBool, 3, 3, (frame))
  568. {
  569. // Are we in static mode?
  570. if ( !object->isStaticFrameProvider() )
  571. {
  572. // No, so warn.
  573. Con::warnf( "ParticleAssetEmitter::setNamedImageFrame() - Method invalid, not in static mode." );
  574. return false;
  575. }
  576. // Are we using named frames?
  577. if ( !object->isUsingNamedImageFrame() )
  578. {
  579. // No, so warn.
  580. Con::warnf( "ParticleAssetEmitter::setNamedImageFrame() - Method invalid, not using named frames." );
  581. return false;
  582. }
  583. return object->setNamedImageFrame( argv[2] );
  584. }
  585. //------------------------------------------------------------------------------
  586. /*! Gets the asset Id of the image asset assigned to the emitter.
  587. @return The asset Id of the image asset assigned to the emitter or nothing if no image is assigned.
  588. */
  589. ConsoleMethodWithDocs(ParticleAssetEmitter, getNamedImageFrame, ConsoleString, 2, 2, ())
  590. {
  591. // Are we in static mode?
  592. if ( !object->isStaticFrameProvider() )
  593. {
  594. // No, so warn.
  595. Con::warnf( "ParticleAssetEmitter::getNamedImageFrame() - Method invalid, not in static mode." );
  596. return NULL;
  597. }
  598. // Are we using named frames?
  599. if ( !object->isUsingNamedImageFrame() )
  600. {
  601. // No, so warn.
  602. Con::warnf( "ParticleAssetEmitter::getNamedImageFrame() - Method invalid, not using named frames." );
  603. return NULL;
  604. }
  605. return object->getNamedImageFrame();
  606. }
  607. //------------------------------------------------------------------------------
  608. /*! Gets whether the emitter is using a numerical or named image frame.
  609. @return Returns true when using a named frame, false when using a numerical index.
  610. */
  611. ConsoleMethodWithDocs(ParticleAssetEmitter, isUsingNamedImageFrame, ConsoleBool, 2, 2, ())
  612. {
  613. return object->isUsingNamedImageFrame();
  614. }
  615. //------------------------------------------------------------------------------
  616. /*! Sets the emitter to use the specified animation asset Id.
  617. @param animationAssetId The animation asset Id to use.
  618. @return Whether the operation was successful or not.
  619. */
  620. ConsoleMethodWithDocs(ParticleAssetEmitter, setAnimation, ConsoleBool, 3, 3, (animationAssetId))
  621. {
  622. return object->setAnimation( argv[2] );
  623. }
  624. //------------------------------------------------------------------------------
  625. /*! Gets the asset Id of the animation asset assigned to the emitter.
  626. @return The asset Id of the animation asset assigned to the emitter or nothing if no animation is assigned.
  627. */
  628. ConsoleMethodWithDocs(ParticleAssetEmitter, getAnimation, ConsoleString, 2, 2, ())
  629. {
  630. return object->getAnimation();
  631. }
  632. //------------------------------------------------------------------------------
  633. /*! Sets whether to use render blending or not.
  634. @param blendMode Whether to use render blending or not.
  635. @return No return value.
  636. */
  637. ConsoleMethodWithDocs(ParticleAssetEmitter, setBlendMode, ConsoleVoid, 3, 3, (blendMode))
  638. {
  639. object->setBlendMode( dAtob(argv[2]) );
  640. }
  641. //------------------------------------------------------------------------------
  642. /*! Gets whether to use render blending or not.
  643. @return Whether to use render blending or not.
  644. */
  645. ConsoleMethodWithDocs(ParticleAssetEmitter, getBlendMode, ConsoleBool, 2, 2, ())
  646. {
  647. return object->getBlendMode();
  648. }
  649. //-----------------------------------------------------------------------------
  650. /*! Sets the source blend factory.
  651. @param srcBlend The source blend factor.
  652. @return No return Value.
  653. */
  654. ConsoleMethodWithDocs(ParticleAssetEmitter, setSrcBlendFactor, ConsoleVoid, 3, 3, (srcBlend))
  655. {
  656. // Fetch source blend factor.
  657. const GLenum blendFactor = SceneObject::getSrcBlendFactorEnum(argv[2]);
  658. object->setSrcBlendFactor( blendFactor );
  659. }
  660. //-----------------------------------------------------------------------------
  661. /*! Gets the source render blend factor.
  662. @return (srcBlend) The source render blend factor.
  663. */
  664. ConsoleMethodWithDocs(ParticleAssetEmitter, getSrcBlendFactor, ConsoleString, 2, 2, ())
  665. {
  666. return SceneObject::getSrcBlendFactorDescription(object->getSrcBlendFactor());
  667. }
  668. //-----------------------------------------------------------------------------
  669. /*! Sets the destination render blend factor.
  670. @param dstBlend The destination render blend factor.
  671. @return No return Value.
  672. */
  673. ConsoleMethodWithDocs(ParticleAssetEmitter, setDstBlendFactor, ConsoleVoid, 3, 3, (dstBlend))
  674. {
  675. // Fetch destination blend factor.
  676. const GLenum blendFactor = SceneObject::getDstBlendFactorEnum(argv[2]);
  677. object->setDstBlendFactor( blendFactor );
  678. }
  679. //-----------------------------------------------------------------------------
  680. /*! Gets the destination render blend factor.
  681. @return (dstBlend) The destination render blend factor.
  682. */
  683. ConsoleMethodWithDocs(ParticleAssetEmitter, getDstBlendFactor, ConsoleString, 2, 2, ())
  684. {
  685. return SceneObject::getDstBlendFactorDescription(object->getDstBlendFactor());
  686. }
  687. //-----------------------------------------------------------------------------
  688. /*! Set the render alpha test threshold.
  689. @param alpha The alpha test threshold in the range of 0.0 to 1.0. Less than zero to disable alpha testing.
  690. @return No return value.
  691. */
  692. ConsoleMethodWithDocs(ParticleAssetEmitter, setAlphaTest, ConsoleVoid, 3, 3, (float alpha))
  693. {
  694. object->setAlphaTest(dAtof(argv[2]));
  695. }
  696. //-----------------------------------------------------------------------------
  697. /*! Gets the render alpha test threshold.
  698. @return The render alpha test threshold in the range of 0.0f to 1.0. Less than zero represents disabled alpha testing.
  699. */
  700. ConsoleMethodWithDocs(ParticleAssetEmitter, getAlphaTest, ConsoleFloat, 2, 2, ())
  701. {
  702. return object->getAlphaTest();
  703. }
  704. //-----------------------------------------------------------------------------
  705. /// Particle emitter fields.
  706. //-----------------------------------------------------------------------------
  707. /*! Gets the number of available selectable fields.
  708. @return The number of available selectable fields.
  709. */
  710. ConsoleMethodWithDocs(ParticleAssetEmitter, getSelectableFieldCount, ConsoleInt, 2, 2, ())
  711. {
  712. return object->getParticleFields().getFields().size();
  713. }
  714. //-----------------------------------------------------------------------------
  715. /*! Gets the selectable field at the specified index.
  716. @return The selectable field name at the specified index.
  717. */
  718. ConsoleMethodWithDocs(ParticleAssetEmitter, getSelectableFieldName, ConsoleString, 3, 3, (fieldIndex))
  719. {
  720. // Fetch the field hash.
  721. const ParticleAssetFieldCollection::typeFieldHash& fieldHash = object->getParticleFields().getFields();
  722. // Fetch the index.
  723. S32 fieldIndex = dAtoi( argv[2] );
  724. // Is the field index valid?
  725. if ( fieldIndex >= 0 && fieldIndex < (S32)fieldHash.size() )
  726. {
  727. // Yes, but because the fields are in a hash-table, we'll have to iterate and get O(index).
  728. for( ParticleAssetFieldCollection::typeFieldHash::const_iterator fieldItr = fieldHash.begin(); fieldItr != fieldHash.end(); ++fieldItr, --fieldIndex )
  729. {
  730. // Skip if this is not the field index we're looking for?
  731. if ( fieldIndex != 0 )
  732. continue;
  733. // Found it so return the field name.
  734. return fieldItr->value->getFieldName();
  735. }
  736. }
  737. // Warn.
  738. Con::warnf( "ParticleAssetEmitter::getSelectableFieldName() - Index '%d' is out of range.", fieldIndex );
  739. return StringTable->EmptyString;
  740. }
  741. //-----------------------------------------------------------------------------
  742. /*! Select the specified field by its name.
  743. @param fieldName The field name to use for the selection. Use an empty name to deselect to stop accidental changes.
  744. @return Whether the field was successfully selected or not.
  745. */
  746. ConsoleMethodWithDocs(ParticleAssetEmitter, selectField, ConsoleBool, 3, 3, (fieldName))
  747. {
  748. return object->getParticleFields().selectField( argv[2] ) != NULL;
  749. }
  750. //-----------------------------------------------------------------------------
  751. /*! Deselect any selected field. If no field is selected then nothing happens.
  752. @return No return value.
  753. */
  754. ConsoleMethodWithDocs(ParticleAssetEmitter, deselectField, ConsoleVoid, 2, 2, ())
  755. {
  756. object->getParticleFields().deselectField();
  757. }
  758. //-----------------------------------------------------------------------------
  759. /*! Gets the selected field name or nothing if no field is selected.
  760. @return The selected field name or nothing if no fields is selected.
  761. */
  762. ConsoleMethodWithDocs(ParticleAssetEmitter, getSelectedField, ConsoleBool, 2, 2, ())
  763. {
  764. // Get the selected field.
  765. const ParticleAssetField* pParticleAssetField = object->getParticleFields().getSelectedField();
  766. return pParticleAssetField == NULL ? StringTable->EmptyString : pParticleAssetField->getFieldName();
  767. }
  768. //-----------------------------------------------------------------------------
  769. /*! Sets a single data-key at time-zero with the specified value. All existing keys are cleared.
  770. @param value The value to set the key to.
  771. @return Returns the index of the new data-key (always zero) or -1 on failure.
  772. */
  773. ConsoleMethodWithDocs(ParticleAssetEmitter, setSingleDataKey, ConsoleInt, 3, 3, (value))
  774. {
  775. return object->getParticleFields().setSingleDataKey( dAtof(argv[2]) );
  776. }
  777. //-----------------------------------------------------------------------------
  778. /*! Add Data-Key to Graph.
  779. @param time The key time.
  780. @param value The value at specified time
  781. @return Returns the index of the new data-key or -1 on failure.
  782. */
  783. ConsoleMethodWithDocs(ParticleAssetEmitter, addDataKey, ConsoleInt, 4, 4, (time, value))
  784. {
  785. return object->getParticleFields().addDataKey( dAtof(argv[2]), dAtof(argv[3]) );
  786. }
  787. //-----------------------------------------------------------------------------
  788. /*! Remove the data-key from the field.
  789. @param keyIndex The index of the data-key you want to remove.
  790. @return Whether the operation was successful or not.
  791. */
  792. ConsoleMethodWithDocs(ParticleAssetEmitter, removeDataKey, ConsoleBool, 3, 3, (keyIndex))
  793. {
  794. return object->getParticleFields().removeDataKey( dAtoi(argv[2]) );
  795. }
  796. //-----------------------------------------------------------------------------
  797. /*! Clears all data-key(s) from the field.
  798. @return Whether the operation was successful or not.
  799. */
  800. ConsoleMethodWithDocs(ParticleAssetEmitter, clearDataKeys, ConsoleBool, 2, 2, ())
  801. {
  802. return object->getParticleFields().clearDataKeys();
  803. }
  804. //-----------------------------------------------------------------------------
  805. /*! Set data-key value for the field.
  806. @param keyIndex The index of the key to be modified.
  807. @param value The value to change the key to.
  808. @return Whether the operation was successful or not.
  809. */
  810. ConsoleMethodWithDocs(ParticleAssetEmitter, setDataKeyValue, ConsoleBool, 4, 4, (keyIndex, value))
  811. {
  812. // Set Data Key.
  813. return object->getParticleFields().setDataKey( dAtoi(argv[2]), dAtof(argv[3]) );
  814. }
  815. //-----------------------------------------------------------------------------
  816. /*! Gets the data-key count.
  817. @return The number of data-keys in the currently selected field or -1 if no field is selected.
  818. */
  819. ConsoleMethodWithDocs(ParticleAssetEmitter, getDataKeyCount, ConsoleInt, 2, 2, ())
  820. {
  821. // Get Data Key Count.
  822. return object->getParticleFields().getDataKeyCount();
  823. }
  824. //-----------------------------------------------------------------------------
  825. /*! Gets the data-key at the specified index from the field.
  826. @param keyIndex The index of the data-key to be retrieved.
  827. @return The data-key comprising both the time and value or nothing if the key is invalid.
  828. */
  829. ConsoleMethodWithDocs(ParticleAssetEmitter, getDataKey, ConsoleString, 3, 3, (keyIndex))
  830. {
  831. // Fetch the key index.
  832. const S32 keyIndex = dAtoi(argv[2]);
  833. // Fetch the data-key.
  834. const ParticleAssetField::DataKey dataKey = object->getParticleFields().getDataKey( keyIndex );
  835. // Finish if the data-key is bad.
  836. if ( dataKey == ParticleAssetField::BadDataKey )
  837. return StringTable->EmptyString;
  838. // Create Returnable Buffer.
  839. char* pBuffer = Con::getReturnBuffer(32);
  840. // Format Buffer.
  841. dSprintf(pBuffer, 32, "%f %f", dataKey.mTime, dataKey.mValue );
  842. // Return buffer.
  843. return pBuffer;
  844. }
  845. //-----------------------------------------------------------------------------
  846. /*! Get the minimum value for the field.
  847. @return The minimum value for the field or always 0.0 if no field is selected.
  848. */
  849. ConsoleMethodWithDocs(ParticleAssetEmitter, getMinValue, ConsoleFloat, 2, 2, ())
  850. {
  851. return object->getParticleFields().getMinValue();
  852. }
  853. //-----------------------------------------------------------------------------
  854. /*! Get the maximum value for the field.
  855. @return The maximum value for the field or always 0.0 if no field is selected.
  856. */
  857. ConsoleMethodWithDocs(ParticleAssetEmitter, getMaxValue, ConsoleFloat, 2, 2, ())
  858. {
  859. return object->getParticleFields().getMaxValue();
  860. }
  861. //-----------------------------------------------------------------------------
  862. /*! Get the minimum time for the field.
  863. @return The minimum time for the field or always 0.0 if no field is selected.
  864. */
  865. ConsoleMethodWithDocs(ParticleAssetEmitter, getMinTime, ConsoleFloat, 2, 2, ())
  866. {
  867. return object->getParticleFields().getMinTime();
  868. }
  869. //-----------------------------------------------------------------------------
  870. /*! Get the maximum time for the field.
  871. @return The maximum time for the field or always 0.0 if no field is selected.
  872. */
  873. ConsoleMethodWithDocs(ParticleAssetEmitter, getMaxTime, ConsoleFloat, 2, 2, ())
  874. {
  875. return object->getParticleFields().getMaxTime();
  876. }
  877. //-----------------------------------------------------------------------------
  878. /*! Get the fields' value at the specified time.
  879. @param time The time to sample the field value at.
  880. @return The fields' value at the specified time or always 0.0 if no field is selected.
  881. */
  882. ConsoleMethodWithDocs(ParticleAssetEmitter, getFieldValue, ConsoleFloat, 3, 3, (time))
  883. {
  884. return object->getParticleFields().getFieldValue( dAtof(argv[2]) );
  885. }
  886. //-----------------------------------------------------------------------------
  887. /*! Sets the time period to repeat (cycle) the fields' values at.
  888. @return Whether the operation was successful or not.
  889. */
  890. ConsoleMethodWithDocs(ParticleAssetEmitter, setRepeatTime, ConsoleBool, 3, 3, (repeatTime))
  891. {
  892. return object->getParticleFields().setRepeatTime( dAtof(argv[2]) );
  893. }
  894. //-----------------------------------------------------------------------------
  895. /*! Gets the time period that the fields' value repeat (cycle) at.
  896. @return The time period that the fields' value repeat (cycle) at.
  897. */
  898. ConsoleMethodWithDocs(ParticleAssetEmitter, getRepeatTime, ConsoleFloat, 2, 2, ())
  899. {
  900. return object->getParticleFields().getRepeatTime();
  901. }
  902. //-----------------------------------------------------------------------------
  903. /*! Set the scaling of field values retrieved from the field. This does not alter the actual data-key values.
  904. @param valueScale The scale for field values retrieved from the field.
  905. @return Whether the operation was successful or not.
  906. */
  907. ConsoleMethodWithDocs(ParticleAssetEmitter, setValueScale, ConsoleBool, 3, 3, (valueScale))
  908. {
  909. return object->getParticleFields().setValueScale( dAtof(argv[2]) );
  910. }
  911. //-----------------------------------------------------------------------------
  912. /*! Gets the scaling of field values' retrieved from the field.
  913. @return The scaling of field values' retrieved from the field.
  914. */
  915. ConsoleMethodWithDocs(ParticleAssetEmitter, getValueScale, ConsoleFloat, 2, 2, ())
  916. {
  917. return object->getParticleFields().getValueScale();
  918. }
  919. ConsoleMethodGroupEndWithDocs(ParticleAssetEmitter)