OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010, Google Inc. | 2 * Copyright 2010, Google Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 this.transpose_ = true; | 582 this.transpose_ = true; |
583 }; | 583 }; |
584 o3d.inherit('ViewInverseTransposeParamMatrix4', 'CompositionParamMatrix4'); | 584 o3d.inherit('ViewInverseTransposeParamMatrix4', 'CompositionParamMatrix4'); |
585 | 585 |
586 | 586 |
587 /** | 587 /** |
588 * @constructor | 588 * @constructor |
589 */ | 589 */ |
590 o3d.ViewProjectionParamMatrix4 = function() { | 590 o3d.ViewProjectionParamMatrix4 = function() { |
591 o3d.CompositionParamMatrix4.call(this); | 591 o3d.CompositionParamMatrix4.call(this); |
592 this.matrix_names_ = ['projection', 'view']; | 592 this.matrix_names_ = ['viewProjection']; |
593 }; | 593 }; |
594 o3d.inherit('ViewProjectionParamMatrix4', 'CompositionParamMatrix4'); | 594 o3d.inherit('ViewProjectionParamMatrix4', 'CompositionParamMatrix4'); |
595 | 595 |
596 | 596 |
597 /** | 597 /** |
598 * @constructor | 598 * @constructor |
599 */ | 599 */ |
600 o3d.ViewProjectionInverseParamMatrix4 = function() { | 600 o3d.ViewProjectionInverseParamMatrix4 = function() { |
601 o3d.CompositionParamMatrix4.call(this); | 601 o3d.CompositionParamMatrix4.call(this); |
602 this.matrix_names_ = ['projection', 'view']; | 602 this.matrix_names_ = ['viewProjection']; |
603 this.inverse_ = true; | 603 this.inverse_ = true; |
604 }; | 604 }; |
605 o3d.inherit('ViewProjectionInverseParamMatrix4', 'CompositionParamMatrix4'); | 605 o3d.inherit('ViewProjectionInverseParamMatrix4', 'CompositionParamMatrix4'); |
606 | 606 |
607 | 607 |
608 /** | 608 /** |
609 * @constructor | 609 * @constructor |
610 */ | 610 */ |
611 o3d.ViewProjectionTransposeParamMatrix4 = function() { | 611 o3d.ViewProjectionTransposeParamMatrix4 = function() { |
612 o3d.CompositionParamMatrix4.call(this); | 612 o3d.CompositionParamMatrix4.call(this); |
613 this.matrix_names_ = ['projection', 'view']; | 613 this.matrix_names_ = ['viewProjection']; |
614 this.transpose_ = true; | 614 this.transpose_ = true; |
615 }; | 615 }; |
616 o3d.inherit('ViewProjectionTransposeParamMatrix4', 'CompositionParamMatrix4'); | 616 o3d.inherit('ViewProjectionTransposeParamMatrix4', 'CompositionParamMatrix4'); |
617 | 617 |
618 | 618 |
619 /** | 619 /** |
620 * @constructor | 620 * @constructor |
621 */ | 621 */ |
622 o3d.ViewProjectionInverseTransposeParamMatrix4 = function() { | 622 o3d.ViewProjectionInverseTransposeParamMatrix4 = function() { |
623 o3d.CompositionParamMatrix4.call(this); | 623 o3d.CompositionParamMatrix4.call(this); |
624 this.matrix_names_ = ['projection', 'view']; | 624 this.matrix_names_ = ['viewProjection']; |
625 this.inverse_ = true; | 625 this.inverse_ = true; |
626 this.transpose_ = true; | 626 this.transpose_ = true; |
627 }; | 627 }; |
628 o3d.inherit('ViewProjectionInverseTransposeParamMatrix4', | 628 o3d.inherit('ViewProjectionInverseTransposeParamMatrix4', |
629 'CompositionParamMatrix4'); | 629 'CompositionParamMatrix4'); |
630 | 630 |
631 | 631 |
632 /** | 632 /** |
633 * @constructor | 633 * @constructor |
634 */ | 634 */ |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 }; | 718 }; |
719 o3d.inherit('WorldViewInverseTransposeParamMatrix4', | 719 o3d.inherit('WorldViewInverseTransposeParamMatrix4', |
720 'CompositionParamMatrix4'); | 720 'CompositionParamMatrix4'); |
721 | 721 |
722 | 722 |
723 /** | 723 /** |
724 * @constructor | 724 * @constructor |
725 */ | 725 */ |
726 o3d.WorldViewProjectionParamMatrix4 = function() { | 726 o3d.WorldViewProjectionParamMatrix4 = function() { |
727 o3d.CompositionParamMatrix4.call(this); | 727 o3d.CompositionParamMatrix4.call(this); |
728 this.matrix_names_ = ['projection', 'view', 'world']; | 728 this.matrix_names_ = ['worldViewProjection']; |
729 }; | 729 }; |
730 o3d.inherit('WorldViewProjectionParamMatrix4', | 730 o3d.inherit('WorldViewProjectionParamMatrix4', |
731 'CompositionParamMatrix4'); | 731 'CompositionParamMatrix4'); |
732 | 732 |
733 | 733 |
734 /** | 734 /** |
735 * @constructor | 735 * @constructor |
736 */ | 736 */ |
737 o3d.WorldViewProjectionInverseParamMatrix4 = function() { | 737 o3d.WorldViewProjectionInverseParamMatrix4 = function() { |
738 o3d.CompositionParamMatrix4.call(this); | 738 o3d.CompositionParamMatrix4.call(this); |
739 this.matrix_names_ = ['projection', 'view', 'world']; | 739 this.matrix_names_ = ['worldViewProjection']; |
740 this.inverse_ = true; | 740 this.inverse_ = true; |
741 }; | 741 }; |
742 o3d.inherit('WorldViewProjectionInverseParamMatrix4', | 742 o3d.inherit('WorldViewProjectionInverseParamMatrix4', |
743 'CompositionParamMatrix4'); | 743 'CompositionParamMatrix4'); |
744 | 744 |
745 | 745 |
746 /** | 746 /** |
747 * @constructor | 747 * @constructor |
748 */ | 748 */ |
749 o3d.WorldViewProjectionTransposeParamMatrix4 = function() { | 749 o3d.WorldViewProjectionTransposeParamMatrix4 = function() { |
750 o3d.CompositionParamMatrix4.call(this); | 750 o3d.CompositionParamMatrix4.call(this); |
751 this.matrix_names_ = ['projection', 'view', 'world']; | 751 this.matrix_names_ = ['worldViewProjection']; |
752 this.transpose_ = true; | 752 this.transpose_ = true; |
753 }; | 753 }; |
754 o3d.inherit('WorldViewProjectionTransposeParamMatrix4', | 754 o3d.inherit('WorldViewProjectionTransposeParamMatrix4', |
755 'CompositionParamMatrix4'); | 755 'CompositionParamMatrix4'); |
756 | 756 |
757 | 757 |
758 /** | 758 /** |
759 * @constructor | 759 * @constructor |
760 */ | 760 */ |
761 o3d.WorldViewProjectionInverseTransposeParamMatrix4 = function() { | 761 o3d.WorldViewProjectionInverseTransposeParamMatrix4 = function() { |
762 o3d.CompositionParamMatrix4.call(this); | 762 o3d.CompositionParamMatrix4.call(this); |
763 this.matrix_names_ = ['projection', 'view', 'world']; | 763 this.matrix_names_ = ['worldViewProjection']; |
764 this.inverse_ = true; | 764 this.inverse_ = true; |
765 this.transpose_ = true; | 765 this.transpose_ = true; |
766 }; | 766 }; |
767 o3d.inherit('WorldViewProjectionInverseTransposeParamMatrix4', | 767 o3d.inherit('WorldViewProjectionInverseTransposeParamMatrix4', |
768 'CompositionParamMatrix4'); | 768 'CompositionParamMatrix4'); |
769 | 769 |
770 /** | 770 /** |
771 * Called to specify the value of a uniform variable. | 771 * Called to specify the value of a uniform variable. |
772 */ | 772 */ |
773 o3d.ParamFloat.prototype.applyToLocation = function(gl, location) { | 773 o3d.ParamFloat.prototype.applyToLocation = function(gl, location) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 */ | 815 */ |
816 o3d.ParamSampler.prototype.applyToLocation = function(gl, location) { | 816 o3d.ParamSampler.prototype.applyToLocation = function(gl, location) { |
817 // When before the effect object assigns values to parameters, | 817 // When before the effect object assigns values to parameters, |
818 // it sets this variable to 0. | 818 // it sets this variable to 0. |
819 var i = o3d.Param.texture_index_; | 819 var i = o3d.Param.texture_index_; |
820 gl.activeTexture(gl.TEXTURE0 + i); | 820 gl.activeTexture(gl.TEXTURE0 + i); |
821 | 821 |
822 var value = null; | 822 var value = null; |
823 var target = 0; | 823 var target = 0; |
824 | 824 |
825 if (this.value) { | 825 if (this.value && this.value.texture && this.value.texture.texture_) { |
826 this.value.bindAndSetParameters_(); | 826 value = this.value.texture.texture_; |
827 gl.uniform1i(location, i); | 827 target = this.value.texture.texture_target_; |
828 o3d.Param.texture_index_++; | |
829 } | 828 } |
| 829 |
| 830 gl.bindTexture(target, value); |
| 831 gl.uniform1i(location, i); |
| 832 o3d.Param.texture_index_++; |
830 }; | 833 }; |
831 | 834 |
832 | 835 |
833 /** | 836 /** |
834 * Object to compute all combinations of world/view/projection | 837 * Object to compute all combinations of world/view/projection |
835 * inverse/transpose matrices and provide them as parameters. | 838 * inverse/transpose matrices and provide them as parameters. |
836 * | 839 * |
837 * @type {o3d.ParamObject} | 840 * @type {o3d.ParamObject} |
838 */ | 841 */ |
839 o3d.Param.SAS = new o3d.ParamObject; | 842 o3d.Param.SAS = new o3d.ParamObject; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 */ | 907 */ |
905 o3d.Param.SAS.setView = function(view) { | 908 o3d.Param.SAS.setView = function(view) { |
906 this['view'] = view; | 909 this['view'] = view; |
907 }; | 910 }; |
908 | 911 |
909 /** | 912 /** |
910 * Sets the base world matrix that gets use to compute all other products for | 913 * Sets the base world matrix that gets use to compute all other products for |
911 * SAS parameters. | 914 * SAS parameters. |
912 */ | 915 */ |
913 o3d.Param.SAS.setProjection = function(projection) { | 916 o3d.Param.SAS.setProjection = function(projection) { |
914 // TODO(petersont): this wasn't being used. Need to adjust all of | |
915 // the handwritten GLSL shaders to incorporate the modification of | |
916 // gl_Position based on dx_clipping. | |
917 /* | |
918 var adjustedProjection = | |
919 [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 2, 0], [0, 0, -1, 1]]; | |
920 o3d.Transform.compose( | |
921 adjustedProjection, projection, adjustedProjection); | |
922 */ | |
923 this['projection'] = projection; | 917 this['projection'] = projection; |
924 }; | 918 }; |
925 | 919 |
| 920 /** |
| 921 * Sets the viewProjection matrix. |
| 922 */ |
| 923 o3d.Param.SAS.setViewProjection = function(viewProjection) { |
| 924 this['viewProjection'] = viewProjection; |
| 925 }; |
926 | 926 |
| 927 /** |
| 928 * Sets the worldViewProjection matrix. |
| 929 */ |
| 930 o3d.Param.SAS.setWorldViewProjection = function(worldViewProjection) { |
| 931 this['worldViewProjection'] = worldViewProjection; |
| 932 }; |
OLD | NEW |