// Path: openCVTutorial1CameraPreview/src/main/java/aruco/min3d/Utils.java
// public class Utils 
// {
// 	public static final float DEG = (float)(Math.PI / 180f);
// 		
// 	private static final int BYTES_PER_FLOAT = 4;  
// 	
// 	/**
// 	 * Convenience method to create a Bitmap given a Context's drawable resource ID. 
// 	 */
// 	public static Bitmap makeBitmapFromResourceId(Context $context, int $id)
// 	{
// 		InputStream is = $context.getResources().openRawResource($id);
// 		
// 		Bitmap bitmap;
// 		try {
// 		   bitmap = BitmapFactory.decodeStream(is);
// 		} finally {
// 		   try {
// 		      is.close();
// 		   } catch(IOException e) {
// 		      // Ignore.
// 		   }
// 		}
// 	      
// 		return bitmap;
// 	}
// 	
// 	/**
// 	 * Convenience method to create a Bitmap given a drawable resource ID from the application Context. 
// 	 */
// 	public static Bitmap makeBitmapFromResourceId(int $id)
// 	{
// 		return makeBitmapFromResourceId(Shared.context(), $id);
// 	}
// 	
// 	/**
// 	 * Add two triangles to the Object3d's faces using the supplied indices
// 	 */
// 	public static void addQuad(Object3d $o, int $upperLeft, int $upperRight, int $lowerRight, int $lowerLeft)
// 	{
// 		$o.faces().add((short)$upperLeft, (short)$lowerRight, (short)$upperRight);
// 		$o.faces().add((short)$upperLeft, (short)$lowerLeft, (short)$lowerRight);
// 	}
// 	
// 	public static FloatBuffer makeFloatBuffer3(float $a, float $b, float $c)
// 	{
// 		ByteBuffer b = ByteBuffer.allocateDirect(3 * BYTES_PER_FLOAT);
// 		b.order(ByteOrder.nativeOrder());
// 		FloatBuffer buffer = b.asFloatBuffer();
// 		buffer.put($a);
// 		buffer.put($b);
// 		buffer.put($c);
// 		buffer.position(0);
// 		return buffer;
// 	}
// 
// 	public static FloatBuffer makeFloatBuffer4(float $a, float $b, float $c, float $d)
// 	{
// 		ByteBuffer b = ByteBuffer.allocateDirect(4 * BYTES_PER_FLOAT);
// 		b.order(ByteOrder.nativeOrder());
// 		FloatBuffer buffer = b.asFloatBuffer();
// 		buffer.put($a);
// 		buffer.put($b);
// 		buffer.put($c);
// 		buffer.put($d);
// 		buffer.position(0);
// 		return buffer;
// 	}
// }


import java.nio.FloatBuffer;
import min3d.interfaces.IDirtyParent;
import aruco.min3d.Utils;
package min3d.vos;



/**
 * Light must be added to Scene to take effect.
 * 
 * Eg, "scene.lights().add(myLight);"  
 */
public class Light extends AbstractDirtyManaged implements IDirtyParent
{
	/**
	 * Position is relative to eye space, not world space.
	 */
	public Number3dManaged 		position;
	
	/**
	 * Direction is a vector and should be normalized.
	 */
	public Number3dManaged 		direction;  
	
	public Color4Managed 		ambient;
	public Color4Managed 		diffuse;
	public Color4Managed 		specular;
	public Color4Managed 		emissive;
	
	private LightType			_type;

