API Documentation
1 /* 2 GLGE WebGL Graphics Engine 3 Copyright (c) 2010, Paul Brunt 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without 7 modification, are permitted provided that the following conditions are met: 8 * Redistributions of source code must retain the above copyright 9 notice, this list of conditions and the following disclaimer. 10 * Redistributions in binary form must reproduce the above copyright 11 notice, this list of conditions and the following disclaimer in the 12 documentation and/or other materials provided with the distribution. 13 * Neither the name of GLGE nor the 14 names of its contributors may be used to endorse or promote products 15 derived from this software without specific prior written permission. 16 17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 DISCLAIMED. IN NO EVENT SHALL PAUL BRUNT BE LIABLE FOR ANY 21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /** 30 * @fileOverview 31 * @name glge_physicssphere.js 32 * @author me@paulbrunt.co.uk 33 */ 34 35 (function(GLGE){ 36 37 GLGE.PHYSICS_XAXIS=[1,0,0,0]; 38 GLGE.PHYSICS_YAXIS=[0,1,0,0]; 39 GLGE.PHYSICS_ZAXIS=[0,0,1,0]; 40 GLGE.PHYSICS_NEGXAXIS=[-1,0,0,0]; 41 GLGE.PHYSICS_NEGYAXIS=[0,-1,0,0]; 42 GLGE.PHYSICS_NEGZAXIS=[0,0,-1,0]; 43 /** 44 * @class A wrapping class for jiglib spheres 45 * @augments GLGE.PhysicsAbstract 46 */ 47 GLGE.PhysicsPlane=function(uid){ 48 this.jigLibObj=new jigLib.JPlane(this,this.normal,this.distance); 49 this.jigLibObj.GLGE=this; 50 this.jigLibObj.addEventListener(jigLib.JCollisionEvent.COLLISION, function(event){this.GLGE.fireEvent("collision",{obj:event.collisionBody.GLGE,impulse:event.collisionImpulse})}); 51 GLGE.PhysicsAbstract.call(this,uid); 52 } 53 GLGE.augment(GLGE.PhysicsAbstract,GLGE.PhysicsPlane); 54 55 GLGE.PhysicsPlane.prototype.normal=[0,0,1,0]; 56 GLGE.PhysicsPlane.prototype.distance=0; 57 58 GLGE.PhysicsPlane.prototype.className="PhysicsPlane"; 59 /** 60 * Sets the normal of the plane 61 * @param {number} value The normal to set 62 */ 63 GLGE.PhysicsPlane.prototype.setNormal=function(value){ 64 this.normal=value; 65 this.jigLibObj.set_normal(value); 66 return this; 67 } 68 /** 69 * Sets the distance of the plane 70 * @param {number} value The distance to set 71 */ 72 GLGE.PhysicsPlane.prototype.setDistance=function(value){ 73 this.distance=value; 74 this.jigLibObj.set_distance(value); 75 return this; 76 } 77 78 /** 79 * Gets the normal of the plane 80 * @returns {number} The current normal 81 */ 82 GLGE.PhysicsPlane.prototype.getNormal=function(){ 83 return this.jigLibObj.get_normal(); 84 } 85 86 /** 87 * Gets the distance of the plane 88 * @returns {number} The current distance 89 */ 90 GLGE.PhysicsPlane.prototype.getDistance=function(){ 91 return this.jigLibObj.get_distance(); 92 } 93 94 })(GLGE);