001/**
002 * Copyright (c) 2008-2014 Ardor Labs, Inc.
003 *
004 * This file is part of Ardor3D.
005 *
006 * Ardor3D is free software: you can redistribute it and/or modify it
007 * under the terms of its license which may be found in the accompanying
008 * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
009 */
010
011package com.ardor3d.extension.shadow.map;
012
013import org.junit.Assert;
014import org.junit.Test;
015
016import com.ardor3d.bounding.BoundingBox;
017import com.ardor3d.bounding.BoundingSphere;
018import com.ardor3d.math.Vector3;
019
020public class TestPSSMCamera {
021    @Test
022    public void testBoxSphereCameraPack() {
023        MockPSSMCamera camera = new MockPSSMCamera();
024        camera.setLocation(0, 0, -10);
025        camera.setFrustumPerspective(50, 1, 1, 100);
026
027        final BoundingBox boundingBox = new BoundingBox();
028        boundingBox.setCenter(new Vector3(0, 0, 10));
029        boundingBox.setXExtent(2);
030        boundingBox.setYExtent(2);
031        boundingBox.setZExtent(2);
032
033        camera.pack(boundingBox);
034
035        final double boxNear1 = camera.getFrustumNear();
036        final double boxFar1 = camera.getFrustumFar();
037
038        Assert.assertEquals(new Vector3(2, 2, 2), camera.getExtents());
039
040        camera = new MockPSSMCamera();
041        camera.setLocation(0, 0, -10);
042        camera.setFrustumPerspective(50, 1, 1, 100);
043
044        final BoundingSphere boundingSphere = new BoundingSphere();
045        boundingSphere.setCenter(new Vector3(0, 0, 10));
046        boundingSphere.setRadius(2);
047
048        camera.pack(boundingSphere);
049
050        final double boxNear2 = camera.getFrustumNear();
051        final double boxFar2 = camera.getFrustumFar();
052
053        Assert.assertEquals(new Vector3(2, 2, 2), camera.getExtents());
054
055        Assert.assertEquals(boxNear1, boxNear2, 0.0);
056        Assert.assertEquals(boxFar1, boxFar2, 0.0);
057    }
058}