ParticleAssetEmitter_ScriptBinding.h 38 KB

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