home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 22 / PC Actual CD 22.iso / SHARE / prog / POVRAY / EXPLODE.ZIP / EXPLODE.TXT < prev    next >
Encoding:
Text File  |  1997-03-10  |  19.7 KB  |  452 lines

  1. **************************************************************************
  2. **************************************************************************
  3.         OBJECT EXPLODER INCLUDE FILE FOR PERSISTENCE OF VISION 3.x
  4. **************************************************************************
  5. **************************************************************************
  6.  
  7. Created by Chris Colefax, March 1997
  8.  
  9. 1.0  INSTALLATION
  10. 2.0  QUICK START
  11. 3.0  OPTIONS
  12. 3.1  A NOTE ON UNITS
  13.         3.2  OBJECT OPTIONS
  14.                 3.2.1  explode_object
  15.                 3.2.2  object_centre
  16.                 3.2.3  object_size
  17.                 3.2.4  object_corner1
  18.                 3.2.5  object_corner2
  19.                 3.2.6  object_hollow
  20.         3.3  PARTICLE OPTIONS
  21.                 3.3.1  particle_res
  22.                 3.3.2  particle_object
  23.                 3.3.3  particle_texture
  24.         3.4  EXPLOSION OPTIONS
  25.                 3.4.1  exp_location
  26.                 3.4.2  exp_strength
  27.                 3.4.3  exp_falloff
  28.                 3.4.4  exp_gravity
  29.                 3.4.5  exp_sky
  30.                 3.4.6  exp_spin
  31.         3.5  GROUND PLANE OPTIONS
  32.                 3.5.1  ground_plane
  33.                 3.5.2  ground_dist
  34.                 3.5.3  ground_reflection
  35.                 3.5.4  max_bounces
  36.         3.6  TURBULENCE OPTIONS
  37.                 3.6.1  exp_turb
  38.                 3.6.2  scale_turb
  39.                 3.6.3  rotate_turb
  40.                 3.6.4  vel_turb
  41.                 3.6.5  dir_turb
  42.                 3.6.6  spin_turb
  43.                 3.6.7  exp_seed
  44.         4.0  GENERATING THE EXPLOSION
  45.         5.0  CONTACTING THE AUTHOR
  46.  
  47. **************************************************************************
  48.  
  49.  
  50. 1.0  INSTALLATION
  51. **************************************************************************
  52. Copy the Object Exploder include file (Explode.inc) to one of the
  53. directories (folders) in your POVRay library path.  Normally this is the
  54. INCLUDE sub-directory of the directory where you installed POVRay, so if
  55. you installed POVRay in C:\POVRAY you should copy the Explode.inc file to 
  56. C:\POVRAY\INCLUDE.  On a Windows 95 system, this is probably something 
  57. like:
  58.  
  59.    C:\Program Files\POV-Ray for Windows\Include
  60.  
  61. On UNIX and similar systems, where filenames are case-sensitive, you may
  62. have to rename the include file so that it starts with a capital and the
  63. rest of its letters are lowercase.  If you want to render the sample
  64. files you should also check that the naming of Map.gif is as shown.  This
  65. will enable you to render the sample files without modification.
  66.  
  67.  
  68. 2.0  QUICK START
  69. **************************************************************************
  70. The Object Exploder include file will take any existing POVRay object,
  71. from a simple sphere to a complex CSG object, and explode it into a mass
  72. of animated particles.  There are many options you can use to affect the
  73. way the explosion occurs; to use any of these you simply add the following
  74. line to your POVRay scene file:
  75.  
  76.    #declare [variable-name] = [value]
  77.  
  78. substituting the desired variable name and value where appropriate.  After
  79. you have declared all the options you want to use, you add the following
  80. line to your POVRay scene file:
  81.  
  82.    #include "Explode.inc"
  83.  
  84. The Object Exploder include file will then automatically create the
  85. animated explosion for you.  Although only one option is required to
  86. create an explosion (explode_object) you will want to use the options
  87. listed below to ensure you get the sort of explosion that you want.
  88.  
  89.  
  90. 3.0  OPTIONS
  91. **************************************************************************
  92.  
  93. 3.1  A NOTE ON UNITS
  94. ********************
  95. When using the Object Exploder options you will discover a number of
  96. variables that must be specified as a certain number of units.  Just as in
  97. POVRay the units you wish to use are entirely up to you, eg. you may
  98. specify the object size in microns or miles, and the explosion clock in
  99. milliseconds or days.
  100.  
  101. The important thing is that you keep the units that you use in a
  102. particular scene file consistent for that entire file, eg. if you are
  103. measuring distances in metres and time in seconds then speeds should be
  104. expressed as metres per second.  This will ensure that you get the results
  105. you expect, and will save you a lot of trouble.
  106.  
  107.  
  108. 3.2  OBJECT OPTIONS
  109. *******************
  110. The first step when using the Object Exploder include file is to specify
  111. a number of parameters that identify the object you wish to explode, as
  112. well as it's position in the POVRay universe.
  113.  
  114. 3.2.1  explode_object
  115. *********************
  116. This parameter indicates the object you want to explode, and can be either
  117. a predefined object or a completely new object definition, including
  118. textures and transformations, eg:
  119.  
  120.    #declare explode_object = object {MyObject scale 3}
  121.    #declare explode_object = sphere {<0, 5, 0>, 3 pigment {Red}}
  122.  
  123. Any POVRay object can be used, including CSG objects and triangle meshes.
  124.  
  125. After you have specified the explode_object you must declare a number of
  126. variables that indicate the size and position of the object.  Four vectors
  127. can be used for this, but only two are needed, and only the first two
  128. found will be used.  For the best results you should try to make these
  129. measurements as accurate as possible.
  130.  
  131. 3.2.2  object_centre
  132. ********************
  133. This specifies the exact centre of the explode_object, and is best used
  134. when exploding spherical or cylindrical objects.
  135.  
  136. Note: object_center can also be used to specify this variable.
  137.  
  138. 3.2.3  object_size
  139. ******************
  140. This specifies the X, Y, and Z dimensions of the explode_object, eg. if
  141. the explode_object was a sphere with a radius of 1 then the size would
  142. be <2, 2, 2>.
  143.  
  144. 3.2.4  object_corner1
  145. *********************
  146. This specifies the lower-left hand corner of the object, and is best used
  147. when exploding box-like objects.
  148.  
  149. 3.2.5  object_corner2
  150. *********************
  151. This vector specifies the upper-right hand corner of the object.
  152.  
  153. 3.2.6  object_hollow
  154. ********************
  155. This is a true / false value that indicates whether the explode_object is
  156. to be considered as a surface model only, or as a solid object.
  157. If object_hollow = true (default) then the object is considered to be
  158. hollow inside, and particles are created from the surface of the object.
  159.  
  160. If object_hollow = false then the object is considered to be solid, and
  161. when it is exploded particles will be created inside the object as well as
  162. on the surface.  Note that this may not work with all objects (eg.
  163. triangles, polygons) as they do not have clearly defined insides and
  164. outsides.
  165.  
  166. 3.3  PARTICLE OPTIONS
  167. *********************
  168. After you have specified all the desired object variables you can specify
  169. a number of options which will adjust the shape, size, and number of
  170. particles created when the object is exploded.
  171.  
  172. 3.3.1  particle_res
  173. *******************
  174. This is the most important of the particle options, and specifies the
  175. number of particles to create.  It should be specified as a vector, but
  176. may be specified as a float (eg. 3 = <3, 3, 3>).  When the object is
  177. exploded it is broken up into a grid of particles, with the number of
  178. particles in each direction taken from the X, Y, and Z components of
  179. this vector, eg. #declare particle_res = <7, 3, 5> will create 7
  180. particles in the X direction, 3 in the Y direction, and 5 in the Z
  181. direction, which gives 7 * 3 * 5 particles, or 105 particles in total.
  182.  
  183. Each component of the vector can be 1 or larger.  However, adjusting
  184. this variable can drastically alter the speed it takes to generate the
  185. explosion, so keep this in mind when trying larger numbers.
  186.  
  187. 3.3.2  particle_object
  188. **********************
  189. This specifies the shape of the individual particles created by the
  190. Object Exploder, and should generally be a unit sized object centred
  191. around the origin (the default is box {<-.5, -.5, -.5>, <.5, .5, .5>}).
  192.  
  193. The particle_object can include texture information, but this will
  194. only be used if object_hollow = false.  Note also that this will give
  195. all particles the same texture; if you want the particles to be
  196. textured based on their location inside the object you should use the
  197. particle_texture option.
  198.  
  199. 3.3.3  particle_texture
  200. ***********************
  201. This specifies the texture of the inside of the object, and will only
  202. be used if object_hollow = false.  Using this option allows you to
  203. texture particles differently according to their position within the
  204. object, eg. if you use a gradient that goes from white at the bottom
  205. of the object to red at the top, any particles from the bottom of the
  206. object will be white while any from the top will be red.
  207. The default particle_texture = texture {pigment {rgb <.5, .5, .5>}}
  208.  
  209. 3.4  EXPLOSION OPTIONS
  210. **********************
  211. The following parameters specify the actual characteristics of the
  212. explosion itself (ie. the force that breaks apart the object).
  213.  
  214. 3.4.1  exp_location
  215. *******************
  216. This specifies the vector location of the explosion, and determines the
  217. direction in which the particles will move after the explosion, eg.
  218. making this the same as the object_centre will explode the particles
  219. outwards in all directions, while placing this below the object will
  220. explode the particles upwards.  By default this is at the origin.
  221.  
  222. 3.4.2  exp_strength
  223. *******************
  224. This specifies the force of the explosion.  It is actually the velocity
  225. given to each particle at the start of the explosion.  Larger numbers
  226. will make the objects explode more quickly, while smaller numbers will
  227. make the explosion seem smaller.  Specifying 0 for this option will
  228. not actually move the particles, and is useful for giving the impression
  229. of an object that cracks without actually blowing up (it is best used
  230. with the exp_gravity option).
  231.  
  232. Specifying negative numbers will cause the particles to move in the
  233. opposite direction, and can be used to create an imploding object,
  234. rather than an exploding object.
  235.  
  236. 3.4.3  exp_falloff
  237. ******************
  238. Normally all particles are given the same velocity (specified by
  239. exp_strength) at the start of the explosion, regardless of their distance
  240. from the explosion itself.  You can use the exp_falloff option to make
  241. particles further from the explosion receive less of the explosion's
  242. force than particles that are near the explosion.  The number specified
  243. actually indicates the distance at which the exp_strength drops to 25% of
  244. its original strength, eg. #declare exp_falloff = 10 means that a particle
  245. 10 units away from the exp_location will only receive 25% of the force
  246. specified by exp_strength.
  247.  
  248. 3.4.4  exp_gravity
  249. ******************
  250. This specifies the strength of the force of gravity, declared as a float
  251. (NOT a vector).  Normally this is 0 (ie. no gravity), but specifying
  252. otherwise will cause particles to be pulled to the ground.
  253.  
  254. 3.4.5  exp_sky
  255. **************
  256. This specifies the direction vector that points in the up direction
  257. (normally this it y, ie. <0, 1, 0>).  It works in a similar way to the
  258. sky keyword in the POVRay camera, and it useful when using a different
  259. coordinate system (eg. #declare exp_sky = z if the z-axis points upwards).
  260. This vector determines the direction of the gravity (opposite to the sky,
  261. of course) and is also used as the normal of the ground plane if one
  262. is specified (see section 3.5).
  263.  
  264. 3.4.6  exp_spin
  265. ***************
  266. This option can be used to cause the exploded particles to spin as they
  267. move through space.  It can be specified as a vector or float, and
  268. indicates the number of spins to make per each unit of time, eg.
  269. #declare exp_spin = <.5, 1, 0> will spin each particle 180 degrees about
  270. the x-axis and 360 degrees about the y-axis for every unit of time that
  271. passes.  Usually it is easier to #declare this option as a float value
  272. that indicates the amount of spin you wish to give each particle, eg.
  273. #declare exp_spin = .3
  274.  
  275. 3.5  GROUND PLANE OPTIONS
  276. *************************
  277. The Object Exploder include file has the ability to add a ground plane
  278. to the scene.  If a particle hits this plane it can automatically rebound
  279. off it or it can stop and come to rest on the plane.
  280. Note that the Object Exploder include file will not actually create a
  281. ground plane object for you, giving you the option to use any sort of
  282. object you like to represent the ground.
  283.  
  284. 3.5.1  ground_plane
  285. *******************
  286. This is a true / false value that indicates whether a ground plane is
  287. present or not.  Normally this is false, but setting it to true will
  288. cause the Object Exploder to check each particle's movement against
  289. this plane to see if it rebounds or stops.  Also, any particles
  290. underneath the plane will not be created.
  291.  
  292. 3.5.2  ground_dist
  293. ******************
  294. This specifies the distance of the ground from the origin, and is the
  295. same as the distance value as specified in the plane object.  Note that
  296. the normal direction of the plane is always the same as exp_sky (the
  297. default if <0, 1, 0>; see section 3.4.5).  Normally the ground_dist = 0.
  298.  
  299. 3.5.3  ground_reflection
  300. ************************
  301. This specifies the amount of energy a particle retains after hitting the
  302. ground plane.  ground_reflection = 1 means that the particles retains
  303. all it's energy, and will bounce back to the same height each time
  304. it hits the ground.  ground_reflection = 0 means that the particle retains
  305. none of it's energy after hitting the plane, and therefore it comes to
  306. a stop.  Values in between 0 and 1 will cause the particle to bounce
  307. less high each time it hits the plane, eventually coming to a stop.
  308. Values larger than 1 will cause the particle to bounce higher each time
  309. it hits the plane.
  310.  
  311. 3.5.4  max_bounces
  312. ******************
  313. This option specifies the maximum number of times a particle will rebound
  314. off a plane before coming to a stop (even if ground_reflection >= 1).
  315. This is necessary because of the way the rebounds are calculated: each
  316. time a particle is checked for rebounds all the particles rebounds prior
  317. to the current rebound need to be recalculated (this is a limitation in
  318. the way POVRay handles variables from frame to frame in an animation).
  319. This means that on a particle's second rebound the first rebound has to
  320. be calculated again, while on the third rebound the first and second
  321. rebounds have to recalculated.
  322.  
  323. Because calculating each rebound requires solving a quadratic equation
  324. as well as a number of other calculations, this can add a considerable
  325. amount to the time needed to generate the explosion.  For this reason,
  326. you can use the max_bounces option to limit the number of bounces a
  327. particle will make.  By default this is set to 1 (ie. each particle
  328. will bounce once, and then stop).  Setting it to 0 will stop particles
  329. bouncing at all, while increasing the number will allow particles to
  330. bounce more times before coming to a stop.
  331.  
  332. 3.6  TURBULENCE OPTIONS
  333. ***********************
  334. By default the Object Exploder include file creates the explosion
  335. particles in a perfect grid (specified by the particle_res option), and
  336. each particle is the same size, and travels at the same speed.  While this
  337. is fine for some explosions it is less than realistic.  To remedy this you
  338. can add turbulence to the explosion, adding a little randomness to each
  339. particle's size and speed.
  340.  
  341. 3.6.1  exp_turb
  342. ***************
  343. This option controls the overall amount of turbulence added to the
  344. explosion (normally this is 0).  Good values range from 0 (no
  345. turbulence) to 1 (lots of turbulence), but any value can be used.
  346. Changing this value will add equal turbulence to all aspects of
  347. the explosion.  If you wish to adjust the turbulence of individual areas
  348. of the explosion you can use the following parameters.   (Note that all
  349. the individual turbulence options are multiplied by exp_turb to find the
  350. final turbulence, so you will have to make sure that exp_turb is not 0
  351. before using the other turbulence options).
  352.  
  353. 3.6.2  scale_turb
  354. *****************
  355. This option controls the amount of turbulence added to the scaling of the
  356. particles.  It is specified as a factor of the particle size,
  357. eg. scale_turb = .5 will give particles scaled up to 50% larger or smaller
  358. than normal.
  359.  
  360. 3.6.3  rotate_turb
  361. ******************
  362. This option controls the amount of turbulence added to the rotation of the
  363. particles.  It is specified as a fraction of 360 degrees,
  364. eg. rotate_turb = .1 will give particles rotated up to 36 degrees away from
  365. normal.
  366.  
  367. 3.6.4  vel_turb
  368. ***************
  369. This option controls the amount of turbulence added to the velocity of the
  370. particles.  It is specified as a factor of the particle velocity,
  371. eg. #declare vel_turb = .3 will give particles with velocities up to 30%
  372. more or less than normal.
  373.  
  374. 3.6.5  dir_turb
  375. ***************
  376. This option controls the amount of turbulence added to the direction of the
  377. particles movement.  It is specified as a fraction of 360 degrees,
  378. eg. #declare dir_turb = .2 will give particles that move up to 20 degrees
  379. away from normal.
  380.  
  381. 3.6.6  spin_turb
  382. ****************
  383. This option controls the amount of turbulence added to the spin of each
  384. particle, and only applies when you have specified a non-zero value for
  385. exp_spin (see section 3.4.6).  It is measured as a factor of the total spin
  386. amount, eg. #declare spin_turb = .7 will give particles that spin up to 70%
  387. more or less than normal.
  388.  
  389. 3.6.7  exp_seed
  390. ***************
  391. This option specifies that random number seed used when adding turbulence to
  392. the explosion.  Normally this is 0, but any integer value can be used.
  393.  
  394.  
  395. 4.0  GENERATING THE EXPLOSION
  396. **************************************************************************
  397. After you have declared all the desired variables you have to specify the
  398. explode_clock variable (and then include the "Explode.inc" file, of course).
  399. This variable indicates the current time value of the explosion, where 0 is
  400. just before the explosion starts.
  401.  
  402. Normally the explode_clock is equal to POVRay's internal clock variable.
  403. This may not, however, be what you require for a particular animation.
  404. Because of this you are given the option to #declare explode_clock to be
  405. any value you want.  
  406.  
  407. You can use this to create still scenes from a particular way through the
  408. explosion, eg. #declare explode_clock = 1.47 will create a still scene of
  409. the explosion 1.47 units of time after it started.  (Note that when
  410. explode_clock is less than or equal to 0 the explode_object is placed in
  411. the scene without being altered at all).
  412.  
  413. Usually you will declare explode_clock to be some function of POVRay's
  414. internal clock variable.  Sometimes this will be as simple as:
  415.  
  416.    #declare explode_clock = clock * 5
  417.  
  418. which will create an explode_clock that goes 5 times as fast as the
  419. internal clock.  You could use 0.5 to make the explode_clock half as fast as
  420. the internal clock, or any number you wish.
  421.  
  422. Sometimes, however, you might want a more complicated explode_clock, such
  423. as one that starts only at a particular time, or one that goes backwards,
  424. or one that starts fast and slows down.  All of these can be easily
  425. accomplished using POVRay's various float functions, and the #if and #switch
  426. directives.
  427.  
  428. For some examples of using explode_clock in this way take
  429. a look at the sample animations that came with the Object Exploder include
  430. file.
  431.  
  432.  
  433. 5.0  CONTACTING THE AUTHOR
  434. **************************************************************************
  435. If you wish to contact me with bug reports, bug fixes, criticisms, 
  436. comments, suggested improvements, questions, etc. you can reach me by 
  437. email at:
  438.  
  439.    ccolefax@geocities.com
  440.  
  441. or by regular mail at:
  442.  
  443.    Chris Colefax
  444.    PO Box 110
  445.    Kuranda, Queensland
  446.    Australia  4872
  447.  
  448. **************************************************************************
  449.  
  450. POV-Ray(tm) and Persistence of Vision(tm) are registered trademarks of the
  451. POV-Ray Team(tm)
  452.