diff options
author | Jonathan Duran | 2012-07-17 09:30:22 -0700 |
---|---|---|
committer | Jonathan Duran | 2012-07-17 09:30:22 -0700 |
commit | 53051672a62208fbc96957719d8285fac6431ed6 (patch) | |
tree | 79d542ee811044e8af2ef84aa0d6662c6eb895c4 /js/lib/rdge/materials/julia-material.js | |
parent | 7e2c2dbd040ed79a3f0678f91bd4b6db9cf69231 (diff) | |
parent | 5146f224258929415adf4a8022e492454b4e2476 (diff) | |
download | ninja-53051672a62208fbc96957719d8285fac6431ed6.tar.gz |
Merge branch 'refs/heads/NINJA-master' into TimelineUber
Conflicts:
js/panels/Timeline/DragDrop.js
js/panels/Timeline/Keyframe.reel/Keyframe.js
js/panels/Timeline/Layer.reel/Layer.js
js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js
js/panels/Timeline/Span.reel/Span.js
js/panels/Timeline/Style.reel/Style.js
js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js
js/panels/Timeline/Track.reel/Track.html
js/panels/Timeline/Track.reel/Track.js
js/panels/Timeline/Track.reel/css/Track.css
js/panels/Timeline/TrackSpacer.reel/TrackSpacer.html
js/panels/Timeline/TrackSpacer.reel/TrackSpacer.js
js/panels/Timeline/TrackSpacer.reel/css/TrackSpacer.css
js/panels/Timeline/Tween.reel/Tween.js
Signed-off-by: Jonathan Duran <jduran@motorola.com>
Diffstat (limited to 'js/lib/rdge/materials/julia-material.js')
-rw-r--r-- | js/lib/rdge/materials/julia-material.js | 162 |
1 files changed, 86 insertions, 76 deletions
diff --git a/js/lib/rdge/materials/julia-material.js b/js/lib/rdge/materials/julia-material.js index eed9e79a..ceab3340 100644 --- a/js/lib/rdge/materials/julia-material.js +++ b/js/lib/rdge/materials/julia-material.js | |||
@@ -1,24 +1,25 @@ | |||
1 | /* <copyright> | 1 | /* <copyright> |
2 | Copyright (c) 2012, Motorola Mobility, Inc | 2 | Copyright (c) 2012, Motorola Mobility LLC. |
3 | All Rights Reserved. | 3 | All Rights Reserved. |
4 | BSD License. | ||
5 | 4 | ||
6 | Redistribution and use in source and binary forms, with or without | 5 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met: | 6 | modification, are permitted provided that the following conditions are met: |
8 | 7 | ||
9 | - Redistributions of source code must retain the above copyright notice, | 8 | * Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. | 9 | this list of conditions and the following disclaimer. |
11 | - Redistributions in binary form must reproduce the above copyright | 10 | |
12 | notice, this list of conditions and the following disclaimer in the | 11 | * Redistributions in binary form must reproduce the above copyright notice, |
13 | documentation and/or other materials provided with the distribution. | 12 | this list of conditions and the following disclaimer in the documentation |
14 | - Neither the name of Motorola Mobility nor the names of its contributors | 13 | and/or other materials provided with the distribution. |
15 | may be used to endorse or promote products derived from this software | 14 | |
16 | without specific prior written permission. | 15 | * Neither the name of Motorola Mobility LLC nor the names of its |
16 | contributors may be used to endorse or promote products derived from this | ||
17 | software without specific prior written permission. | ||
17 | 18 | ||
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | 22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
@@ -35,100 +36,109 @@ var JuliaMaterial = function JuliaMaterial() { | |||
35 | /////////////////////////////////////////////////////////////////////// | 36 | /////////////////////////////////////////////////////////////////////// |
36 | // Instance variables | 37 | // Instance variables |
37 | /////////////////////////////////////////////////////////////////////// | 38 | /////////////////////////////////////////////////////////////////////// |
38 | this._name = "Julia"; | 39 | this._name = "Julia"; |
39 | this._shaderName = "julia"; | 40 | this._shaderName = "julia"; |
40 | 41 | ||
41 | this._defaultTexMap = 'assets/images/rocky-normal.jpg'; | 42 | this._defaultTexMap = 'assets/images/rocky-normal.jpg'; |
42 | 43 | ||
43 | this._time = 0.0; | 44 | this._time = 0.0; |
44 | this._dTime = 0.01; | 45 | this._dTime = 0.01; |
45 | 46 | ||
46 | /////////////////////////////////////////////////////////////////////// | 47 | /////////////////////////////////////////////////////////////////////// |
47 | // Properties | 48 | // Properties |
48 | /////////////////////////////////////////////////////////////////////// | 49 | /////////////////////////////////////////////////////////////////////// |
49 | var u_speed_index = 0; | 50 | var u_speed_index = 0; |
50 | this._propNames = [ "u_speed" ]; | 51 | this._propNames = [ "u_speed" ]; |
51 | this._propLabels = [ "Speed" ]; | 52 | this._propLabels = [ "Speed" ]; |
52 | this._propTypes = [ "float" ]; | 53 | this._propTypes = [ "float" ]; |
53 | this._propValues = []; | 54 | this._propValues = []; |
54 | this._propValues[this._propNames[u_speed_index]] = 1.0; | 55 | this._propValues[this._propNames[u_speed_index]] = 1.0; |
55 | 56 | ||
56 | /////////////////////////////////////////////////////////////////////// | 57 | /////////////////////////////////////////////////////////////////////// |
57 | // Material Property Accessors | 58 | // Material Property Accessors |
58 | /////////////////////////////////////////////////////////////////////// | 59 | /////////////////////////////////////////////////////////////////////// |
59 | this.isAnimated = function() { return true; }; | 60 | this.isAnimated = function() { return true; }; |
60 | this.getShaderDef = function() { return JuliaMaterialDef; } | 61 | this.getShaderDef = function() { return JuliaMaterialDef; } |
61 | 62 | ||
62 | /////////////////////////////////////////////////////////////////////// | 63 | /////////////////////////////////////////////////////////////////////// |
63 | // Methods | 64 | // Methods |
64 | /////////////////////////////////////////////////////////////////////// | 65 | /////////////////////////////////////////////////////////////////////// |
65 | 66 | ||
66 | this.init = function( world ) { | 67 | this.init = function( world ) { |
67 | // save the world | 68 | // save the world |
68 | if (world) this.setWorld( world ); | 69 | if (world) this.setWorld( world ); |
69 | 70 | ||
70 | // set up the shader | 71 | // set up the shader |
71 | this._shader = new RDGE.jshader(); | 72 | this._shader = new RDGE.jshader(); |
72 | this._shader.def = JuliaMaterialDef; | 73 | this._shader.def = JuliaMaterialDef; |
73 | this._shader.init(); | 74 | this._shader.init(); |
74 | 75 | ||
75 | // set up the material node | 76 | // set up the material node |
76 | this._materialNode = RDGE.createMaterialNode("juliaMaterial" + "_" + world.generateUniqueNodeID()); | 77 | this._materialNode = RDGE.createMaterialNode("juliaMaterial" + "_" + world.generateUniqueNodeID()); |
77 | this._materialNode.setShader(this._shader); | 78 | this._materialNode.setShader(this._shader); |
78 | 79 | ||
79 | this._time = 0; | 80 | this._time = 0; |
80 | if (this._shader && this._shader['default']) { | 81 | if (this._shader && this._shader['default']) { |
81 | this._shader['default'].u_time.set( [this._time] ); | 82 | this._shader['default'].u_time.set( [this._time] ); |
82 | } | 83 | } |
83 | 84 | ||
84 | // set the shader values in the shader | 85 | // set the shader values in the shader |
85 | this.setShaderValues(); | 86 | this.setShaderValues(); |
86 | this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); | 87 | this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); |
87 | this.update( 0 ); | 88 | this.update( 0 ); |
89 | }; | ||
90 | |||
91 | this.resetToDefault = function() | ||
92 | { | ||
93 | this._propValues[this._propNames[u_speed_index]] = 1.0; | ||
94 | |||
95 | var nProps = this._propNames.length; | ||
96 | for (var i=0; i<nProps; i++) | ||
97 | this.setProperty( this._propNames[i], this._propValues[this._propNames[i]] ); | ||
88 | }; | 98 | }; |
89 | } | 99 | } |
90 | 100 | ||
91 | /////////////////////////////////////////////////////////////////////////////////////// | 101 | /////////////////////////////////////////////////////////////////////////////////////// |
92 | // RDGE shader | 102 | // RDGE shader |
93 | 103 | ||
94 | // shader spec (can also be loaded from a .JSON file, or constructed at runtime) | 104 | // shader spec (can also be loaded from a .JSON file, or constructed at runtime) |
95 | var JuliaMaterialDef = | 105 | var JuliaMaterialDef = |
96 | {'shaders': | 106 | {'shaders': |
97 | { | 107 | { |
98 | 'defaultVShader':"assets/shaders/Basic.vert.glsl", | 108 | 'defaultVShader':"assets/shaders/Basic.vert.glsl", |
99 | 'defaultFShader':"assets/shaders/Julia.frag.glsl" | 109 | 'defaultFShader':"assets/shaders/Julia.frag.glsl" |
100 | }, | 110 | }, |
101 | 'techniques': | 111 | 'techniques': |
102 | { | 112 | { |
103 | 'default': | 113 | 'default': |
104 | [ | 114 | [ |
105 | { | 115 | { |
106 | 'vshader' : 'defaultVShader', | 116 | 'vshader' : 'defaultVShader', |
107 | 'fshader' : 'defaultFShader', | 117 | 'fshader' : 'defaultFShader', |
108 | // attributes | 118 | // attributes |
109 | 'attributes' : | 119 | 'attributes' : |
110 | { | 120 | { |
111 | 'vert' : { 'type' : 'vec3' }, | 121 | 'vert' : { 'type' : 'vec3' }, |
112 | 'normal' : { 'type' : 'vec3' }, | 122 | 'normal' : { 'type' : 'vec3' }, |
113 | 'texcoord' : { 'type' : 'vec2' } | 123 | 'texcoord' : { 'type' : 'vec2' } |
114 | }, | 124 | }, |
115 | // parameters | 125 | // parameters |
116 | 'params' : | 126 | 'params' : |
117 | { | 127 | { |
118 | 'u_time' : { 'type' : 'float' }, | 128 | 'u_time' : { 'type' : 'float' }, |
119 | 'u_speed' : { 'type' : 'float' }, | 129 | 'u_speed' : { 'type' : 'float' }, |
120 | 'u_resolution' : { 'type' : 'vec2' }, | 130 | 'u_resolution' : { 'type' : 'vec2' }, |
121 | }, | 131 | }, |
122 | 132 | ||
123 | // render states | 133 | // render states |
124 | 'states' : | 134 | 'states' : |
125 | { | 135 | { |
126 | 'depthEnable' : true, | 136 | 'depthEnable' : true, |
127 | 'offset':[1.0, 0.1] | 137 | 'offset':[1.0, 0.1] |
128 | } | 138 | } |
129 | } | 139 | } |
130 | ] | 140 | ] |
131 | } | 141 | } |
132 | }; | 142 | }; |
133 | 143 | ||
134 | JuliaMat |