aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhwc4872012-06-06 16:34:41 -0700
committerhwc4872012-06-06 16:34:41 -0700
commit6c994c4b90023cecf4fd0caafb404b859fe28f54 (patch)
tree75a4d813441ca6a3eb529dc88a749776459bb76e
parent920436977433ea55c01ce1e73895d1db0a6abac1 (diff)
downloadninja-6c994c4b90023cecf4fd0caafb404b859fe28f54.tar.gz
material cleanup and rearchitecture
-rw-r--r--assets/canvas-runtime.js79
-rw-r--r--assets/shaders/Taper.vert.glsl2
-rw-r--r--js/io/system/ninjalibrary.json2
-rwxr-xr-xjs/lib/drawing/world.js2
-rwxr-xr-xjs/lib/geom/circle.js22
-rwxr-xr-xjs/lib/geom/geom-obj.js21
-rwxr-xr-xjs/lib/geom/rectangle.js23
-rwxr-xr-xjs/lib/rdge/materials/bump-metal-material.js2
-rw-r--r--js/lib/rdge/materials/cloud-material.js17
-rw-r--r--js/lib/rdge/materials/deform-material.js16
-rw-r--r--js/lib/rdge/materials/flag-material.js16
-rwxr-xr-xjs/lib/rdge/materials/flat-material.js18
-rw-r--r--js/lib/rdge/materials/fly-material.js1
-rwxr-xr-xjs/lib/rdge/materials/material.js219
-rw-r--r--js/lib/rdge/materials/pulse-material.js189
-rw-r--r--js/lib/rdge/materials/taper-material.js102
-rw-r--r--js/lib/rdge/materials/water-material.js45
-rwxr-xr-xjs/models/materials-model.js89
-rwxr-xr-xjs/panels/Materials/materials-popup.reel/materials-popup.js16
19 files changed, 484 insertions, 397 deletions
diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js
index ef1d01a9..2f728c06 100644
--- a/assets/canvas-runtime.js
+++ b/assets/canvas-runtime.js
@@ -87,6 +87,10 @@ NinjaCvsRt.CanvasDataManager = Object.create(Object.prototype, {
87 var glRt = Object.create(NinjaCvsRt.GLRuntime, {}); 87 var glRt = Object.create(NinjaCvsRt.GLRuntime, {});
88 glRt.renderWorld(canvas, jObj, this._assetPath); 88 glRt.renderWorld(canvas, jObj, this._assetPath);
89 } 89 }
90 else
91 {
92 console.log( "***** COULD NOT FIND CANVAS WITH ID " + id + " *****" );
93 }
90 } 94 }
91 } 95 }
92 } 96 }
@@ -1491,6 +1495,79 @@ NinjaCvsRt.RuntimeTwistVertMaterial = Object.create(NinjaCvsRt.RuntimeMaterial,
1491 } 1495 }
1492}); 1496});
1493 1497
1498//////////////////////////////////////////////////////
1499
1500NinjaCvsRt.RuntimeTaperMaterial = Object.create(NinjaCvsRt.RuntimeMaterial, {
1501 _name: { value: "TaperMaterial", writable: true },
1502 _shaderName: { value: "taper", writable: true },
1503
1504 _dTime: { value: 0.01, writable: true },
1505 _twistAmount: { value: 0.0, writable: true },
1506 _angle: { value: 0.0, writable: true },
1507
1508
1509 isAnimated: { value: function() { return true; }},
1510
1511 importJSON: {
1512 value: function(jObj) {
1513 this._tex0 = jObj.tex0;
1514 this._tex1 = jObj.tex1;
1515
1516 this._speed = jObj.speed;
1517
1518 this._limit1 = jObj.limit1;
1519 this._limit2 = jObj.limit2;
1520 this._twistAmount = jObj.angle;
1521 }
1522 },
1523
1524 init: {
1525 value: function(world) {
1526 var material = this._materialNode;
1527 if (material)
1528 {
1529 var technique = material.shaderProgram["colorMe"];
1530 var renderer = RDGE.globals.engine.getContext().renderer;
1531 if (renderer && technique)
1532 {
1533 var wrap = 'REPEAT', mips = true;
1534 var tex = renderer.getTextureByName(this._tex0, wrap, mips );
1535 if (tex) technique.u_tex0.set( tex );
1536 tex = renderer.getTextureByName(this._tex1, wrap, mips );
1537 if (tex) technique.u_tex1.set( tex );
1538
1539 technique.u_twistAmount.set( [this._angle] );
1540 technique.u_limit1.set( [this._limit1] );
1541 technique.u_limit2.set( [this._limit2] );
1542 }
1543 }
1544 }
1545 },
1546
1547 // several materials inherit from pulse.
1548 // they may share this update method
1549 update: {
1550 value: function(time) {
1551
1552 var angle = this._angle;
1553 angle += this._dTime * this._speed;
1554 if (angle > this._twistAmount)
1555 {
1556 angle = this._twistAmount;
1557 this._dTime = -this._dTime;
1558 }
1559 else if (angle < 0.0)
1560 {
1561 angle = 0;
1562 this._dTime = -this._dTime;
1563 }
1564 this._angle = angle;
1565 this._shader.twistMe["u_twistAmount"].set([angle]);
1566 }
1567 }
1568});
1569
1570
1494NinjaCvsRt.RuntimePulseMaterial = Object.create(NinjaCvsRt.RuntimeMaterial, { 1571NinjaCvsRt.RuntimePulseMaterial = Object.create(NinjaCvsRt.RuntimeMaterial, {
1495 _name: { value: "PulseMaterial", writable: true }, 1572 _name: { value: "PulseMaterial", writable: true },
1496 _shaderName: { value: "pulse", writable: true }, 1573 _shaderName: { value: "pulse", writable: true },
@@ -1501,7 +1578,7 @@ NinjaCvsRt.RuntimePulseMaterial = Object.create(NinjaCvsRt.RuntimeMaterial, {
1501 1578
1502 importJSON: { 1579 importJSON: {
1503 value: function(jObj) { 1580 value: function(jObj) {
1504 this._texMap = jObj.texture; 1581 this._texMap = jObj.u_tex0;
1505 if (jObj.dTime) this._dTime = jObj.dTime; 1582 if (jObj.dTime) this._dTime = jObj.dTime;
1506 } 1583 }
1507 }, 1584 },
diff --git a/assets/shaders/Taper.vert.glsl b/assets/shaders/Taper.vert.glsl
index 30b73456..eb562c2f 100644
--- a/assets/shaders/Taper.vert.glsl
+++ b/assets/shaders/Taper.vert.glsl
@@ -24,8 +24,6 @@ uniform float u_minVal;
24uniform float u_maxVal; 24uniform float u_maxVal;
25uniform float u_center; 25uniform float u_center;
26 26
27uniform vec4 color;
28
29 27
30// matrix uniforms 28// matrix uniforms
31uniform mat4 u_mvMatrix; 29uniform mat4 u_mvMatrix;
diff --git a/js/io/system/ninjalibrary.json b/js/io/system/ninjalibrary.json
index 5c1eb875..5038bd21 100644
--- a/js/io/system/ninjalibrary.json
+++ b/js/io/system/ninjalibrary.json
@@ -1,6 +1,6 @@
1{ 1{
2 "libraries": [ 2 "libraries": [
3 {"name": "Montage", "path": "/node_modules/descriptor.json", "version": "0.10.0.0"}, 3 {"name": "Montage", "path": "/node_modules/descriptor.json", "version": "0.10.0.0"},
4 {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.5.7.0"} 4 {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.5.8.2"}
5 ] 5 ]
6} \ No newline at end of file 6} \ No newline at end of file
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js
index 228c0d94..8068284e 100755
--- a/js/lib/drawing/world.js
+++ b/js/lib/drawing/world.js
@@ -484,11 +484,11 @@ World.prototype.updateObject = function (obj) {
484 for (var i = 1; i < nPrims; i++) 484 for (var i = 1; i < nPrims; i++)
485 { 485 {
486 // get the next primitive 486 // get the next primitive
487 var prim = prims[i];
488 childTrNode = RDGE.createTransformNode("objNode_" + this._nodeCounter++); 487 childTrNode = RDGE.createTransformNode("objNode_" + this._nodeCounter++);
489 ctrTrNode.insertAsChild(childTrNode); 488 ctrTrNode.insertAsChild(childTrNode);
490 489
491 // attach the instanced box goe 490 // attach the instanced box goe
491 var prim = prims[i];
492 childTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prim); 492 childTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prim);
493 childTrNode.attachMaterial(materialNodes[i]); 493 childTrNode.attachMaterial(materialNodes[i]);
494 } 494 }
diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js
index b2709ce4..6627b4b7 100755
--- a/js/lib/geom/circle.js
+++ b/js/lib/geom/circle.js
@@ -57,16 +57,18 @@ exports.Circle = Object.create(GeomObj, {
57 this.m_world = world; 57 this.m_world = world;
58 58
59 if(strokeMaterial) { 59 if(strokeMaterial) {
60 this._strokeMaterial = strokeMaterial; 60 this._strokeMaterial = strokeMaterial.dup();
61 } else { 61 } else {
62 this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); 62 this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup();
63 } 63 }
64 if (strokeColor && this._strokeMaterial.hasProperty( "color" )) this._strokeMaterial.setProperty( "color", this._strokeColor );
64 65
65 if(fillMaterial) { 66 if(fillMaterial) {
66 this._fillMaterial = fillMaterial; 67 this._fillMaterial = fillMaterial.dup();
67 } else { 68 } else {
68 this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); 69 this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup();
69 } 70 }
71 if (fillColor && this._fillMaterial.hasProperty( "color" )) this._fillMaterial.setProperty( "color", this._fillColor );
70 } 72 }
71 }, 73 },
72 74
@@ -702,19 +704,23 @@ exports.Circle = Object.create(GeomObj, {
702 var strokeMaterialName = jObj.strokeMat; 704 var strokeMaterialName = jObj.strokeMat;
703 var fillMaterialName = jObj.fillMat; 705 var fillMaterialName = jObj.fillMat;
704 706
705 var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); 707 var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ).dup();
706 if (!strokeMat) { 708 if (!strokeMat) {
707 console.log( "object material not found in library: " + strokeMaterialName ); 709 console.log( "object material not found in library: " + strokeMaterialName );
708 strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); 710 strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup();
709 } 711 }
710 this._strokeMaterial = strokeMat; 712 this._strokeMaterial = strokeMat;
713 if (this._strokeMaterial.hasProperty( 'color' ))
714 this._strokeMaterial.setProperty( 'color', this._strokeColor );
711 715
712 var fillMat = MaterialsModel.getMaterial( fillMaterialName ); 716 var fillMat = MaterialsModel.getMaterial( fillMaterialName ).dup();
713 if (!fillMat) { 717 if (!fillMat) {
714 console.log( "object material not found in library: " + fillMaterialName );