From 3644cb6def4f681c99959e5729e78ea353441fad Mon Sep 17 00:00:00 2001
From: Kris Kowal
Date: Fri, 6 Jul 2012 12:34:53 -0700
Subject: Normalize to unix line terminators
---
.../RDGE/src/core/script/MeshManager.js | 494 +--
.../RDGE/src/core/script/RenderInitProcs.js | 518 +--
.../RDGE/src/core/script/RenderProcs.js | 1022 +++---
.../RDGE/src/core/script/ScreenQuad.js | 106 +-
.../RDGE/src/core/script/ShaderManager.js | 220 +-
.../RDGE/src/core/script/animation.js | 690 ++--
js/helper-classes/RDGE/src/core/script/box.js | 324 +-
js/helper-classes/RDGE/src/core/script/camera.js | 550 ++--
js/helper-classes/RDGE/src/core/script/engine.js | 922 +++---
js/helper-classes/RDGE/src/core/script/fx/blur.js | 434 +--
js/helper-classes/RDGE/src/core/script/fx/ssao.js | 278 +-
.../RDGE/src/core/script/init_state.js | 558 ++--
js/helper-classes/RDGE/src/core/script/jpass.js | 1346 ++++----
js/helper-classes/RDGE/src/core/script/jshader.js | 1528 ++++-----
.../RDGE/src/core/script/lightmanager.js | 238 +-
.../RDGE/src/core/script/math/mat4.js | 1538 ++++-----
.../RDGE/src/core/script/math/quat.js | 500 +--
.../RDGE/src/core/script/math/vec2.js | 432 +--
.../RDGE/src/core/script/math/vec3.js | 748 ++---
.../RDGE/src/core/script/math/vec4.js | 566 ++--
.../RDGE/src/core/script/objectManager.js | 196 +-
js/helper-classes/RDGE/src/core/script/particle.js | 1594 ++++-----
.../RDGE/src/core/script/precompiled.js | 196 +-
.../RDGE/src/core/script/renderUtils.js | 792 ++---
.../RDGE/src/core/script/rendercontext.js | 578 ++--
js/helper-classes/RDGE/src/core/script/renderer.js | 3370 ++++++++++----------
.../RDGE/src/core/script/run_state.js | 718 ++---
js/helper-classes/RDGE/src/core/script/runtime.js | 446 +--
.../RDGE/src/core/script/scenegraph.js | 2006 ++++++------
.../RDGE/src/core/script/scenegraphNodes.js | 1140 +++----
.../RDGE/src/core/script/shadowLight.js | 152 +-
js/helper-classes/RDGE/src/core/script/sockets.js | 362 +--
.../RDGE/src/core/script/utilities.js | 530 +--
33 files changed, 12546 insertions(+), 12546 deletions(-)
(limited to 'js/helper-classes/RDGE/src/core')
diff --git a/js/helper-classes/RDGE/src/core/script/MeshManager.js b/js/helper-classes/RDGE/src/core/script/MeshManager.js
index 1fff19c5..eea94b74 100755
--- a/js/helper-classes/RDGE/src/core/script/MeshManager.js
+++ b/js/helper-classes/RDGE/src/core/script/MeshManager.js
@@ -1,247 +1,247 @@
-/*
-Copyright (c) 2012, Motorola Mobility, Inc
-All Rights Reserved.
-BSD License.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- - Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- - Neither the name of Motorola Mobility nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
- */
-
-// RDGE namespaces
-var RDGE = RDGE || {};
-
-RDGE.Model = function (name, mesh) {
- this.name = name;
- this.mesh = mesh;
- this.camera = null;
-};
-
-/*
- * Maintains a list of meshes to allow instancing of data
- */
-RDGE.MeshManager = function () {
- this.contentUrl = "assets_web/mesh/";
- this.modelMap = {};
- this.readyList = []; // meshes that have data ready
- this.meshesLoading = true; // indicates that no meshes have loaded or that they are still loading
- this.postMeshLoadCallbackList = [];
- this.tempSphere = null;
- this.requestCounter = 0;
-};
-
-/*
- * Pass the scene meshNode stump, loads temp object while real mesh is downloading
- */
-RDGE.MeshManager.prototype.loadMesh = function (meshStump, tempMesh) {
- // if it exists already, return the mesh requested
- if ( this.modelMap[meshStump.name] !== undefined )
- return this.modelMap[meshStump.name];
-
- meshStump.ready = false;
- meshStump.addr = this.contentUrl + meshStump.name + "_mesh.json";
- meshStump.ctxID = RDGE.globals.engine.getContext().renderer.id;
-
- // sets a temp mesh up in place of the final mesh to load
- if (!tempMesh) {
- if (this.tempSphere == null) {
- this.tempSphere = RDGE.renderUtils.makeSphere(RDGE.globals.engine.getContext().renderer.ctx, 25, 5, 5);
- }
-
- tempMesh = this.tempSphere;
- }
-
- // add the temp mesh to the map of loaded meshes
- this.modelMap[meshStump.name] = tempMesh;
-
- // update the request counter - we now have one more mesh to load
- this.requestCounter++;
-
- RDGE.requestMesh(meshStump);
-
- return null;
-};
-
-/*
- * Deletes the passed mesh from the manager as well as all renderers
- */
-RDGE.MeshManager.prototype.deleteMesh = function (name) {
- var model = this.modelMap[name];
-
- if (model) {
- RDGE.globals.engine.ctxMan.forEach(function (context) {
- context.renderer.deletePrimitive(model.primitive);
- });
-
- delete this.modelMap[name];
- }
-};
-
-RDGE.MeshManager.prototype.getModelByName = function (name) {
- return this.modelMap[name];
-};
-
-RDGE.MeshManager.prototype.getModelNames = function () {
- var names = [];
- for (var index in this.modelMap) {
- names.push(this.modelList[index].name);
- }
-
- return names;
-};
-
-
-RDGE.MeshManager.prototype.processMeshData = function () {
- var renderer = RDGE.globals.engine.getContext().renderer;
-
- // loop through meshes and load ready data
- for (var index in this.readyList) {
- // if item is ready load it
- if (this.readyList[index] && this.readyList[index].ready && renderer.id === this.readyList[index].ctxID) {
-
-
- // pop the item
- var model = this.readyList[index];
- this.readyList.splice(index, 1);
-
- var primset = new RDGE.rdgePrimitiveDefinition();
-
- primset.vertexDefinition =
- {
- // this shows two ways to map this data to an attribute
- "vert": { 'type': RDGE.rdgeConstants.VS_ELEMENT_POS, 'bufferIndex': 0, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC },
- "a_pos": { 'type': RDGE.rdgeConstants.VS_ELEMENT_POS, 'bufferIndex': 0, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC },
- "normal": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT3, 'bufferIndex': 1, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC },
- "a_norm": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT3, 'bufferIndex': 1, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC },
- "a_normal": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT3, 'bufferIndex': 1, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC },
- "texcoord": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex': 2, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC },
- "a_texcoord": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex': 2, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC },
- "a_texcoords": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex': 2, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC },
- "a_uv": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex': 2, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }
- };
-
- primset.bufferStreams =
- [
- model.root.data.coords,
- model.root.data.normals,
- model.root.data.uvs
- ];
-
- primset.streamUsage =
- [
- RDGE.rdgeConstants.BUFFER_STATIC,
- RDGE.rdgeConstants.BUFFER_STATIC,
- RDGE.rdgeConstants.BUFFER_STATIC
- ];
-
- primset.indexUsage = RDGE.rdgeConstants.BUFFER_STREAM;
-
- primset.indexBuffer = model.root.data.indices;
-
- renderer.createPrimitive( primset );
-
- model.root.primitive = primset;
-
- // generate a bounding box for this mesh
- model.root.bbox = new RDGE.box();
-
- var numCoords = model.root.data.coords.length; var idx = 0;
- while (idx < numCoords - 2) {
- var thisCoord = [model.root.data.coords[idx+0], model.root.data.coords[idx+1], model.root.data.coords[idx+2]];
- model.root.bbox.addVec3(thisCoord);
- idx += 3;
- }
-
- this.modelMap[model.root.attribs.name] = model.root;
-
- // now that the model is load reduce the request count
- this.requestCounter--;
-
- this.onLoaded(model.root.attribs.name);
- //break;
- }
-
- }
-};
-
-RDGE.MeshManager.prototype.isReady = function () {
- return this.readyList.length == 0;
-};
-
-RDGE.MeshManager.prototype.addOnLoadedCallback = function (callback) {
- this.postMeshLoadCallbackList.push(callback)
-};
-
-RDGE.MeshManager.prototype.onLoaded = function (meshName) {
- for (var index = 0 in this.postMeshLoadCallbackList) {
- // call the functions
- this.postMeshLoadCallbackList[index].onMeshLoaded(meshName);
- }
-};
-
-RDGE.MeshManager.prototype.exportJSON = function () {
- for (var m in this.modelMap) {
- this.modelMap[m].primitive.built = false;
- }
-
- return JSON.stringify(this.modelMap);
-};
-
-RDGE.MeshManager.prototype.importJSON = function (jsonMeshExport) {
- try {
- var tempModelMap = JSON.parse(jsonMeshExport);
-
- for (var m in tempModelMap) {
- if (!this.modelMap[m]) {
- this.modelMap[m] = tempModelMap[m];
- }
- }
- window.console.log("meshes imported");
- } catch (e) {
- window.console.error("error importing meshes: " + e.description );
- }
-};
-
-/*
- * global function for the mesh manager to make mesh file requests
- */
-RDGE.requestMesh = function (mesh) {
- var request = new XMLHttpRequest();
- request.mesh = mesh;
- request.onreadystatechange = function () {
- if (request.readyState == 4) {
- if (request.status == 200 || window.location.href.indexOf("http") == -1) {
- var mesh = eval("(" + request.responseText + ")"); //retrieve result as an JavaScript object
- mesh.ready = true;
- mesh.ctxID = request.mesh.ctxID;
- RDGE.globals.meshMan.readyList.push(mesh);
- }
- else {
- alert("An error has occured making the request");
- }
- }
- }
-
- request.open("GET", mesh.addr, true);
- request.send(null);
-};
+/*
+Copyright (c) 2012, Motorola Mobility, Inc
+All Rights Reserved.
+BSD License.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ - Neither the name of Motorola Mobility nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// RDGE namespaces
+var RDGE = RDGE || {};
+
+RDGE.Model = function (name, mesh) {
+ this.name = name;
+ this.mesh = mesh;
+ this.camera = null;
+};
+
+/*
+ * Maintains a list of meshes to allow instancing of data
+ */
+RDGE.MeshManager = function () {
+ this.contentUrl = "assets_web/mesh/";
+ this.modelMap = {};
+ this.readyList = []; // meshes that have data ready
+ this.meshesLoading = true; // indicates that no meshes have loaded or that they are still loading
+ this.postMeshLoadCallbackList = [];
+ this.tempSphere = null;
+ this.requestCounter = 0;
+};
+
+/*
+ * Pass the scene meshNode stump, loads temp object while real mesh is downloading
+ */
+RDGE.MeshManager.prototype.loadMesh = function (meshStump, tempMesh) {
+ // if it exists already, return the mesh requested
+ if ( this.modelMap[meshStump.name] !== undefined )
+ return this.modelMap[meshStump.name];
+
+ meshStump.ready = false;
+ meshStump.addr = this.contentUrl + meshStump.name + "_mesh.json";
+ meshStump.ctxID = RDGE.globals.engine.getContext().renderer.id;
+
+ // sets a temp mesh up in place of the final mesh to load
+ if (!tempMesh) {
+ if (this.tempSphere == null) {
+ this.tempSphere = RDGE.renderUtils.makeSphere(RDGE.globals.engine.getContext().renderer.ctx, 25, 5, 5);
+ }
+
+ tempMesh = this.tempSphere;
+ }
+
+ // add the temp mesh to the map of loaded meshes
+ this.modelMap[meshStump.name] = tempMesh;
+
+ // update the request counter - we now have one more mesh to load
+ this.requestCounter++;
+
+ RDGE.requestMesh(meshStump);
+
+ return null;
+};
+
+/*
+ * Deletes the passed mesh from the manager as well as all renderers
+ */
+RDGE.MeshManager.prototype.deleteMesh = function (name) {
+ var model = this.modelMap[name];
+
+ if (model) {
+ RDGE.globals.engine.ctxMan.forEach(function (context) {
+ context.renderer.deletePrimitive(model.primitive);
+ });
+
+ delete this.modelMap[name];
+ }
+};
+
+RDGE.MeshManager.prototype.getModelByName = function (name) {
+ return this.modelMap[name];
+};
+
+RDGE.MeshManager.prototype.getModelNames = function () {
+ var names = [];
+ for (var index in this.modelMap) {
+ names.push(this.modelList[index].name);
+ }
+
+ return names;
+};
+
+
+RDGE.MeshManager.prototype.processMeshData = function () {
+ var renderer = RDGE.globals.engine.getContext().renderer;
+
+ // loop through meshes and load ready data
+ for (var index in this.readyList) {
+ // if item is ready load it
+ if (this.readyList[index] && this.readyList[index].ready && renderer.id === this.readyList[index].ctxID) {
+
+
+ // pop the item
+ var model = this.readyList[index];
+ this.readyList.splice(index, 1);
+
+ var primset = new RDGE.rdgePrimitiveDefinition();
+
+ primset.vertexDefinition =
+ {
+ // this shows two ways to map this data to an attribute
+ "vert": { 'type': RDGE.rdgeConstants.VS_ELEMENT_POS, 'bufferIndex': 0, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC },
+ "a_pos": { 'type': RDGE.rdgeConstants.VS_ELEMENT_POS, 'bufferIndex': 0, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC },
+ "normal": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT3, 'bufferIndex': 1, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC },
+ "a_norm": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT3, 'bufferIndex': 1, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC },
+ "a_normal": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT3, 'bufferIndex': 1, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC },
+ "texcoord": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex': 2, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC },
+ "a_texcoord": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex': 2, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC },
+ "a_texcoords": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex': 2, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC },
+ "a_uv": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex': 2, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }
+ };
+
+ primset.bufferStreams =
+ [
+ model.root.data.coords,
+ model.root.data.normals,
+ model.root.data.uvs
+ ];
+
+ primset.streamUsage =
+ [
+ RDGE.rdgeConstants.BUFFER_STATIC,
+ RDGE.rdgeConstants.BUFFER_STATIC,
+ RDGE.rdgeConstants.BUFFER_STATIC
+ ];
+
+ primset.indexUsage = RDGE.rdgeConstants.BUFFER_STREAM;
+
+ primset.indexBuffer = model.root.data.indices;
+
+ renderer.createPrimitive( primset );
+
+ model.root.primitive = primset;
+
+ // generate a bounding box for this mesh
+ model.root.bbox = new RDGE.box();
+
+ var numCoords = model.root.data.coords.length; var idx = 0;
+ while (idx < numCoords - 2) {
+ var thisCoord = [model.root.data.coords[idx+0], model.root.data.coords[idx+1], model.root.data.coords[idx+2]];
+ model.root.bbox.addVec3(thisCoord);
+ idx += 3;
+ }
+
+ this.modelMap[model.root.attribs.name] = model.root;
+
+ // now that the model is load reduce the request count
+ this.requestCounter--;
+
+ this.onLoaded(model.root.attribs.name);
+ //break;
+ }
+
+ }
+};
+
+RDGE.MeshManager.prototype.isReady = function () {
+ return this.readyList.length == 0;
+};
+
+RDGE.MeshManager.prototype.addOnLoadedCallback = function (callback) {
+ this.postMeshLoadCallbackList.push(callback)
+};
+
+RDGE.MeshManager.prototype.onLoaded = function (meshName) {
+ for (var index = 0 in this.postMeshLoadCallbackList) {
+ // call the functions
+ this.postMeshLoadCallbackList[index].onMeshLoaded(meshName);
+ }
+};
+
+RDGE.MeshManager.prototype.exportJSON = function () {
+ for (var m in this.modelMap) {
+ this.modelMap[m].primitive.built = false;
+ }
+
+ return JSON.stringify(this.modelMap);
+};
+
+RDGE.MeshManager.prototype.importJSON = function (jsonMeshExport) {
+ try {
+ var tempModelMap = JSON.parse(jsonMeshExport);
+
+ for (var m in tempModelMap) {
+ if (!this.modelMap[m]) {
+ this.modelMap[m] = tempModelMap[m];
+ }
+ }
+ window.console.log("meshes imported");
+ } catch (e) {
+ window.console.error("error importing meshes: " + e.description );
+ }
+};
+
+/*
+ * global function for the mesh manager to make mesh file requests
+ */
+RDGE.requestMesh = function (mesh) {
+ var request = new XMLHttpRequest();
+ request.mesh = mesh;
+ request.onreadystatechange = function () {
+ if (request.readyState == 4) {
+ if (request.status == 200 || window.location.href.indexOf("http") == -1) {
+ var mesh = eval("(" + request.responseText + ")"); //retrieve result as an JavaScript object
+ mesh.ready = true;
+ mesh.ctxID = request.mesh.ctxID;
+ RDGE.globals.meshMan.readyList.push(mesh);
+ }
+ else {
+ alert("An error has occured making the request");
+ }
+ }
+ }
+
+ request.open("GET", mesh.addr, true);
+ request.send(null);
+};
diff --git a/js/helper-classes/RDGE/src/core/script/RenderInitProcs.js b/js/helper-classes/RDGE/src/core/script/RenderInitProcs.js
index 20b37abb..9f0a5e35 100755
--- a/js/helper-classes/RDGE/src/core/script/RenderInitProcs.js
+++ b/js/helper-classes/RDGE/src/core/script/RenderInitProcs.js
@@ -1,259 +1,259 @@
-/*
-Copyright (c) 2012, Motorola Mobility, Inc
-All Rights Reserved.
-BSD License.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- - Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- - Neither the name of Motorola Mobility nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
- */
-
-// RDGE namespaces
-var RDGE = RDGE || {};
-
-RDGE.renderInitProcDefault = function (primSet, vertexData) {
- var material = primSet.material;
-
- //push envMap tex
- material.tex.env.push(arrayPeek(material.shader).envMap);
- material.tex.envDiff.push(arrayPeek(material.shader).envDiff);
-
- gl.useProgram(arrayPeek(material.shader).shaderHandle);
-
- arrayPeek(material.renderObj).addTexture("layerMap1", 0, RDGE.UNIFORMTYPE.TEXTURE2D);
- arrayPeek(material.renderObj).addTexture("layerMap2", 1, RDGE.UNIFORMTYPE.TEXTURE2D);
- arrayPeek(material.renderObj).addTexture("colorMeMap1", 2, RDGE.UNIFORMTYPE.TEXTURE2D);
- arrayPeek(material.renderObj).addTexture("colorMeMap2", 3, RDGE.UNIFORMTYPE.TEXTURE2D);
- arrayPeek(material.renderObj).addTexture("envMap", 4, RDGE.UNIFORMTYPE.TEXTURE2D);
- arrayPeek(material.renderObj).addTexture("envDiff", 5, RDGE.UNIFORMTYPE.TEXTURE2D);
-
- arrayPeek(material.renderObj).addTexture("normalMap1", 15, RDGE.UNIFORMTYPE.TEXTURE2D);
- arrayPeek(material.renderObj).addTexture("normalMap2", 6, RDGE.UNIFORMTYPE.TEXTURE2D);
-
- arrayPeek(material.renderObj).addTexture("stickerMap0", 7, RDGE.UNIFORMTYPE.TEXTURE2D);
- arrayPeek(material.renderObj).addTexture("stickerMap1", 8, RDGE.UNIFORMTYPE.TEXTURE2D);
- arrayPeek(material.renderObj).addTexture("stickerMap2", 9, RDGE.UNIFORMTYPE.TEXTURE2D);
- arrayPeek(material.renderObj).addTexture("stickerMap3", 10, RDGE.UNIFORMTYPE.TEXTURE2D);
- arrayPeek(material.renderObj).addTexture("stickerMap4", 11, RDGE.UNIFORMTYPE.TEXTURE2D);
- arrayPeek(material.renderObj).addTexture("stickerMap5", 12, RDGE.UNIFORMTYPE.TEXTURE2D);
- arrayPeek(material.renderObj).addTexture("stickerMap6", 13, RDGE.UNIFORMTYPE.TEXTURE2D);
- arrayPeek(material.renderObj).addTexture("stickerMap7", 14, RDGE.UNIFORMTYPE.TEXTURE2D);
-
- arrayPeek(material.renderObj).addUniform("u_normalMatrix", gl.normalMatrix, RDGE.UNIFORMTYPE.MATRIX4);
- arrayPeek(material.renderObj).addUniform("u_mvMatrix", gl.mvMatrix, RDGE.UNIFORMTYPE.MATRIX4);
- arrayPeek(material.renderObj).addUniform("u_invMvMatrix", gl.invMvMatrix, RDGE.UNIFORMTYPE.MATRIX4);
-
- arrayPeek(material.renderObj).addUniform("u_stickerMatrix0", primSet.parentMesh.stickers[0], RDGE.UNIFORMTYPE.MATRIX4);
- arrayPeek(material.renderObj).addUniform("u_stickerMatrix1", primSet.parentMesh.stickers[1], RDGE.UNIFORMTYPE.MATRIX4);
- arrayPeek(material.renderObj).addUniform("u_stickerMatrix2", primSet.parentMesh.stickers[2], RDGE.UNIFORMTYPE.MATRIX4);
- arrayPeek(material.renderObj).addUniform("u_stickerMatrix3", primSet.parentMesh.stickers[3], RDGE.UNIFORMTYPE.MATRIX4);
- arrayPeek(material.renderObj).addUniform("u_stickerMatrix4", primSet.parentMesh.stickers[4], RDGE.UNIFORMTYPE.MATRIX4);
- arrayPeek(material.renderObj).addUniform("u_stickerMatrix5", primSet.parentMesh.stickers[5], RDGE.UNIFORMTYPE.MATRIX4);
- arrayPeek(material.renderObj).addUniform("u_stickerMatrix6", primSet.parentMesh.stickers[6], RDGE.UNIFORMTYPE.MATRIX4);
- arrayPeek(material.renderObj).addUniform("u_stickerMatrix7", primSet.parentMesh.stickers[7], RDGE.UNIFORMTYPE.MATRIX4);
-
- arrayPeek(material.renderObj).addUniform("u_stickerPos0", primSet.parentMesh.stickersPos[0], RDGE.UNIFORMTYPE.FLOAT3);
- arrayPeek(material.renderObj).addUniform("u_stickerPos1", primSet.parentMesh.stickersPos[1], RDGE.UNIFORMTYPE.FLOAT3);
- arrayPeek(material.renderObj).addUniform("u_stickerPos2", primSet.parentMesh.stickersPos[2], RDGE.UNIFORMTYPE.FLOAT3);
- arrayPeek(material.renderObj).addUniform("u_stickerPos3", primSet.parentMesh.stickersPos[3], RDGE.UNIFORMTYPE.FLOAT3);
- arrayPeek(material.renderObj).addUniform("u_stickerPos4", primSet.parentMesh.stickersPos[4], RDGE.UNIFORMTYPE.FLOAT3);
- arrayPeek(material.renderObj).addUniform("u_stickerPos5", primSet.parentMesh.stickersPos[5], RDGE.UNIFORMTYPE.FLOAT3);
- arrayPeek(material.renderObj).addUniform("u_stickerPos6", primSet.parentMesh.stickersPos[6], RDGE.UNIFORMTYPE.FLOAT3);
- arrayPeek(material.renderObj).addUniform("u_stickerPos7", primSet.parentMesh.stickersPos[7], RDGE.UNIFORMTYPE.FLOAT3);
-
- arrayPeek(material.renderObj).addUniform("u_projMatrix", gl.perspectiveMatrix, RDGE.UNIFORMTYPE.MATRIX4);
-
- arrayPeek(material.renderObj).addUniform("u_fillColor1", material.fillColor[0], RDGE.UNIFORMTYPE.FLOAT4);
- arrayPeek(material.renderObj).addUniform("u_fillColor2", material.fillColor[1], RDGE.UNIFORMTYPE.FLOAT4);
- arrayPeek(material.renderObj).addUniform("u_skinColor", material.fillColor[2], RDGE.UNIFORMTYPE.FLOAT4);
-
- // debug---
- vertexData.vertexObject.name = "vertexObject";
- vertexData.normalObject.name = "normalObject";
- vertexData.texCoordObject.name = "texCoordObject";
- vertexData.indexObject.name = "indexObject";
- //----------
-
- arrayPeek(material.renderObj).addBuffers(vertexData.vertexObject, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT);
- arrayPeek(material.renderObj).addBuffers(vertexData.normalObject, gl.ARRAY_BUFFER, 3, 1, gl.FLOAT);
- arrayPeek(material.renderObj).addBuffers(vertexData.texCoordObject, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT);
- arrayPeek(material.renderObj).addBuffers(vertexData.indexObject, gl.ELEMENT_ARRAY_BUFFER);
-
- gl.useProgram(null);
- // gl.console.log("Mesh Init done!");
-};
-
-RDGE.renderInitScreenQuad = function (quad, shader) {
- if (shader == undefined) {
- quad.shader = RDGE.createShader(gl, 'screenQuad_vShader', 'screenQuad_fShader', ["vert", "texcoord"]);
- }
- else {
- quad.shader = shader;
- }
-
- quad.renderObj = new RDGE.RenderObject(quad.shader);
-
- quadBuf = getScreenAlignedQuad();
-
- quad.vertBuffer = quadBuf.vertexObject;
- quad.uvBuffer = quadBuf.texCoordObject;
-
-
- quad.renderObj.addTexture("basemap", 0, RDGE.UNIFORMTYPE.TEXTURE2D);
-
- var invWidth = (RDGE.globals.width == 0.0) ? 0.0 : 1.0 / RDGE.globals.width, invHeight = (RDGE.globals.height == 0.0) ? 0.0 : 1.0 / RDGE.globals.height;
- quad.renderObj.addUniform("u_inv_viewport_width", invWidth, RDGE.UNIFORMTYPE.FLOAT);
- quad.renderObj.addUniform("u_inv_viewport_height", invHeight, RDGE.UNIFORMTYPE.FLOAT);
-
- quad.renderObj.addBuffers(quad.vertBuffer, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT);
- quad.renderObj.addBuffers(quad.uvBuffer, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT);
-};
-
-RDGE.renderInitProcDepthMap = function (renderObj) {
- renderObj.shader = g_depthShader.shaderHandle; //RDGE.createShader(gl, depthMapVShader, depthMapFShader, [ "vert", "normal", "texcoord"]);
-
- gl.useProgram(renderObj.shader);
-
- renderObj.addUniform("u_mvpLightMatrix", g_mainLight.mvpMatrix, RDGE.UNIFORMTYPE.MATRIX4);
- //renderObj.addUniform("u_mvpLightMatrixWTF", g_mainLight.mvpMatrix, RDGE.UNIFORMTYPE.MATRIX4);
- // var uni = gl.getUniformLocation(renderObj.shader, "u_mvpLightMatrixWTF");
- // renderObj.addUniform("u_WTF1", g_lightMat[0], RDGE.UNIFORMTYPE.FLOAT4);
- // renderObj.addUniform("u_WTF2", g_lightMat[1], RDGE.UNIFORMTYPE.FLOAT4);
- // renderObj.addUniform("u_WTF3", g_lightMat[2], RDGE.UNIFORMTYPE.FLOAT4);
- // renderObj.addUniform("u_WTF4", g_lightMat[3], RDGE.UNIFORMTYPE.FLOAT4);
- //
- // since the uniform data references should not change we can just bind one time
- renderObj.bindUniforms();
-
- gl.useProgram(null);
-};
-
-RDGE.renderInitShadowReceiver = function (primSet, vertexData) {
- // setup passes
- primSet.shadowTarget = g_texMan.loadRenderTarget("shadowTarget", 256, 256);
- primSet.shadowTargetFinal = g_texMan.loadRenderTarget("shadowTargetFinal", 256, 256);
- primSet.screenQuad = new RDGE.ScreenQuad(primSet.shadowTargetFinal);
- primSet.screenQuad.initialize(RDGE.renderInitRadialBlur);
-
- // set the target as the shadow to get projcetd
- primSet.parentMesh.shadowToProject = primSet.shadowTarget;
-
- //mainSceneQuad = new RDGE.ScreenQuad(primSet.shadowTarget);
- //mainSceneQuad.initialize(renderInitScreenQuad);
-
- var material = primSet.material;
-
- //push envMap tex
- material.tex.env.push(arrayPeek(material.shader).envMap);
- material.tex.envDiff.push(arrayPeek(material.shader).envDiff);
-
- gl.useProgram(arrayPeek(material.shader).shaderHandle);
-
- arrayPeek(material.renderObj).addTexture("shadowMap", 0, RDGE.UNIFORMTYPE.TEXTURE2D);
- arrayPeek(material.renderObj).addUniform("u_mvMatrix", gl.mvMatrix, RDGE.UNIFORMTYPE.MATRIX4);
-
- arrayPeek(material.renderObj).addUniform("u_projMatrix", gl.perspectiveMatrix, RDGE.UNIFORMTYPE.MATRIX4);
-
- arrayPeek(material.renderObj).addUniform("u_shadowBiasMatrix", g_mainLight.shadowMatrix, RDGE.UNIFORMTYPE.MATRIX4);
- arrayPeek(material.renderObj).addUniform("u_vShadowLight", g_mainLight.view, RDGE.UNIFORMTYPE.MATRIX4);
-
-
- // debug---
- vertexData.vertexObject.name = "vertexObject";
- vertexData.normalObject.name = "normalObject";
- vertexData.texCoordObject.name = "texCoordObject";
- vertexData.indexObject.name = "indexObject";
- //----------
-
- arrayPeek(material.renderObj).addBuffers(vertexData.vertexObject, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT);
- arrayPeek(material.renderObj).addBuffers(vertexData.normalObject, gl.ARRAY_BUFFER, 3, 1, gl.FLOAT);
- arrayPeek(material.renderObj).addBuffers(vertexData.texCoordObject, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT);
- arrayPeek(material.renderObj).addBuffers(vertexData.indexObject, gl.ELEMENT_ARRAY_BUFFER);
-
- gl.useProgram(null);
-
- //RDGE.renderInitShadowProjection(primSet, vertexData);
-};
-
-
-RDGE.renderInitShadowProjection = function (primSet, vertexData) {
- var material = primSet.material;
-
- //push envMap tex
- //material.tex.env.push(arrayPeek(material.shader).envMap);
- //material.tex.envDiff.push(arrayPeek(material.shader).envDiff);
-
- gl.useProgram(arrayPeek(material.shader).shaderHandle);
-
- arrayPeek(material.renderObj).addTexture("shadowMap", 0, RDGE.UNIFORMTYPE.TEXTURE2D);
- arrayPeek(material.renderObj).addUniform("u_mvMatrix", gl.mvMatrix, RDGE.UNIFORMTYPE.MATRIX4);
-
- arrayPeek(material.renderObj).addUniform("u_projMatrix", gl.perspectiveMatrix, RDGE.UNIFORMTYPE.MATRIX4);
-
- arrayPeek(material.renderObj).addUniform("u_shadowBiasMatrix", g_mainLight.shadowMatrix, RDGE.UNIFORMTYPE.MATRIX4);
- arrayPeek(material.renderObj).addUniform("u_vShadowLight", g_mainLight.view, RDGE.UNIFORMTYPE.MATRIX4);
-
-
- // debug---
- vertexData.vertexObject.name = "vertexObject";
- vertexData.normalObject.name = "normalObject";
- vertexData.texCoordObject.name = "texCoordObject";
- vertexData.indexObject.name = "indexObject";
- //----------
-
- arrayPeek(material.renderObj).addBuffers(vertexData.vertexObject, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT);
- arrayPeek(material.renderObj).addBuffers(vertexData.normalObject, gl.ARRAY_BUFFER, 3, 1, gl.FLOAT);
- arrayPeek(material.renderObj).addBuffers(vertexData.texCoordObject, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT);
- arrayPeek(material.renderObj).addBuffers(vertexData.indexObject, gl.ELEMENT_ARRAY_BUFFER);
-
-
- gl.useProgram(null);
-};
-
-RDGE.renderInitRadialBlur = function(quad, shader) {
- if (shader == undefined) {
- quad.shader = RDGE.createShader(gl, 'radialBlur_vshader', 'radialBlur_fshader', ["vert", "texcoord"]);
- }
- else {
- quad.shader = shader;
- }
-
- quad.renderObj = new RDGE.RenderObject(quad.shader);
-
- quadBuf = getScreenAlignedQuad();
-
- quad.vertBuffer = quadBuf.vertexObject;
- quad.uvBuffer = quadBuf.texCoordObject;
-
-
- quad.renderObj.addTexture("basemap", 0, RDGE.UNIFORMTYPE.TEXTURE2D);
-
- quad.renderObj.addUniform("u_inv_viewport_width", 1.0 / RDGE.globals.width, RDGE.UNIFORMTYPE.FLOAT);
- quad.renderObj.addUniform("u_inv_viewport_height", 1.0 / RDGE.globals.height, RDGE.UNIFORMTYPE.FLOAT);
- quad.renderObj.addUniform("u_sampRadius", 5.0, RDGE.UNIFORMTYPE.FLOAT);
- quad.renderObj.addUniform("u_numSamples", 16, RDGE.UNIFORMTYPE.INT);
- quad.renderObj.addUniform("u_mapSize", 256.0, RDGE.UNIFORMTYPE.FLOAT);
-
- quad.renderObj.addBuffers(quad.vertBuffer, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT);
- quad.renderObj.addBuffers(quad.uvBuffer, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT);
-};
+/*
+Copyright (c) 2012, Motorola Mobility, Inc
+All Rights Reserved.
+BSD License.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ - Neither the name of Motorola Mobility nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// RDGE namespaces
+var RDGE = RDGE || {};
+
+RDGE.renderInitProcDefault = function (primSet, vertexData) {
+ var material = primSet.material;
+
+ //push envMap tex
+ material.tex.env.push(arrayPeek(material.shader).envMap);
+ material.tex.envDiff.push(arrayPeek(material.shader).envDiff);
+
+ gl.useProgram(arrayPeek(material.shader).shaderHandle);
+
+ arrayPeek(material.renderObj).addTexture("layerMap1", 0, RDGE.UNIFORMTYPE.TEXTURE2D);
+ arrayPeek(material.renderObj).addTexture("layerMap2", 1, RDGE.UNIFORMTYPE.TEXTURE2D);
+ arrayPeek(material.renderObj).addTexture("colorMeMap1", 2, RDGE.UNIFORMTYPE.TEXTURE2D);
+ arrayPeek(material.renderObj).addTexture("colorMeMap2", 3, RDGE.UNIFORMTYPE.TEXTURE2D);
+ arrayPeek(material.renderObj).addTexture("envMap", 4, RDGE.UNIFORMTYPE.TEXTURE2D);
+ arrayPeek(material.renderObj).addTexture("envDiff", 5, RDGE.UNIFORMTYPE.TEXTURE2D);
+
+ arrayPeek(material.renderObj).addTexture("normalMap1", 15, RDGE.UNIFORMTYPE.TEXTURE2D);
+ arrayPeek(material.renderObj).addTexture("normalMap2", 6, RDGE.UNIFORMTYPE.TEXTURE2D);
+
+ arrayPeek(material.renderObj).addTexture("stickerMap0", 7, RDGE.UNIFORMTYPE.TEXTURE2D);
+ arrayPeek(material.renderObj).addTexture("stickerMap1", 8, RDGE.UNIFORMTYPE.TEXTURE2D);
+ arrayPeek(material.renderObj).addTexture("stickerMap2", 9, RDGE.UNIFORMTYPE.TEXTURE2D);
+ arrayPeek(material.renderObj).addTexture("stickerMap3", 10, RDGE.UNIFORMTYPE.TEXTURE2D);
+ arrayPeek(material.renderObj).addTexture("stickerMap4", 11, RDGE.UNIFORMTYPE.TEXTURE2D);
+ arrayPeek(material.renderObj).addTexture("stickerMap5", 12, RDGE.UNIFORMTYPE.TEXTURE2D);
+ arrayPeek(material.renderObj).addTexture("stickerMap6", 13, RDGE.UNIFORMTYPE.TEXTURE2D);
+ arrayPeek(material.renderObj).addTexture("stickerMap7", 14, RDGE.UNIFORMTYPE.TEXTURE2D);
+
+ arrayPeek(material.renderObj).addUniform("u_normalMatrix", gl.normalMatrix, RDGE.UNIFORMTYPE.MATRIX4);
+ arrayPeek(material.renderObj).addUniform("u_mvMatrix", gl.mvMatrix, RDGE.UNIFORMTYPE.MATRIX4);
+ arrayPeek(material.renderObj).addUniform("u_invMvMatrix", gl.invMvMatrix, RDGE.UNIFORMTYPE.MATRIX4);
+
+ arrayPeek(material.renderObj).addUniform("u_stickerMatrix0", primSet.parentMesh.stickers[0], RDGE.UNIFORMTYPE.MATRIX4);
+ arrayPeek(material.renderObj).addUniform("u_stickerMatrix1", primSet.parentMesh.stickers[1], RDGE.UNIFORMTYPE.MATRIX4);
+ arrayPeek(material.renderObj).addUniform("u_stickerMatrix2", primSet.parentMesh.stickers[2], RDGE.UNIFORMTYPE.MATRIX4);
+ arrayPeek(material.renderObj).addUniform("u_stickerMatrix3", primSet.parentMesh.stickers[3], RDGE.UNIFORMTYPE.MATRIX4);
+ arrayPeek(material.renderObj).addUniform("u_stickerMatrix4", primSet.parentMesh.stickers[4], RDGE.UNIFORMTYPE.MATRIX4);
+ arrayPeek(material.renderObj).addUniform("u_stickerMatrix5", primSet.parentMesh.stickers[5], RDGE.UNIFORMTYPE.MATRIX4);
+ arrayPeek(material.renderObj).addUniform("u_stickerMatrix6", primSet.parentMesh.stickers[6], RDGE.UNIFORMTYPE.MATRIX4);
+ arrayPeek(material.renderObj).addUniform("u_stickerMatrix7", primSet.parentMesh.stickers[7], RDGE.UNIFORMTYPE.MATRIX4);
+
+ arrayPeek(material.renderObj).addUniform("u_stickerPos0", primSet.parentMesh.stickersPos[0], RDGE.UNIFORMTYPE.FLOAT3);
+ arrayPeek(material.renderObj).addUniform("u_stickerPos1", primSet.parentMesh.stickersPos[1], RDGE.UNIFORMTYPE.FLOAT3);
+ arrayPeek(material.renderObj).addUniform("u_stickerPos2", primSet.parentMesh.stickersPos[2], RDGE.UNIFORMTYPE.FLOAT3);
+ arrayPeek(material.renderObj).addUniform("u_stickerPos3", primSet.parentMesh.stickersPos[3], RDGE.UNIFORMTYPE.FLOAT3);
+ arrayPeek(material.renderObj).addUniform("u_stickerPos4", primSet.parentMesh.stickersPos[4], RDGE.UNIFORMTYPE.FLOAT3);
+ arrayPeek(material.renderObj).addUniform("u_stickerPos5", primSet.parentMesh.stickersPos[5], RDGE.UNIFORMTYPE.FLOAT3);
+ arrayPeek(material.renderObj).addUniform("u_stickerPos6", primSet.parentMesh.stickersPos[6], RDGE.UNIFORMTYPE.FLOAT3);
+ arrayPeek(material.renderObj).addUniform("u_stickerPos7", primSet.parentMesh.stickersPos[7], RDGE.UNIFORMTYPE.FLOAT3);
+
+ arrayPeek(material.renderObj).addUniform("u_projMatrix", gl.perspectiveMatrix, RDGE.UNIFORMTYPE.MATRIX4);
+
+ arrayPeek(material.renderObj).addUniform("u_fillColor1", material.fillColor[0], RDGE.UNIFORMTYPE.FLOAT4);
+ arrayPeek(material.renderObj).addUniform("u_fillColor2", material.fillColor[1], RDGE.UNIFORMTYPE.FLOAT4);
+ arrayPeek(material.renderObj).addUniform("u_skinColor", material.fillColor[2], RDGE.UNIFORMTYPE.FLOAT4);
+
+ // debug---
+ vertexData.vertexObject.name = "vertexObject";
+ vertexData.normalObject.name = "normalObject";
+ vertexData.texCoordObject.name = "texCoordObject";
+ vertexData.indexObject.name = "indexObject";
+ //----------
+
+ arrayPeek(material.renderObj).addBuffers(vertexData.vertexObject, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT);
+ arrayPeek(material.renderObj).addBuffers(vertexData.normalObject, gl.ARRAY_BUFFER, 3, 1, gl.FLOAT);
+ arrayPeek(material.renderObj).addBuffers(vertexData.texCoordObject, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT);
+ arrayPeek(material.renderObj).addBuffers(vertexData.indexObject, gl.ELEMENT_ARRAY_BUFFER);
+
+ gl.useProgram(null);
+ // gl.console.log("Mesh Init done!");
+};
+
+RDGE.renderInitScreenQuad = function (quad, shader) {
+ if (shader == undefined) {
+ quad.shader = RDGE.createShader(gl, 'screenQuad_vShader', 'screenQuad_fShader', ["vert", "texcoord"]);
+ }
+ else {
+ quad.shader = shader;
+ }
+
+ quad.renderObj = new RDGE.RenderObject(quad.shader);
+
+ quadBuf = getScreenAlignedQuad();
+
+ quad.vertBuffer = quadBuf.vertexObject;
+ quad.uvBuffer = quadBuf.texCoordObject;
+
+
+ quad.renderObj.addTexture("basemap", 0, RDGE.UNIFORMTYPE.TEXTURE2D);
+
+ var invWidth = (RDGE.globals.width == 0.0) ? 0.0 : 1.0 / RDGE.globals.width, invHeight = (RDGE.globals.height == 0.0) ? 0.0 : 1.0 / RDGE.globals.height;
+ quad.renderObj.addUniform("u_inv_viewport_width", invWidth, RDGE.UNIFORMTYPE.FLOAT);
+ quad.renderObj.addUniform("u_inv_viewport_height", invHeight, RDGE.UNIFORMTYPE.FLOAT);
+
+ quad.renderObj.addBuffers(quad.vertBuffer, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT);
+ quad.renderObj.addBuffers(quad.uvBuffer, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT);
+};
+
+RDGE.renderInitProcDepthMap = function (renderObj) {
+ renderObj.shader = g_depthShader.shaderHandle; //RDGE.createShader(gl, depthMapVShader, depthMapFShader, [ "vert", "normal", "texcoord"]);
+
+ gl.useProgram(renderObj.shader);
+
+ renderObj.addUniform("u_mvpLightMatrix", g_mainLight.mvpMatrix, RDGE.UNIFORMTYPE.MATRIX4);
+ //renderObj.addUniform("u_mvpLightMatrixWTF", g_mainLight.mvpMatrix, RDGE.UNIFORMTYPE.MATRIX4);
+ // var uni = gl.getUniformLocation(renderObj.shader, "u_mvpLightMatrixWTF");
+ // renderObj.addUniform("u_WTF1", g_lightMat[0], RDGE.UNIFORMTYPE.FLOAT4);
+ // renderObj.addUniform("u_WTF2", g_lightMat[1], RDGE.UNIFORMTYPE.FLOAT4);
+ // renderObj.addUniform("u_WTF3", g_lightMat[2], RDGE.UNIFORMTYPE.FLOAT4);
+ // renderObj.addUniform("u_WTF4", g_lightMat[3], RDGE.UNIFORMTYPE.FLOAT4);
+ //
+ // since the uniform data references should not change we can just bind one time
+ renderObj.bindUniforms();
+
+ gl.useProgram(null);
+};
+
+RDGE.renderInitShadowReceiver = function (primSet, vertexData) {
+ // setup passes
+ primSet.shadowTarget = g_texMan.loadRenderTarget("shadowTarget", 256, 256);
+ primSet.shadowTargetFinal = g_texMan.loadRenderTarget("shadowTargetFinal", 256, 256);
+ primSet.screenQuad = new RDGE.ScreenQuad(primSet.shadowTargetFinal);
+ primSet.screenQuad.initialize(RDGE.renderInitRadialBlur);
+
+ // set the target as the shadow to get projcetd
+ primSet.parentMesh.shadowToProject = primSet.shadowTarget;
+
+ //mainSceneQuad = new RDGE.ScreenQuad(primSet.shadowTarget);
+ //mainSceneQuad.initialize(renderInitScreenQuad);
+
+ var material = primSet.material;
+
+ //push envMap tex
+ material.tex.env.push(arrayPeek(material.shader).envMap);
+ material.tex.envDiff.push(arrayPeek(material.shader).envDiff);
+
+ gl.useProgram(arrayPeek(material.shader).shaderHandle);
+
+ arrayPeek(material.renderObj).addTexture("shadowMap", 0, RDGE.UNIFORMTYPE.TEXTURE2D);
+ arrayPeek(material.renderObj).addUniform("u_mvMatrix", gl.mvMatrix, RDGE.UNIFORMTYPE.MATRIX4);
+
+ arrayPeek(material.renderObj).addUniform("u_projMatrix", gl.perspectiveMatrix, RDGE.UNIFORMTYPE.MATRIX4);
+
+ arrayPeek(material.renderObj).addUniform("u_shadowBiasMatrix", g_mainLight.shadowMatrix, RDGE.UNIFORMTYPE.MATRIX4);
+ arrayPeek(material.renderObj).addUniform("u_vShadowLight", g_mainLight.view, RDGE.UNIFORMTYPE.MATRIX4);
+
+
+ // debug---
+ vertexData.vertexObject.name = "vertexObject";
+ vertexData.normalObject.name = "normalObject";
+ vertexData.texCoordObject.name = "texCoordObject";
+ vertexData.indexObject.name = "indexObject";
+ //----------
+
+ arrayPeek(material.renderObj).addBuffers(vertexData.vertexObject, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT);
+ arrayPeek(material.renderObj).addBuffers(vertexData.normalObject, gl.ARRAY_BUFFER, 3, 1, gl.FLOAT);
+ arrayPeek(material.renderObj).addBuffers(vertexData.texCoordObject, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT);
+ arrayPeek(material.renderObj).addBuffers(vertexData.indexObject, gl.ELEMENT_ARRAY_BUFFER);
+
+ gl.useProgram(null);
+
+ //RDGE.renderInitShadowProjection(primSet, vertexData);
+};
+
+
+RDGE.renderInitShadowProjection = function (primSet, vertexData) {
+ var material = primSet.material;
+
+ //push envMap tex
+ //material.tex.env.push(arrayPeek(material.shader).envMap);
+ //material.tex.envDiff.push(arrayPeek(material.shader).envDiff);
+
+ gl.useProgram(arrayPeek(material.shader).shaderHandle);
+
+ arrayPeek(material.renderObj).addTexture("shadowMap", 0, RDGE.UNIFORMTYPE.TEXTURE2D);
+ arrayPeek(material.renderObj).addUniform("u_mvMatrix", gl.mvMatrix, RDGE.UNIFORMTYPE.MATRIX4);
+
+ arrayPeek(material.renderObj).addUniform("u_projMatrix", gl.perspectiveMatrix, RDGE.UNIFORMTYPE.MATRIX4);
+
+ arrayPeek(material.renderObj).addUniform("u_shadowBiasMatrix", g_mainLight.shadowMatrix, RDGE.UNIFORMTYPE.MATRIX4);
+ arrayPeek(material.renderObj).addUniform("u_vShadowLight", g_mainLight.view, RDGE.UNIFORMTYPE.MATRIX4);
+
+
+ // debug---
+ vertexData.vertexObject.name = "vertexObject";
+ vertexData.normalObject.name = "normalObject";
+ vertexData.texCoordObject.name = "texCoordObject";
+ vertexData.indexObject.name = "indexObject";
+ //----------
+
+ arrayPeek(material.renderObj).addBuffers(vertexData.vertexObject, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT);
+ arrayPeek(material.renderObj).addBuffers(vertexData.normalObject, gl.ARRAY_BUFFER, 3, 1, gl.FLOAT);
+ arrayPeek(material.renderObj).addBuffers(vertexData.texCoordObject, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT);
+ arrayPeek(material.renderObj).addBuffers(vertexData.indexObject, gl.ELEMENT_ARRAY_BUFFER);
+
+
+ gl.useProgram(null);
+};
+
+RDGE.renderInitRadialBlur = function(quad, shader) {
+ if (shader == undefined) {
+ quad.shader = RDGE.createShader(gl, 'radialBlur_vshader', 'radialBlur_fshader', ["vert", "texcoord"]);
+ }
+ else {
+ quad.shader = shader;
+ }
+
+ quad.renderObj = new RDGE.RenderObject(quad.shader);
+
+ quadBuf = getScreenAlignedQuad();
+
+ quad.vertBuffer = quadBuf.vertexObject;
+ quad.uvBuffer = quadBuf.texCoordObject;
+
+
+ quad.renderObj.addTexture("basemap", 0, RDGE.UNIFORMTYPE.TEXTURE2D);
+
+ quad.renderObj.addUniform("u_inv_viewport_width", 1.0 / RDGE.globals.width, RDGE.UNIFORMTYPE.FLOAT);
+ quad.renderObj.addUniform("u_inv_viewport_height", 1.0 / RDGE.globals.height, RDGE.UNIFORMTYPE.FLOAT);
+ quad.renderObj.addUniform("u_sampRadius", 5.0, RDGE.UNIFORMTYPE.FLOAT);
+ quad.renderObj.addUniform("u_numSamples", 16, RDGE.UNIFORMTYPE.INT);
+ quad.renderObj.addUniform("u_mapSize", 256.0, RDGE.UNIFORMTYPE.FLOAT);
+
+ quad.renderObj.addBuffers(quad.vertBuffer, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT);
+ quad.renderObj.addBuffers(quad.uvBuffer, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT);
+};
diff --git a/js/helper-classes/RDGE/src/core/script/RenderProcs.js b/js/helper-classes/RDGE/src/core/script/RenderProcs.js
index 1583ea14..1f0d3b3c 100755
--- a/js/helper-classes/RDGE/src/core/script/RenderProcs.js
+++ b/js/helper-classes/RDGE/src/core/script/RenderProcs.js
@@ -1,511 +1,511 @@
-/*
-Copyright (c) 2012, Motorola Mobility, Inc
-All Rights Reserved.
-BSD License.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- - Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- - Neither the name of Motorola Mobility nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
- */
-
-// RDGE namespaces
-var RDGE = RDGE || {};
-
-/**
-* supported uniform types
-*/
-RDGE.UNIFORMTYPE = function () {
- this.INT = 0x3F0;
- this.FLOAT = 0x3E8;
- this.FLOAT2 = 0x3E9;
- this.FLOAT3 = 0x3EA;
- this.FLOAT4 = 0x3EB;
- this.MATRIX3 = 0x3EC;
- this.MATRIX4 = 0x3ED;
- this.TEXTURE2D = 0x3EE;
- this.TEXTURECUBE = 0x3EF;
-};
-
-/**
-* RDGE.RenderObject - contains references to all the data need to render, including vertex buffers, uniform handles, and matrices
-* @param shaderHandle
-*/
-RDGE.RenderObject = function (shaderHandle) {
- this.shader = shaderHandle;
- this.world = null;
- this.bindings = new RDGE.ShaderData();
- this.initRenderProc = null;
- this.renderProc = null;
- this.postRenderProc = null;
-};
-
-/**
-* Adds a uniform to the render object to bound during render
-* @param name - name of the uniform
-* @param value - reference to value that will get bound (will be referenced from now on, don't delete the ref)
-* @param type - type of uniform, use RDGE.UNIFORMTYPE
-*/
-RDGE.RenderObject.prototype.addUniform = function (name, value, type) {
- var uniform = RDGE.globals.gl.getUniformLocation(this.shader, name);
- if (uniform) {
- uniform.debugName = name;
- this.bindings.uniforms.push(new RDGE.UniformPair(uniform, value, type));
- }
- /*
- else
- {
- gl.console.log("ERROR: uniform - " + name + " not found!");
- }
- */
-};
-
-/**
-* Adds a uniform to the render object to bound during render
-* @param name - name of the uniform
-* @param value - reference to value that will get bound (will be referenced from now on, don't delete the ref)
-* @param type - type of uniform, use RDGE.UNIFORMTYPE
-*/
-RDGE.RenderObject.prototype.addUniformArray = function (name, value, type, size) {
- var uniform = RDGE.globals.gl.getUniformLocation(this.shader, name);
- if (uniform) {
- for (var index = 0; index < size; index++) {
- uniform.debugName = name + index;
- this.bindings.uniforms.push(new RDGE.UniformPair(uniform, value[index], type));
- uniform += value[index].length;
- value++;
- }
- }
- /*
- else
- {
- gl.console.log("ERROR: uniform - " + name + " not found!");
- }*/
-};
-
-/**
-* Add texture to uniform
-* @param name - handle to the texture
-* @param unit - texture slot to use
-* @param type - RDGE.UNIFORMTYPE.TEXTURE2D or TEXTURE2D.TEXTURECUBE
-*/
-RDGE.RenderObject.prototype.addTexture = function (name, unit, type) {
- var uniform = RDGE.globals.gl.getUniformLocation(this.shader, name);
- if (uniform) {
- this.bindings.textures.push(new RDGE.TexUniform(uniform, unit, type));
- }
- /*
- else
- {
- gl.console.log("ERROR: texture uniform - " + name + " not found!");
- }
- */
-};
-
-/**
-* Adds a vertex buffer to the render object
-* @param buffer - buffer to use
-* @param glBufferType - type of buffer i.e. gl.ARRAY_BUFFER
-* @param attribSize - if using attrib the size of an element (3 for vec3)
-* @param attribIndex - the index slot the attrib goes in
-* @param glAttribType - type of the attrib i.e. gl.FLOAT
-*/
-RDGE.RenderObject.prototype.addBuffers = function (buffer, glBufferType, attribSize, attribIndex, glAttribType) {
- //gl.useProgram(this.shader);
- if (attribSize == undefined || attribIndex == undefined || glAttribType == undefined ||
- attribSize == null || attribIndex == null || glAttribType == null) {
- this.bindings.buffers.push(new RDGE.BufferAttrib(buffer, glBufferType, null, null, null));
- }
- else {
- this.bindings.buffers.push(new RDGE.BufferAttrib(buffer, glBufferType, attribSize, attribIndex, glAttribType));
- }
- //gl.useProgram(null);
-};
-
-/**
-* bind the matrices, vertices and floats to shader uniforms
-*/
-RDGE.RenderObject.prototype.bindUniforms = function () {
- for (var uniIndex = 0; uniIndex < this.bindings.uniforms.length; uniIndex++) {
- var bind = this.bindings.uniforms[uniIndex];
- switch (bind.type) {
- case RDGE.UNIFORMTYPE.INT:
- RDGE.globals.gl.uniform1i(bind.uniform, bind.value);
- break;
- case RDGE.UNIFORMTYPE.FLOAT:
- RDGE.globals.gl.uniform1f(bind.uniform, bind.value);
- break;
- case RDGE.UNIFORMTYPE.FLOAT2:
- RDGE.globals.gl.uniform2fv(bind.uniform, bind.value);
- break;
- case RDGE.UNIFORMTYPE.FLOAT3:
- RDGE.globals.gl.uniform3fv(bind.uniform, bind.value);
- break;
- case RDGE.UNIFORMTYPE.FLOAT4:
- RDGE.globals.gl.uniform4fv(bind.uniform, bind.value);
- break;
- case RDGE.UNIFORMTYPE.MATRIX3:
- RDGE.globals.gl.uniformMatrix3fv(bind.uniform, false, bind.value);
- break;
- case RDGE.UNIFORMTYPE.MATRIX4:
- RDGE.globals.gl.uniformMatrix4fv(bind.uniform, false, bind.value);
- break;
- default:
- // gl.console.log("RDGE.RenderObject: trying to bind unknown texture type");
- break;
- }
- }
-};
-
-/**
-* binds the texture uniform to texture slots
-*/
-RDGE.RenderObject.prototype.bindTextures = function () {
- for (var uniIndex = 0; uniIndex < this.bindings.textures.length; uniIndex++) {
- var bind = this.bindings.textures[uniIndex];
- var error = 0;
- switch (bind.type) {
- case RDGE.UNIFORMTYPE.TEXTURE2D:
- RDGE.globals.gl.activeTexture(RDGE.globals.gl.TEXTURE0 + bind.unit);
- RDGE.globals.gl.uniform1i(bind.uniform, bind.unit);
- break;
- case RDGE.UNIFORMTYPE.TEXTURECUBE:
- RDGE.globals.gl.activeTexture(RDGE.globals.gl.TEXTURE0 + bind.unit);
- RDGE.globals.gl.uniform1i(bind.uniform, bind.unit);
- break;
- default:
- // gl.console.log("RDGE.RenderObject: trying to bind unknown texture type");
- break;
- }
- }
-};
-
-/**
-* Binds all buffers and enables any vertexAttribs
-*/
-RDGE.RenderObject.prototype.bindBuffers = function () {
- for (var bufIndex = 0; bufIndex < this.bindings.buffers.length; bufIndex++) {
- var bind = this.bindings.buffers[bufIndex];
- RDGE.globals.gl.bindBuffer(bind.glBufferType, bind.buffer);
-
- if (bind.glAttribType != null) {
- // enable the attribute and point buffer to it
- RDGE.globals.gl.enableVertexAttribArray(bind.attribIndex);
-
- RDGE.globals.gl.vertexAttribPointer(bind.attribIndex, bind.attribSize, bind.glAttribType, false, 0, 0);
- }
- }
-};
-
-RDGE.RenderObject.prototype.unBindBuffers = function () {
- for (var bufIndex = 0; bufIndex < this.bindings.buffers.length; bufIndex++) {
- var bind = this.bindings.buffers[bufIndex];
-
- if (bind.glAttribType != null) {
- // enable the attribute and point buffer to it
- RDGE.globals.gl.disableVertexAttribArray(bind.attribIndex);
- }
-
- RDGE.globals.gl.bindBuffer(bind.glBufferType, null);
- }
-};
-
-RDGE.RenderObject.prototype.initialize = function (initRenderProc) {
- initRenderProc(this);
-};
-
-RDGE.RenderObject.prototype.clear = function () {
- this.world = RDGE.mat4.identity();
- this.bindings = new RDGE.ShaderData();
-};
-
-/***
-* Shader data proto
-*/
-RDGE.ShaderData = function () {
- this.uniforms = [];
- this.textures = [];
- this.buffers = [];
-};
-
-/***
-* Structure to contain reference data for binding to during render
-*/
-RDGE.UniformPair = function (uniform, value, type) {
- this.uniform = uniform;
- this.value = value;
- this.type = type;
-};
-
-RDGE.TexUniform = function (uniform, unit, type) {
- this.uniform = uniform;
- this.unit = unit;
- this.type = type;
-};
-
-RDGE.BufferAttrib = function (buffer, glBufferType, attribSize, attribIndex, glAttribType) {
- // buffer data
- this.buffer = buffer;
- this.glBufferType = glBufferType;
-
- // attribute data (can be null)
- this.attribSize = attribSize;
- this.glAttribType = glAttribType;
- this.attribIndex = attribIndex;
-};
-
-RDGE.setActiveTexture = function (id, texture) {
- RDGE.globals.gl.activeTexture(id);
- RDGE.globals.gl.bindTexture(RDGE.globals.gl.TEXTURE_2D, texture);
-};
-
-RDGE.renderProcDefault = function (primSet) {
- //gl.disable(gl.DEPTH_TEST);
- //gl.disable(gl.CULL_FACE);
- var activeCam = RDGE.globals.cameraManager.getActiveCamera();
- RDGE.globals.gl.mvMatrix = activeCam.view;
- RDGE.globals.gl.mvMatrix = RDGE.mat4.mul(RDGE.globals.gl.mvMatrix, primSet.parentMesh.world);
- RDGE.globals.gl.invMvMatrix = RDGE.mat4.inverse(RDGE.globals.gl.mvMatrix);
- RDGE.globals.gl.normalMatrix = RDGE.mat4.transpose(RDGE.globals.gl.invMvMatrix);
-
- // update shadow light MV matrix
- RDGE.globals.gl.useProgram(arrayPeek(primSet.material.shader).shaderHandle);
- // Bind the texture
-
- RDGE.globals.gl.activeTexture(RDGE.globals.gl.TEXTURE0);
- RDGE.globals.gl.bindTexture(RDGE.globals.gl.TEXTURE_2D, arrayPeek(primSet.material.tex.set1).diff);
-
- RDGE.globals.gl.activeTexture(RDGE.globals.gl.TEXTURE1);
- RDGE.globals.gl.bindTexture(RDGE.globals.gl.TEXTURE_2D, arrayPeek(primSet.material.tex.set2).diff);
-
- RDGE.globals.gl.activeTexture(RDGE.globals.gl.TEXTURE2);
- RDGE.globals.gl.bindTexture(RDGE.globals.gl.TEXTURE_2D, arrayPeek(primSet.material.tex.set1).spec);
-
- RDGE.globals.gl.activeTexture(RDGE.globals.gl.TEXTURE3);
- RDGE.globals.gl.bindTexture(RDGE.globals.gl.TEXTURE_2D, arrayPeek(primSet.material.tex.set2).spec);
-
- RDGE.globals.gl.activeTexture(RDGE.globals.gl.TEXTURE4);
- RDGE.globals.gl.bindTexture(RDGE.globals.gl.TEXTURE_2D, arrayPeek(primSet.material.tex.env));
-
- RDGE.globals.gl.activeTexture(RDGE.globals.gl.TEXTURE5);
- RDGE.globals.gl.bindTexture(RDGE.globals.gl.TEXTURE_2D, arrayPeek(primSet.material.tex.envDiff));
-
- // stickers
- RDGE.setActiveTexture(RDGE.globals.gl.TEXTURE7, RDGE.globals.cam.stickerTexture[0]);
- RDGE.setActiveTexture(RDGE.globals.gl.TEXTURE8, RDGE.globals.cam.stickerTexture[1]);
- RDGE.setActiveTexture(RDGE.globals.gl.TEXTURE9, RDGE.globals.cam.stickerTexture[2]);
- RDGE.setActiveTexture(RDGE.globals.gl.TEXTURE10, RDGE.globals.cam.stickerTexture[3]);
- RDGE.setActiveTexture(RDGE.globals.gl.TEXTURE11, RDGE.globals.cam.stickerTexture[4]);
- RDGE.setActiveTexture(RDGE.globals.gl.TEXTURE12, RDGE.globals.cam.stickerTexture[5]);
- RDGE.setActiveTexture(RDGE.globals.gl.TEXTURE13, RDGE.globals.cam.stickerTexture[6]);
- RDGE.setActiveTexture(RDGE.globals.gl.TEXTURE14, RDGE.globals.cam.stickerTexture[7]);
-
- // copy current cams matrix
- for (var i = 0; i < 8; i++) {
- primSet.parentMesh.stickers[i].load(RDGE.globals.cam.stickers[i]);
- primSet.parentMesh.stickersPos[i].setvec(RDGE.globals.cam.stickersPos[i]);
- }
- RDGE.setActiveTexture(RDGE.globals.gl.TEXTURE15, arrayPeek(primSet.material.tex.set1).norm);
- RDGE.setActiveTexture(RDGE.globals.gl.TEXTURE6, arrayPeek(primSet.material.tex.set2).norm);
-
- //bind buffers and attribs
- arrayPeek(primSet.material.renderObj).bindBuffers();
-
- // bind shader uniforms
- arrayPeek(primSet.material.renderObj).bindTextures();
-
- arrayPeek(primSet.material.renderObj).bindUniforms();
-
- RDGE.globals.gl.drawElements(RDGE.globals.gl.TRIANGLES, primSet.size, RDGE.globals.gl.UNSIGNED_SHORT, primSet.indexInBuffer * 2);
-};
-
-RDGE.renderProcLines = function (renderObj, r, g, b, a) {
- RDGE.globals.gl.useProgram(renderObj.shader);
-
- renderObj.lineColor[0] = r;
- renderObj.lineColor[1] = g;
- renderObj.lineColor[2] = b;
- renderObj.lineColor[3] = a;
-
- //bind buffers and attribs
- renderObj.bindBuffers();
-
- // bind shader uniforms
- renderObj.bindUniforms();
-
- // draw the AABBs
- RDGE.globals.gl.drawArrays(RDGE.globals.gl.LINES, 0, renderObj.numPoints / 3);
-
- RDGE.globals.gl.useProgram(null);
-};
-
-RDGE.renderProcScreenQuad = function (quad) {
- RDGE.globals.gl.disable(RDGE.globals.gl.DEPTH_TEST);
- RDGE.globals.gl.useProgram(quad.shader);
-
- //bind buffers and attribs
- quad.renderObj.bindBuffers();
-
- // bind shader uniforms
- quad.renderObj.bindTextures();
- quad.renderObj.bindUniforms();
-
- // render
- var offset = 0;
- // Bind the texture
- RDGE.globals.gl.bindTexture(RDGE.globals.gl.TEXTURE_2D, quad.texture);
- RDGE.globals.gl.drawArrays(RDGE.globals.gl.TRIANGLES, 0, 6);
-
- RDGE.globals.gl.useProgram(null);
- RDGE.globals.gl.enable(RDGE.globals.gl.DEPTH_TEST);
-};
-
-// post render proc
-RDGE.postRenderProcDefault = function (primSet) {
- RDGE.globals.gl.useProgram(arrayPeek(primSet.material.render