Example #1
0
void SWWReaderTest::testBedslopeNormalArray()
{
    CPPUNIT_ASSERT( _sww->isValid() );

    osg::ref_ptr<osg::Vec3Array> actual = _sww->getBedslopeNormalArray();
    CPPUNIT_ASSERT( actual );

    // expected number of bedslope normals
    const size_t nvertices = 24;
    CPPUNIT_ASSERT_EQUAL( actual->size(), nvertices );

    // hard-coded values (bedslope is flat plane)
    using osg::Vec3;
    using osg::Vec3Array;
    Vec3Array *expected = new Vec3Array; 
    expected->assign(24, Vec3( 0.301511, -0.301511, 0.904534 ) );

    for (size_t i=0; i<nvertices; i++)
        CPPUNIT_ASSERT_VEC3_EQUAL( actual->at(i), expected->at(i) );
}
Example #2
0
void SWWReaderTest::testBedslopeVertexArray()
{
    osg::ref_ptr<osg::Vec3Array> actual = _sww->getBedslopeVertexArray();
    CPPUNIT_ASSERT( _sww->isValid() );
    CPPUNIT_ASSERT( actual );

    // expected number of bedslope vertices
    const size_t nvertices = 20;
    CPPUNIT_ASSERT_EQUAL( actual->size(), nvertices );

    // hard-coded values extracted from sww file - note that these values are normalised by the reader
    using osg::Vec3;
    using osg::Vec3Array;
    Vec3Array *expected = new Vec3Array(20);
    (*expected)[ 0] = Vec3(-0.5, -0.5, 0.333333);
    (*expected)[ 1] = Vec3(-0.5, -0.166667, 0.444444);
    (*expected)[ 2] = Vec3(-0.5, 0.166667, 0.555556);
    (*expected)[ 3] = Vec3(-0.5, 0.5, 0.666667);
    (*expected)[ 4] = Vec3(-0.25, -0.5, 0.25);
    (*expected)[ 5] = Vec3(-0.25, -0.166667, 0.361111);
    (*expected)[ 6] = Vec3(-0.25, 0.166667, 0.472222);
    (*expected)[ 7] = Vec3(-0.25, 0.5, 0.583333);
    (*expected)[ 8] = Vec3(0, -0.5, 0.166667);
    (*expected)[ 9] = Vec3(0, -0.166667, 0.277778);
    (*expected)[10] = Vec3(0, 0.166667, 0.388889);
    (*expected)[11] = Vec3(0, 0.5, 0.5);
    (*expected)[12] = Vec3(0.25, -0.5, 0.0833333);
    (*expected)[13] = Vec3(0.25, -0.166667, 0.194444);
    (*expected)[14] = Vec3(0.25, 0.166667, 0.305556);
    (*expected)[15] = Vec3(0.25, 0.5, 0.416667);
    (*expected)[16] = Vec3(0.5, -0.5, 0);
    (*expected)[17] = Vec3(0.5, -0.166667, 0.111111);
    (*expected)[18] = Vec3(0.5, 0.166667, 0.222222);
    (*expected)[19] = Vec3(0.5, 0.5, 0.333333);

    for (size_t i=0; i<nvertices; i++)
	{
        CPPUNIT_ASSERT_VEC3_EQUAL( expected->at(i), actual->at(i) );
	}
}
Example #3
0
void Skybox::drawImplementation(osg::RenderInfo& renderInfo) const{
	int positionCote=mSize/2;

	Vec3Array* boxVertices = new osg::Vec3Array;
	boxVertices->push_back(Vec3f(-positionCote,-positionCote,-positionCote)); //back bottom left 0
	boxVertices->push_back(Vec3f(positionCote,-positionCote,-positionCote)); //back bottom right 1
	boxVertices->push_back(Vec3f(positionCote,positionCote,-positionCote)); //back up right 2
	boxVertices->push_back(Vec3f(-positionCote,positionCote,-positionCote)); //back up left 3
	boxVertices->push_back(Vec3f(-positionCote,-positionCote,positionCote)); //front bottom left 4
	boxVertices->push_back(Vec3f(positionCote,-positionCote,positionCote)); //front bottom right 5
	boxVertices->push_back(Vec3f(positionCote,positionCote,positionCote)); //front up right 6
	boxVertices->push_back(Vec3f(-positionCote,positionCote,positionCote)); //front up left 7

	osg::ref_ptr<osg::Texture2D> texture (new osg::Texture2D(image.get()));
	osg::ref_ptr<osg::StateSet> texSS (new osg::StateSet);
	texture->setInternalFormat(GL_RGBA);
	texture->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR);
	texture->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::LINEAR);
	texSS->setTextureAttributeAndModes (0, texture.get(), osg::StateAttribute::ON);
	texSS->setMode(GL_LIGHTING,osg::StateAttribute::OFF);

	renderInfo.getState()->apply(texSS.get());
	boxVertices->at(0)._v;
	glBegin(GL_QUADS);
		glTexCoord2f(1.0/4.0, 1.01/3.0);glVertex3fv(boxVertices->at(0)._v);
		glTexCoord2f(2.0/4.0, 1.01/3.0);glVertex3fv(boxVertices->at(1)._v);
		glTexCoord2f(2.0/4.0, 1.99/3.0);glVertex3fv(boxVertices->at(2)._v);
		glTexCoord2f(1.0/4.0, 1.99/3.0);glVertex3fv(boxVertices->at(3)._v);

		glTexCoord2f(1.0/4.0, 1.01/3.0);glVertex3fv(boxVertices->at(0)._v);
		glTexCoord2f(0, 1.01/3.0);glVertex3fv(boxVertices->at(4)._v);
		glTexCoord2f(0, 1.99/3.0);glVertex3fv(boxVertices->at(7)._v);
		glTexCoord2f(1.0/4.0, 1.99/3.0);glVertex3fv(boxVertices->at(3)._v);

		glTexCoord2f(1, 1.01/3.0);glVertex3fv(boxVertices->at(4)._v);
		glTexCoord2f(3.0/4.0, 1.01/3.0);glVertex3fv(boxVertices->at(5)._v);
		glTexCoord2f(3.0/4.0, 1.99/3.0);glVertex3fv(boxVertices->at(6)._v);
		glTexCoord2f(1, 1.99/3.0);glVertex3fv(boxVertices->at(7)._v);

		glTexCoord2f(2.0/4.0, 1.01/3.0);glVertex3fv(boxVertices->at(1)._v);
		glTexCoord2f(3.0/4.0, 1.01/3.0);glVertex3fv(boxVertices->at(5)._v);
		glTexCoord2f(3.0/4.0, 1.99/3.0);glVertex3fv(boxVertices->at(6)._v);
		glTexCoord2f(2.0/4.0, 1.99/3.0);glVertex3fv(boxVertices->at(2)._v);

		glTexCoord2f(1.01/4.0, 0);glVertex3fv(boxVertices->at(0)._v);
		glTexCoord2f(1.99/4.0, 0);glVertex3fv(boxVertices->at(1)._v);
		glTexCoord2f(1.99/4.0, 1.0/3.0);glVertex3fv(boxVertices->at(5)._v);
		glTexCoord2f(1.01/4.0, 1.0/3.0);glVertex3fv(boxVertices->at(4)._v);

		glTexCoord2f(1.99/4.0, 2.0/3.0);glVertex3fv(boxVertices->at(2)._v);
		glTexCoord2f(1.01/4.0, 2.0/3.0);glVertex3fv(boxVertices->at(3)._v);
		glTexCoord2f(1.01/4.0, 1);glVertex3fv(boxVertices->at(7)._v);
		glTexCoord2f(1.99/4.0, 1);glVertex3fv(boxVertices->at(6)._v);
	glEnd();

	renderInfo.getState()->apply();
}