Exemplo n.º 1
0
QVector< QVector3D > Terrain::smoothedPositions( const QVector< QVector3D > & in, const QSize & size )
{
	QVector< QVector3D > out( in.size() );

#define inPosition(x,y) (in[(x)+(y)*size.width()])
#define outPosition(x,y) (out[(x)+(y)*size.width()])
	for( int w=0; w<mMapSize.width(); w++ )
		outPosition( w, 0 ) = inPosition( w, 0 );
	for( int h=1; h<mMapSize.height()-1; h++ )
	{
		outPosition( 0, h ) = inPosition( 0, h );
		for( int w=1; w<mMapSize.width()-1; w++ )
		{
			QVector3D smoothed = QVector3D(0,0,0);
			smoothed += inPosition( w-1, h-1 );
			smoothed += inPosition( w  , h-1 );
			smoothed += inPosition( w+1, h-1 );
			smoothed += inPosition( w-1, h   );
			smoothed += inPosition( w  , h   )*4.0;
			smoothed += inPosition( w+1, h   );
			smoothed += inPosition( w-1, h+1 );
			smoothed += inPosition( w  , h+1 );
			smoothed += inPosition( w+1, h+1 );
			smoothed /= 12.0f;
			outPosition( w, h ) = smoothed;
		}
		outPosition( mMapSize.width()-1, h ) = inPosition( mMapSize.width()-1, h );
	}
	for( int w=0; w<mMapSize.width(); w++ )
		outPosition( w, mMapSize.height()-1 ) = inPosition( w,  mMapSize.height()-1 );
#undef inPosition
#undef outPosition
	return out;
}
Exemplo n.º 2
0
nv_math::vec4f Node::worldPosition(){
	nv_math::vec4f outPosition(0.0, 0.0, 0.0, 1.0);

	return m_transform(outPosition);
}