	public Light()
	{
		super(null);
		
		 ambient = new Color4Managed(128,128,128, 255, this);
		 diffuse = new Color4Managed(255,255,255, 255, this);
		 specular = new Color4Managed(0,0,0,255, this);
		 emissive = new Color4Managed(0,0,0,255, this);
		 
		 position = new Number3dManaged(0f, 0f, 1f, this); 			
		 
		 direction = new Number3dManaged(0f, 0f, -1f, this);	
		 _spotCutoffAngle = new FloatManaged(180, this);		
		 _spotExponent = new FloatManaged(0f, this);			
		 
		 _attenuation = new Number3dManaged(1f,0f,0f, this); 	
		 
		 _type = LightType.DIRECTIONAL;								
		 
		 _isVisible = new BooleanManaged(true, this);
		 
// Path: openCVTutorial1CameraPreview/src/main/java/aruco/min3d/Utils.java
// public class Utils 
// {
// 	public static final float DEG = (float)(Math.PI / 180f);
// 		
// 	private static final int BYTES_PER_FLOAT = 4;  
// 	
// 	/**
// 	 * Convenience method to create a Bitmap given a Context's drawable resource ID. 
// 	 */
// 	public static Bitmap makeBitmapFromResourceId(Context $context, int $id)
// 	{
// 		InputStream is = $context.getResources().openRawResource($id);
// 		
// 		Bitmap bitmap;
// 		try {
// 		   bitmap = BitmapFactory.decodeStream(is);
// 		} finally {
// 		   try {
// 		      is.close();
// 		   } catch(IOException e) {
// 		      // Ignore.
// 		   }
// 		}
// 	      
// 		return bitmap;
// 	}
// 	
// 	/**
// 	 * Convenience method to create a Bitmap given a drawable resource ID from the application Context. 
// 	 */
// 	public static Bitmap makeBitmapFromResourceId(int $id)
// 	{
// 		return makeBitmapFromResourceId(Shared.context(), $id);
// 	}
// 	
// 	/**
// 	 * Add two triangles to the Object3d's faces using the supplied indices
// 	 */
// 	public static void addQuad(Object3d $o, int $upperLeft, int $upperRight, int $lowerRight, int $lowerLeft)
// 	{
// 		$o.faces().add((short)$upperLeft, (short)$lowerRight, (short)$upperRight);
// 		$o.faces().add((short)$upperLeft, (short)$lowerLeft, (short)$lowerRight);
// 	}
// 	
// 	public static FloatBuffer makeFloatBuffer3(float $a, float $b, float $c)
// 	{
// 		ByteBuffer b = ByteBuffer.allocateDirect(3 * BYTES_PER_FLOAT);
// 		b.order(ByteOrder.nativeOrder());
// 		FloatBuffer buffer = b.asFloatBuffer();
// 		buffer.put($a);
// 		buffer.put($b);
// 		buffer.put($c);
// 		buffer.position(0);
// 		return buffer;
// 	}
// 
// 	public static FloatBuffer makeFloatBuffer4(float $a, float $b, float $c, float $d)
// 	{
// 		ByteBuffer b = ByteBuffer.allocateDirect(4 * BYTES_PER_FLOAT);
// 		b.order(ByteOrder.nativeOrder());
// 		FloatBuffer buffer = b.asFloatBuffer();
// 		buffer.put($a);
// 		buffer.put($b);
// 		buffer.put($c);
// 		buffer.put($d);
// 		buffer.position(0);
// 		return buffer;
// 	}
// }


// Path: openCVTutorial1CameraPreview/src/main/java/min3d/vos/Light.java
import java.nio.FloatBuffer;
import min3d.interfaces.IDirtyParent;
import aruco.min3d.Utils;

package min3d.vos;



/**
 * Light must be added to Scene to take effect.
 * 
 * Eg, "scene.lights().add(myLight);"  
 */
public class Light extends AbstractDirtyManaged implements IDirtyParent
{
	/**
	 * Position is relative to eye space, not world space.
	 */
	public Number3dManaged 		position;
	
	/**
	 * Direction is a vector and should be normalized.
	 */
	public Number3dManaged 		direction;  
	
	public Color4Managed 		ambient;
	public Color4Managed 		diffuse;
	public Color4Managed 		specular;
	public Color4Managed 		emissive;
	
	private LightType			_type;

	public Light()
	{
		super(null);
		
		 ambient = new Color4Managed(128,128,128, 255, this);
		 diffuse = new Color4Managed(255,255,255, 255, this);
		 specular = new Color4Managed(0,0,0,255, this);
		 emissive = new Color4Managed(0,0,0,255, this);
		 
		 position = new Number3dManaged(0f, 0f, 1f, this); 			
		 
		 direction = new Number3dManaged(0f, 0f, -1f, this);	
		 _spotCutoffAngle = new FloatManaged(180, this);		
		 _spotExponent = new FloatManaged(0f, this);			
		 
		 _attenuation = new Number3dManaged(1f,0f,0f, this); 	
		 
		 _type = LightType.DIRECTIONAL;								
		 
		 _isVisible = new BooleanManaged(true, this);
		 
		 _positionAndTypeBuffer = Utils.makeFloatBuffer4(0,0,0,0);