1 /*
  2   Copyright (c) 2009 Seneca College
  3   Licenced under the MIT License (http://www.c3dl.org/index.php/mit-license/)
  4 */
  5 
  6 /**
  7 	@class c3dl.Point is an object with a position and color which will be
  8 	rendered using OpenGL's built-in point rendering (either as a circle or
  9 	square depending on smoothing) or rendered as sphere meshes.<br />
 10 	<br />
 11 	The default rendering mode for any scene renders the points as sphere
 12 	meshes.
 13 */
 14 c3dl.Point = function()
 15 {
 16 	// no alpha, but may be implemented in the future. 
 17 	this.color = [0,0,0];
 18 
 19 	//
 20 	this.position = [0,0,0];
 21 	
 22 	//
 23 	this.visible = true;
 24 	
 25 	// not completely necessary since the user can handle this easily themselves.
 26 	// Was added just for a bit of convenience.
 27 	this.name = "";
 28 
 29 	/**
 30 		Get the name of this point. The name is empty by default.
 31 		
 32 		@returns {String} name of this point.
 33 	*/
 34 	this.getName = function()
 35 	{
 36 		return this.name;
 37 	}
 38 	
 39 	/**
 40 		Set the name of this point. The default name set is empty.
 41 		
 42 		@param {String} name The name to assign this point.
 43 	*/
 44 	this.setName = function(name)
 45 	{
 46 		this.name = name;
 47 	}
 48 	
 49 	/**
 50 		Get the position of the point.
 51 		
 52 		@returns {Array} Array of 3 values in the order [x,y,z].
 53 	*/
 54 	this.getPosition = function()
 55 	{
 56 		return c3dl.copyObj(this.position);
 57 	}
 58 
 59 	/**
 60 		Set the position of point.
 61 
 62 		@param {Array} pos Array of 3 values in the order [x,y,z] which defines the 
 63 		new coordinate for this point.
 64 	*/
 65 	this.setPosition = function(pos)
 66 	{
 67 		if(pos.length == 3)
 68 		{
 69 			this.position = c3dl.copyObj(pos);
 70 		}
 71 		else
 72 		{
 73 			c3dl.debug.logWarning("invalid value passed to Point::setPosition()");
 74 		}
 75 	}
 76 
 77 	/**
 78 		Get the color of this point.
 79 
 80 		@returns {Array} Three floating point values in the order RGB.
 81 	*/
 82 	this.getColor = function()
 83 	{
 84 		return c3dl.copyObj(this.color);
 85 	}
 86 
 87 	/**
 88 		Set the color of this point.
 89 		
 90 		@param {Array} color An array of 3 values in the order RGB. Each component 
 91 		ranges from 0.0 to 1.0.
 92 	*/
 93 	this.setColor = function(color)
 94 	{
 95 		if( color.length == 3)
 96 		{
 97 			this.color = c3dl.copyObj(color);
 98 		}
 99 		else
100 		{
101 			c3dl.debug.logWarning("invalid value passed to Point::setColor()");
102 		}
103 	}
104 	
105 	/**
106 		Get the visibility of the point.
107 
108 		@returns {bool} visible true if the point should be rendered, otherwise false.
109 	*/
110 	this.isVisible = function()
111 	{
112 		return this.visible;
113 	}
114 	
115 	/**
116 		Set the visibility of this point.
117 		
118 		@param {bool} visible true if the point should be visible, otherwise false.
119 	*/
120 	this.setVisible = function(visible)
121 	{
122 		this.visible = visible;
123 	}
124 	
125 	/**
126 	*/
127 	this.getObjectType = function()
128 	{
129 		return c3dl.POINT;
130 	}
131 }
132