[prev in list] [next in list] [prev in thread] [next in thread] 

List:       osflash-sandy
Subject:    [Sandy] [sandy commit] r344 - in
From:       codesite-noreply () google ! com (codesite-noreply at google ! com)
Date:       2007-08-14 19:26:27
Message-ID: c09ffb4bcf0437add14d7681a9999 () google ! com
[Download RAW message or body]

Author: ippeldv
Date: Tue Aug 14 12:25:59 2007
New Revision: 344

Modified:
   trunk/sandy/as3/branches/3.0/src/sandy/bounds/BBox.as
   trunk/sandy/as3/branches/3.0/src/sandy/bounds/BSphere.as
   trunk/sandy/as3/branches/3.0/src/sandy/errors/SingletonError.as

Log:
Added documentation!

Modified: trunk/sandy/as3/branches/3.0/src/sandy/bounds/BBox.as
==============================================================================
--- trunk/sandy/as3/branches/3.0/src/sandy/bounds/BBox.as	(original)
+++ trunk/sandy/as3/branches/3.0/src/sandy/bounds/BBox.as	Tue Aug 14 12:25:59 2007
@@ -20,21 +20,29 @@
 	import sandy.core.data.Vertex;
 	
 	/**
-	* BoundingBox object used to clip the object faster.
-	* <p>Create a bounding box that contains the whole object</p>
-	* @author		Thomas Pfeiffer - kiroukou
-	* @version		0.1
-	* @date 		22.03.2006
-	*/
+	 * The <code>BBox</code> object is used to clip the object faster.
+	 * <p>It creates a bounding box that contains the whole object</p>
+	 * 
+	 * @example 	This example is taken from the Shape3D class. It is used in
+	 * 				the <code>updateBoundingVolumes()</code> method:
+ 	 *
+ 	 * <listing version="3.0">
+ 	 *     _oBBox = BBox.create( m_oGeometry.aVertex );
+ 	 *  </listing>
+	 *
+	 * @author		Thomas Pfeiffer - kiroukou
+	 * @version		0.1
+	 * @date 		22.03.2006
+	 */
 	public class BBox
 	{
 		/**
-		 * max vector, representing the upper point of the cube volume
+		 * Max vector, representing the upper point of the cube volume
 		 */
 		public var max:Vector;		
 		
 		/**
-		 * min vector, representing the lower point of the cube volume.
+		 * Min vector, representing the lower point of the cube volume.
 		 */
 		public var min:Vector;		
 	
@@ -44,24 +52,26 @@
 		public var aCorners:Array;
 		public var aTCorners:Array;
 		
-		
 		/**
-		 * Create a BBox object, representing a Bounding Box volume englobing the 3D \
                object passed in parameters.
-		 * Verry usefull for clipping and so performance !
+		 * Creates a bounding sphere that encloses a 3D object. This object's vertices are \
passed +		 * to the <code>create</code> method in the form of an <code>Array</code>. \
Very useful  +		 * for clipping and thus performance!
 		 * 
-		 */	
-		public static function create( p_aPts:Array ):BBox
+		 * @param p_aVertices		The vertices of the 3D object
+		 * @return 					A <code>BBox</code> instance
+		 */		
+		public static function create( p_aVertices:Array ):BBox
 		{
-			if(p_aPts.length == 0) return null;
+			if(p_aVertices.length == 0) return null;
 		   
-		    var l:Number = p_aPts.length;
+		    var l:Number = p_aVertices.length;
 		    var l_min:Vector = new Vector();
 		    var l_max:Vector = new Vector();
 			l_min.x = Number.MAX_VALUE;l_max.x = Number.MIN_VALUE;
 			l_min.y = Number.MAX_VALUE;l_max.y = Number.MIN_VALUE;
 			l_min.z = Number.MAX_VALUE;l_max.z = Number.MIN_VALUE;
 			
-			for each( var v:Vertex in p_aPts )
+			for each( var v:Vertex in p_aVertices )
 			{
 				if( v.x < l_min.x )		l_min.x = v.x;
 				else if( v.x > l_max.x )	l_max.x = v.x;
@@ -74,12 +84,12 @@
 			return new BBox( l_min, l_max );
 		}
 	
-	
 		/**
-		* <p>Create a new {@code BBox} Instance</p>
-		* @param	obj		the object owner
-		* @param	radius	The radius of the Sphere
-		*/ 	
+		 * Creates a new <code>BBox</code> instance by passing the min and the max \
<code>Vector</code>. +		 * 
+		 * @param p_min		Min vector, representing the lower point of the cube volume
+		 * @param p_max		Max vector, representing the upper point of the cube volume
+		 */		
 		public function BBox( p_min:Vector=null, p_max:Vector=null )
 		{
 			min		= (p_min != null) ? p_min : new Vector( -0.5,-0.5,-0.5 );
@@ -92,8 +102,9 @@
 		}		
 		
 		/**
-		 * Returns the center of the Bounding Box volume as a 3D vector.
-		 * @return A vector representing the center of the Bounding Box
+		 * Returns the center of the Bounding Box volume in the form of a 3D vector.
+		 * 
+		 * @return 		A <code>Vector</code> representing the center of the Bounding Box
 		 */
 		public function getCenter():Vector
 		{
@@ -104,7 +115,8 @@
 	
 		/**
 		 * Return the size of the Bounding Box.
-		 * @return a Vector representing the size of the volume in three dimensions.
+		 * 
+		 * @return 		A <code>Vector</code> representing the size of the volume in three \
                dimensions.
 		 */
 		public function getSize():Vector
 		{
@@ -113,16 +125,18 @@
 								Math.abs(max.z - min.z));
 		}
 	
-	
 		/**
-		 * get all the 8 corners vertex of the bounding Box volume.
-		 * @param b Boolean the b is set to true, we will compute the array of vertex once \
                again, otherwise it will return the last compute array.
-		 * @return The array containing 8 Vertex representing the Bounding Box corners.
+		 * Get all the eight corner vertices of the bounding box.
+		 * 
+		 * @param p_bRecalcVertices 	If set to true the vertices array will be \
recalculated. +		 * 								Otherwise it will return the last calculated array.
+		 * @return 		The array containing eight vertices representing the Bounding Box \
                corners.
 		 */
-		private function __computeCorners( b:Boolean=false ):Array
+		private function __computeCorners( p_bRecalcVertices:Boolean=false ):Array
 		{
 			var minx:Number,miny:Number,minz:Number,maxx:Number,maxy:Number,maxz:Number;
-			if( b == true )
+			
+			if( p_bRecalcVertices == true )
 			{
 			    minx = m_oTMin.x;    miny = m_oTMin.y;    minz = m_oTMin.z;
 			    maxx = m_oTMax.x;    maxy = m_oTMax.y;    maxz = m_oTMax.z;
@@ -145,7 +159,11 @@
 			return aCorners;
 		}	
 		
-	
+	    /**
+	     * Applies the transformation that is specified in the <code>Matrix4</code> \
parameter. +	     * 
+	     * @param p_oMatrix		The transformation matrix
+	     */		
 	    public function transform( p_oMatrix:Matrix4 ):void
 	    {
 		    var lVector:Vector;
@@ -175,15 +193,20 @@
 	    }
 	    
 		/**
-		* Get a String represntation of the {@code BBox}.
-		* @return	A String representing the BoundingBox
-		*/ 	
+		 * Returns a <code>String</code> representation of the <code>BBox</code>.
+		 * 
+		 * @return 	A String representing the bounding box
+		 */			
 		public function toString():String
 		{
 			return "sandy.bounds.BBox";
 		}
 		
-		
+		/**
+		 * Clones the current bounding box. 
+		 * 
+		 * @return 		A cloned <code>BBox</code> instance
+		 */		
 		public function clone():BBox
 		{
 		    var l_oBBox:BBox = new BBox();

Modified: trunk/sandy/as3/branches/3.0/src/sandy/bounds/BSphere.as
==============================================================================
--- trunk/sandy/as3/branches/3.0/src/sandy/bounds/BSphere.as	(original)
+++ trunk/sandy/as3/branches/3.0/src/sandy/bounds/BSphere.as	Tue Aug 14 12:25:59 2007
@@ -20,14 +20,20 @@
 	import sandy.core.data.Vertex;	
 	
 	/**
-	* Bounding Sphere object used to clip the object faster.
-	* 
-	* <p>Create a bounding Sphere that contains the whole object</p>
-	*
-	* @author		Thomas Pfeiffer - kiroukou
-	* @version		0.1
-	* @date 		22.02.2006
-	*/
+	 * The <code>BSphere</code> object is used to clip the object faster.
+	 * <p>It Creates a bounding sphere that contains the whole object</p>
+	 * 
+	 * @example 	This example is taken from the Shape3D class. It is used in
+	 * 				the <code>updateBoundingVolumes()</code> method:
+ 	 *
+ 	 * <listing version="3.0">
+ 	 *     _oBSphere = BSphere.create( m_oGeometry.aVertex );
+ 	 *  </listing>
+	 *
+	 * @author		Thomas Pfeiffer - kiroukou
+	 * @version		0.1
+	 * @date 		22.03.2006
+	 */
 	public final class BSphere
 	{
 		public var center:Vector;
@@ -38,23 +44,23 @@
 		public var m_nTRadius:Number;
 	
 		/**
-		 * Create a BSphere object, representing a Bounding Sphere volume englobing the 3D \
                object passed in parameters.
-		 * Verry usefull for clipping and so performance !
+		 * Creates a bounding sphere that encloses a 3D object. This object's vertices are \
passed +		 * to the <code>create</code> method in the form of an <code>Array</code>. \
Very useful  +		 * for clipping and thus performance!
 		 * 
+		 * @param p_aVertices		The vertices of the 3D object
+		 * @return 					A <code>BSphere</code> instance
 		 */	
-		public static function create( p_aPts:Array ):BSphere
+		public static function create( p_aVertices:Array ):BSphere
 		{
 		    var l_sphere:BSphere = new BSphere();
-		    l_sphere.compute( p_aPts );
+		    l_sphere.compute( p_aVertices );
 			return l_sphere;
 		}
 				
 		/**
-		* <p>Create a new {@code BSphere} Instance</p>
-		* 
-		* @param	pos	The center of the sphere
-		* @param	radius	THe radius of the Sphere
-		*/ 	
+		 * <p>Create a new <code>BSphere</code> instance.</p>
+		 */ 	
 		public function BSphere()
 		{
 			center = new Vector();
@@ -62,6 +68,11 @@
 			radius = 1.0;
 		}
 		
+		/**
+	     * Applies the transformation that is specified in the <code>Matrix4</code> \
parameter. +	     * 
+	     * @param p_oMatrix		The transformation matrix
+	     */	
 	    public function transform( p_oMatrix:Matrix4 ):void
 	    {
 	        m_oPosition.copy( center );
@@ -71,25 +82,29 @@
 	    }
 	    
 		/**
-		* Get a String represntation of the {@code BSphere}.
+		* Returns a <code>String</code> represntation of the <code>BSphere</code>.
 		* 
-		* @return	A String representing the Bounding Sphere
+		* @return	A String representing the bounding sphere
 		*/ 	
 		public function toString():String
 		{
 			return "sandy.bounds.BSphere (center : "+center+", radius : "+radius + ")";
 		}
 		
-				
-		public function compute( pPoints:Array ):void
+		/**
+		 * Performs the actual computing of the bounding sphere's center and radius
+		 * 
+		 * @param p_aVertices		The vertices of the 3D object
+		 */		
+		public function compute( p_aVertices:Array ):void
 		{
 			var x:Number, y:Number, z:Number, d:Number;
-			if(pPoints.length == 0) return;
+			if(p_aVertices.length == 0) return;
 			
 			var p:Array = new Array();
 			var i:int, j:int, l:int = 0;
 			
-			for each( var v:Vertex in pPoints )
+			for each( var v:Vertex in p_aVertices )
 			{
 				p.push( v.getVector() );
 				l++;
@@ -150,21 +165,23 @@
 		}
 	  
 	  
-		/*
-		* Return the positions of the array of Position p that are outside the \
                BoundingSphere
-		* @param the array of points to test
-		* @return an array of points containing those that are outside. The array has a \
                length of 0 if all the points are inside or on the surface.
-		*/
-		private function pointsOutofSphere(p:Array):Array
+		/**
+		 * Return the positions of the array of Position p that are outside the \
BoundingSphere. +		 * 
+		 * @param 	An array containing the points to test
+	 	 * @return 	An array of points containing those that are outside. The array has a \
length  +	 	 * 			of 0 if all the points are inside or on the surface.
+		 */
+		private function pointsOutofSphere(p_aPoints:Array):Array
 		{
 			var r:Array = new Array();
-			var i:int, l:int = p.length;
+			var i:int, l:int = p_aPoints.length;
 			
 			while( i < l ) 
 			{
-				if(distance(p[int(i)]) > 0) 
+				if(distance(p_aPoints[int(i)]) > 0) 
 				{
-					r.push( p[int(i)] );
+					r.push( p_aPoints[int(i)] );
 				}
 				
 				i++;
@@ -172,34 +189,39 @@
 			return r;
 		}
 	  
-		  /**
-		   * return where a Position is from the sphere surface
-		   * @return >0 if position is outside the sphere, <0 if inside, =0 if on the \
                surface of thesphere
-		   */
-		public function distance(point:Vector):Number
-		{
-			
-			var x:Number = point.x - center.x;
-			var y:Number = point.y - center.y;
-			var z:Number = point.z - center.z;
+		/**
+		 * Returns the distance of a point from the surface.
+		 * 
+		 * @return 	>0 if position is outside the sphere, <0 if inside, =0 if on the \
surface of the sphere +		 */
+		public function distance(p_oPoint:Vector):Number
+		{
+			var x:Number = p_oPoint.x - center.x;
+			var y:Number = p_oPoint.y - center.y;
+			var z:Number = p_oPoint.z - center.z;
 			return  Math.sqrt(x * x + y * y + z * z) - radius;
 		}
-		  
-		private function computeRadius(ps:Array):Number
+		
+		/**
+		 * Computes the bounding sphere's radius
+		 * 
+		 * @param p_aPoints		An array containing the sphere's points
+		 * @return 				The bounding sphere's radius
+		 */		
+		private function computeRadius(p_aPoints:Array):Number
 		{
 			var x:Number, y:Number, z:Number, d:Number, dmax:Number = 0;
-			var i:int, l:int = ps.length;
+			var i:int, l:int = p_aPoints.length;
 			while( i < l ) 
 			{
-				x = ps[int(i)].x - center.x;
-				y = ps[int(i)].x - center.x;
-				z = ps[int(i)].x - center.x;
+				x = p_aPoints[int(i)].x - center.x;
+				y = p_aPoints[int(i)].x - center.x;
+				z = p_aPoints[int(i)].x - center.x;
 				d = x * x + y * y + z * z;
 				if(d > dmax) dmax = d;
 				i++;
 			}
 			return Math.sqrt(dmax);
 		}
-	
 	}
 }

Modified: trunk/sandy/as3/branches/3.0/src/sandy/errors/SingletonError.as
==============================================================================
--- trunk/sandy/as3/branches/3.0/src/sandy/errors/SingletonError.as	(original)
+++ trunk/sandy/as3/branches/3.0/src/sandy/errors/SingletonError.as	Tue Aug 14 \
12:25:59 2007 @@ -16,15 +16,25 @@
 package sandy.errors
 {
 	/**
-	* Custom class for Singleton errors
-	*  
-	* @author		Dennis Ippel
-	* @version		0.1
-	* @date 		27.04.2007
-	* 
-	**/
+	 * Private constructors do not exist in ActionScript 3.0. That's why we need
+	 * to use a workaround. Every singleton class in Sandy has a private static \
variable +	 * called <code>instance</code>. The <code>instance</code> variable is \
given a  +	 * reference to an instance of the class the first time the class \
constructor or +	 * <code>getInstance()</code> is called. If an attempt is made to \
instantiate the +	 * class a the second time, a <code>SingletonError</code> will be \
thrown. Always  +	 * use the static method <code>Class.getInstance()</code> to get an \
instance of the  +	 * class.
+	 * 
+	 * @author		Dennis Ippel - ippeldv
+	 * @version		1.0
+	 * @date 		26.07.2007
+	 */
 	public class SingletonError extends Error
 	{
+		/**
+		 * All the constructor does is passing the error message string to the 
+		 * superclass.
+		 */		
 		public function SingletonError()
 		{
 			super("Class cannot be instantiated");


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic