aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/src/core/script/particle.js
diff options
context:
space:
mode:
authorValerio Virgillito2012-07-09 14:35:44 -0700
committerValerio Virgillito2012-07-09 14:35:44 -0700
commit84b3327bd92faafab7954b5eb64c7abe24a3fe13 (patch)
tree3f56cbed2f08c5a81ea79eaf0bcb9bd031d8a627 /js/helper-classes/RDGE/src/core/script/particle.js
parentc0a42c56f768a873ba637f5b86d5f6a84d4a3312 (diff)
parent40c6eb2c06b34f65a74d59ef9687251952858bab (diff)
downloadninja-84b3327bd92faafab7954b5eb64c7abe24a3fe13.tar.gz
Merge branch 'normalize' of https://github.com/kriskowal/ninja-internal
Conflicts: js/components/gradientpicker.reel/gradientpicker.js js/components/tools-properties/text-properties.reel/text-properties.js js/document/views/base.js js/document/views/design.js js/helper-classes/3D/StageLine.js js/helper-classes/3D/draw-utils.js js/lib/drawing/world.js js/lib/geom/circle.js js/lib/geom/line.js js/lib/geom/rectangle.js js/lib/geom/shape-primitive.js js/lib/rdge/materials/bump-metal-material.js js/lib/rdge/materials/flag-material.js js/lib/rdge/materials/fly-material.js js/lib/rdge/materials/julia-material.js js/lib/rdge/materials/keleidoscope-material.js js/lib/rdge/materials/mandel-material.js js/lib/rdge/materials/material.js js/lib/rdge/materials/plasma-material.js js/lib/rdge/materials/pulse-material.js js/lib/rdge/materials/radial-gradient-material.js js/lib/rdge/materials/taper-material.js js/lib/rdge/materials/twist-vert-material.js js/lib/rdge/materials/water-material.js js/panels/Materials/materials-library-panel.reel/materials-library-panel.html js/panels/Materials/materials-library-panel.reel/materials-library-panel.js js/panels/Materials/materials-popup.reel/materials-popup.html js/panels/Materials/materials-popup.reel/materials-popup.js js/tools/LineTool.js Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/particle.js')
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/particle.js1594
1 files changed, 797 insertions, 797 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/particle.js b/js/helper-classes/RDGE/src/core/script/particle.js
index d1ab6239..59894e9a 100755
--- a/js/helper-classes/RDGE/src/core/script/particle.js
+++ b/js/helper-classes/RDGE/src/core/script/particle.js
@@ -1,797 +1,797 @@
1/* <copyright> 1/* <copyright>
2Copyright (c) 2012, Motorola Mobility, Inc 2Copyright (c) 2012, Motorola Mobility, Inc
3All Rights Reserved. 3All Rights Reserved.
4BSD License. 4BSD License.
5 5
6Redistribution and use in source and binary forms, with or without 6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met: 7modification, are permitted provided that the following conditions are met:
8 8
9 - Redistributions of source code must retain the above copyright notice, 9 - Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer. 10 this list of conditions and the following disclaimer.
11 - Redistributions in binary form must reproduce the above copyright 11 - Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in the 12 notice, this list of conditions and the following disclaimer in the
13 documentation and/or other materials provided with the distribution. 13 documentation and/or other materials provided with the distribution.
14 - Neither the name of Motorola Mobility nor the names of its contributors 14 - Neither the name of Motorola Mobility nor the names of its contributors
15 may be used to endorse or promote products derived from this software 15 may be used to endorse or promote products derived from this software
16 without specific prior written permission. 16 without specific prior written permission.
17 17
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28POSSIBILITY OF SUCH DAMAGE. 28POSSIBILITY OF SUCH DAMAGE.
29</copyright> */ 29</copyright> */
30 30
31var RDGE = RDGE || {}; 31var RDGE = RDGE || {};
32 32
33RDGE.particle = function (def, id) { 33RDGE.particle = function (def, id) {
34 this.id = id; 34 this.id = id;
35 this.def = def; 35 this.def = def;
36 if (this.def.numFrames == undefined) { 36 if (this.def.numFrames == undefined) {
37 if (this.def.textureSize && this.def.frameSize) { 37 if (this.def.textureSize && this.def.frameSize) {
38 this.def.numFrames = (this.def.textureSize[0] / this.def.frameSize[0]) * (this.def.textureSize[1] / this.def.frameSize[1]); 38 this.def.numFrames = (this.def.textureSize[0] / this.def.frameSize[0]) * (this.def.textureSize[1] / this.def.frameSize[1]);
39 } else { 39 } else {
40 this.def.numFrames = 0; 40 this.def.numFrames = 0;
41 } 41 }
42 } 42 }
43 43
44 this.pos = RDGE.vec3.zero(); 44 this.pos = RDGE.vec3.zero();
45 this.delta = RDGE.vec3.zero(); 45 this.delta = RDGE.vec3.zero();
46 this.rotate = 0.0; 46 this.rotate = 0.0;
47 this.age = 0.0; 47 this.age = 0.0;
48 this.lifespan = 0.0; 48 this.lifespan = 0.0;
49 this.velocity = RDGE.vec3.zero(); 49 this.velocity = RDGE.vec3.zero();
50 this.gravity = RDGE.vec3.zero(); 50 this.gravity = RDGE.vec3.zero();
51 this.frame = 0; 51 this.frame = 0;
52 this.frameCount = 0; 52 this.frameCount = 0;
53 this.lastPos = RDGE.vec3.zero(); 53 this.lastPos = RDGE.vec3.zero();
54 this.state = 0; 54 this.state = 0;
55 this.hide = false; 55 this.hide = false;
56 this.color = RDGE.vec4.zero(); 56 this.color = RDGE.vec4.zero();
57 57
58 this.randomize = function (min, max) { 58 this.randomize = function (min, max) {
59 return min + (max - min) * Math.random(); 59 return min + (max - min) * Math.random();
60 }; 60 };
61 this.rate = this.randomize(-1.0, 1.0); 61 this.rate = this.randomize(-1.0, 1.0);
62 62
63 this.randomize3 = function (min, max) { 63 this.randomize3 = function (min, max) {
64 return [this.randomize(min[0], max[0]), 64 return [this.randomize(min[0], max[0]),
65 this.randomize(min[1], max[1]), 65 this.randomize(min[1], max[1]),
66 this.randomize(min[2], max[2])]; 66 this.randomize(min[2], max[2])];
67 }; 67 };
68 68
69 this.spawn = function (spawnMatrix) { 69 this.spawn = function (spawnMatrix) {
70 if (this.def.initialframe == undefined) { 70 if (this.def.initialframe == undefined) {
71 this.frame = this.id % this.def.numFrames; 71 this.frame = this.id % this.def.numFrames;
72 } else { 72 } else {
73 this.frame = this.randomize(this.def.initialframe[0], this.def.initialframe[1]); 73 this.frame = this.randomize(this.def.initialframe[0], this.def.initialframe[1]);
74 } 74 }
75 this.pos = this.randomize3(this.def.initialpos[0], this.def.initialpos[1]); 75 this.pos = this.randomize3(this.def.initialpos[0], this.def.initialpos[1]);
76 if (this.def.worldSpace) { 76 if (this.def.worldSpace) {
77 // calculate the initial position in world space. 77 // calculate the initial position in world space.
78 this.pos = RDGE.mat4.transformPoint(spawnMatrix, this.pos); 78 this.pos = RDGE.mat4.transformPoint(spawnMatrix, this.pos);
79 } 79 }
80 // all other values are assumed to be defined in local or world space depending on 80 // all other values are assumed to be defined in local or world space depending on
81 // the particles worldSpace designation. 81 // the particles worldSpace designation.
82 var toRadians = Math.PI / 180.0; 82 var toRadians = Math.PI / 180.0;
83 if (this.def.initialsize) { 83 if (this.def.initialsize) {
84 this.size = this.randomize(this.def.initialsize[0], this.def.initialsize[1]); 84 this.size = this.randomize(this.def.initialsize[0], this.def.initialsize[1]);
85 } else { 85 } else {
86 this.size = 1.0; 86 this.size = 1.0;
87 } 87 }
88 this.velocity = this.randomize3(this.def.initialvel[0], this.def.initialvel[1]); 88 this.velocity = this.randomize3(this.def.initialvel[0], this.def.initialvel[1]);
89 this.gravity = [this.def.gravity[0], this.def.gravity[1], this.def.gravity[2]]; 89 this.gravity = [this.def.gravity[0], this.def.gravity[1], this.def.gravity[2]];
90 this.rotate = this.randomize(this.def.initialrot[0] * toRadians, this.def.initialrot[1] * toRadians); 90 this.rotate = this.randomize(this.def.initialrot[0] * toRadians, this.def.initialrot[1] * toRadians);
91 this.lifespan = this.randomize(this.def.lifespan[0], this.def.lifespan[1]); 91 this.lifespan = this.randomize(this.def.lifespan[0], this.def.lifespan[1]);
92 this.age = 0.0; 92 this.age = 0.0;
93 this.delta = [0.0, 0.0, 0.0]; 93 this.delta = [0.0, 0.0, 0.0];
94 this.lastPos = RDGE.vec3.add(this.pos, RDGE.vec3.scale(this.velocity, -1.0 / 30.0)); 94 this.lastPos = RDGE.vec3.add(this.pos, RDGE.vec3.scale(this.velocity, -1.0 / 30.0));
95 this.color = [1, 1, 1, 1]; //RDGE.vec4.random( [0.0, 0.0, 0.0, 1.0], [1.0, 1.0, 1.0, 1.0] ); 95 this.color = [1, 1, 1, 1]; //RDGE.vec4.random( [0.0, 0.0, 0.0, 1.0], [1.0, 1.0, 1.0, 1.0] );
96 }; 96 };
97}; 97};
98 98
99// double buffered array utility class 99// double buffered array utility class
100RDGE.DoubleBuffer = function (arrType, size) { 100RDGE.DoubleBuffer = function (arrType, size) {
101 this.buffer = {}; 101 this.buffer = {};
102 this.buffer[0] = new arrType(size); 102 this.buffer[0] = new arrType(size);
103 this.buffer[1] = new arrType(size); 103 this.buffer[1] = new arrType(size);
104 this.bufferIndex = 0; 104 this.bufferIndex = 0;
105 105
106 this.flip = function () { 106 this.flip = function () {
107 this.bufferIndex = 1 - this.bufferIndex; 107 this.bufferIndex = 1 - this.bufferIndex;
108 } 108 }
109 this.front = function () { 109 this.front = function () {
110 return this.buffer[this.bufferIndex]; 110 return this.buffer[this.bufferIndex];
111 } 111 }
112 this.back = function () { 112 this.back = function () {
113 return this.buffer[1 - this.bufferIndex]; 113 return this.buffer[1 - this.bufferIndex];
114 } 114 }
115}; 115};
116 116
117 117
118// cycling buffer 118// cycling buffer
119RDGE.particleBuffer = function (pdef, emitter, size) { 119RDGE.particleBuffer = function (pdef, emitter, size) {<