aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/src/core/script/renderUtils.js
diff options
context:
space:
mode:
authorKris Kowal2012-07-06 12:34:53 -0700
committerKris Kowal2012-07-06 15:01:48 -0700
commit3644cb6def4f681c99959e5729e78ea353441fad (patch)
treef8a886f4829e507cc4956db37cff2580cae6003d /js/helper-classes/RDGE/src/core/script/renderUtils.js
parent04343eda8c2f870b0da55cfdc8003c99fe1cc4de (diff)
downloadninja-3644cb6def4f681c99959e5729e78ea353441fad.tar.gz
Normalize to unix line terminators
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/renderUtils.js')
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/renderUtils.js792
1 files changed, 396 insertions, 396 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/renderUtils.js b/js/helper-classes/RDGE/src/core/script/renderUtils.js
index a25b3dec..4e98cb1a 100755
--- a/js/helper-classes/RDGE/src/core/script/renderUtils.js
+++ b/js/helper-classes/RDGE/src/core/script/renderUtils.js
@@ -1,396 +1,396 @@
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 || {};
32RDGE.renderUtils = RDGE.renderUtils || {}; 32RDGE.renderUtils = RDGE.renderUtils || {};
33 33
34/* 34/*
35* Creates an indexed box primitive 35* Creates an indexed box primitive
36* @return a rdge primitive 36* @return a rdge primitive
37*/ 37*/
38RDGE.renderUtils.createBox = function () { 38RDGE.renderUtils.createBox = function () {
39 var renderer = RDGE.globals.engine.getContext().renderer; 39 var renderer = RDGE.globals.engine.getContext().renderer;
40 40
41 var coords = 41 var coords =
42 [1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, // front 42 [1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, // front
43 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, // right 43 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, // right
44 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, // top 44 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, // top
45 -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, // left 45 -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, // left
46 -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, // bottom 46 -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, // bottom
47 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1]; // back 47 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1]; // back
48 48
49 var normals = 49 var normals =
50 [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, // front 50 [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, // front
51 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, // right 51 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, // right
52 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, // top 52 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, // top
53 -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, // left 53 -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, // left
54 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, // bottom 54 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, // bottom
55 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1]; // back 55 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1]; // back
56 56
57 var uvs = 57 var uvs =
58 [1, 1, 0, 1, 0, 0, 1, 0, // front 58 [1, 1, 0, 1, 0, 0, 1, 0, // front
59 0, 1, 0, 0, 1, 0, 1, 1, // right 59 0, 1, 0, 0, 1, 0, 1, 1, // right
60 1, 0, 1, 1, 0, 1, 0, 0, // top 60 1, 0, 1, 1, 0, 1, 0, 0, // top
61 1, 1, 0, 1, 0, 0, 1, 0, // left 61 1, 1, 0, 1, 0, 0, 1, 0, // left
62 0, 0, 1, 0, 1, 1, 0, 1, // bottom 62 0, 0, 1, 0, 1, 1, 0, 1, // bottom
63 0, 0, 1, 0, 1, 1, 0, 1]; // back 63 0, 0, 1, 0, 1, 1, 0, 1]; // back
64 64
65 var indices = 65 var indices =
66 [0, 1, 2, 0, 2, 3, // front 66 [0, 1, 2, 0, 2, 3, // front
67 4, 5, 6, 4, 6, 7, // right 67 4, 5, 6, 4, 6, 7, // right
68 8, 9, 10, 8, 10, 11, // top 68 8, 9, 10, 8, 10, 11, // top
69 12, 13, 14, 12, 14, 15, // left 69 12, 13, 14, 12, 14, 15, // left
70 16, 17, 18, 16, 18, 19, // bottom 70 16, 17, 18, 16, 18, 19, // bottom
71 20, 21, 22, 20, 22, 23]; // back 71 20, 21, 22, 20, 22, 23]; // back
72 72
73 73
74 var prim = new RDGE.rdgePrimitiveDefinition(); 74 var prim = new RDGE.rdgePrimitiveDefinition();
75 75
76 prim.vertexDefinition = 76 prim.vertexDefinition =
77 { 77 {
78 "vert": { 'type': RDGE.rdgeConstants.VS_ELEMENT_POS, 'bufferIndex': 0, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }, 78 "vert": { 'type': RDGE.rdgeConstants.VS_ELEMENT_POS, 'bufferIndex': 0, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC },
79 "a_pos": { 'type': RDGE.rdgeConstants.VS_ELEMENT_POS, 'bufferIndex': 0, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }, 79 "a_pos": { 'type': RDGE.rdgeConstants.VS_ELEMENT_POS, 'bufferIndex': 0, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC },
80 80
81 "normal": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT3, 'bufferIndex': 1, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }, 81 "normal": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT3, 'bufferIndex': 1, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC },
82 "a_nrm": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT3, 'bufferIndex': 1, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }, 82 "a_nrm": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT3, 'bufferIndex': 1, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC },
83 83
84 "texcoord": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex': 2, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }, 84 "texcoord": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex': 2, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC },
85 "a_uv": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex': 2, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC } 85 "a_uv": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex': 2, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }
86 }; 86 };
87 87
88 prim.bufferStreams = 88 prim.bufferStreams =
89 [ 89 [
90 coords, 90 coords,
91 normals, 91 normals,
92 uvs 92 uvs
93 ]; 93 ];
94 94
95 prim.streamUsage = 95 prim.streamUsage =
96 [ 96 [
97 RDGE.rdgeConstants.BUFFER_STATIC, 97 RDGE.rdgeConstants.BUFFER_STATIC,
98 RDGE.rdgeConstants.BUFFER_STATIC, 98 RDGE.rdgeConstants.BUFFER_STATIC,
99 RDGE.rdgeConstants.BUFFER_STATIC 99 RDGE.rdgeConstants.BUFFER_STATIC
100 ]; 100 ];
101 101
102 prim.indexUsage = RDGE.rdgeConstants.BUFFER_STREAM; 102 prim.indexUsage = RDGE.rdgeConstants.BUFFER_STREAM;
103 prim.indexBuffer = indices; 103 prim.indexBuffer = indices;
104 104
105 prim.type = RDGE.rdgeConstants.TRIANGLES; 105 prim.type = RDGE.rdgeConstants.TRIANGLES;
106 106
107 renderer.createPrimitive(prim); 107 renderer.createPrimitive(prim);
108 108
109 return prim; 109 return prim;
110}; 110};
111 111
112// 112//
113// makeSphere 113// makeSphere
114// 114//
115// Create a sphere with the passed number of latitude and longitude bands and the passed radius. 115// Create a sphere with the passed number of latitude and longitude bands and the passed radius.
116// Sphere has vertices, normals and texCoords. Create VBOs for each as well as the index array. 116// Sphere has vertices, normals and texCoords. Create VBOs for each as well as the index array.
117// Return an object with the following properties: 117// Return an object with the following properties:
118// 118//
119// normalObject WebGLBuffer object for normals 119// normalObject WebGLBuffer object for normals
120// texCoordObject WebGLBuffer object for texCoords 120// texCoordObject WebGLBuffer object for texCoords
121// vertexObject WebGLBuffer object for vertices