package xyz.marsavic.gfxlab.graphics3d.scene;

import xyz.marsavic.gfxlab.Color;
import xyz.marsavic.gfxlab.Vec3;
import xyz.marsavic.gfxlab.graphics3d.Light;
import xyz.marsavic.gfxlab.graphics3d.Material;
import xyz.marsavic.gfxlab.graphics3d.Scene;
import xyz.marsavic.gfxlab.graphics3d.solids.Ball;
import xyz.marsavic.gfxlab.graphics3d.solids.Group;
import xyz.marsavic.gfxlab.graphics3d.solids.HalfSpace;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Collections;


public class SceneTest1 extends Scene.Base{
	BufferedImage obomba;
	{
		try {
			obomba = ImageIO.read(new File("resources/obomba.jpg"));
		} catch (IOException e) {
			System.err.println("Couldn't load Obomba, exiting");
			System.exit(-1);
		}
	}

	public SceneTest1() {
		solid = Group.of(
				Ball.cr(Vec3.xyz(0, 0, 0), 1,
						uv -> Material.diffuseImage(obomba, uv)
				),
				HalfSpace.pn(Vec3.xyz(0, -1, 0), Vec3.xyz(0, 1, 0),
						uv -> Material.diffuseImage(obomba, uv)
				)
		);
		Collections.addAll(lights,
				Light.pc(Vec3.xyz(-1, 1, -1), Color.hsb(0.0, 1.0, 0.6)),
				Light.pc(Vec3.xyz( 2, 0,  0), Color.gray(0.6)),
				Light.pc(Vec3.xyz( 0, 0,  -2), Color.gray(0.1))
		);
	}
	
}
