Exemplo n.º 1
0
void Terrain::generate(int x, int y) {
	_grid = boost::multi_array<double, 2>(boost::extents[x][y]);
	int xSize = _grid.shape()[0];
	int ySize = _grid.shape()[1];
	for (int x = 0; x < xSize; ++x) {
		for (int y = 0; y < ySize; ++y) {
			_grid[x][y] = Random<double>(0, 1);
		}
	}

	_generateMesh();
}
// scaling is tricky.  Have to apply scale, then rasterize.
// So scale is baked in to the mesh, but rot
// remesh if scale is different;
void FastLaplaceComper::SetTransform(double rot, pt_t center, double scale, pt_t translation, bool bake_rot)
{
    m_rotationBaked = bake_rot;
    bool remesh = false;
    if(_tgt_xfrm.getScale() != scale)
    {
        remesh = true;
    }
    if(_tgt_xfrm.getRot() != rot && m_rotationBaked)
    {
        remesh = true;
    }

    _tgt_xfrm = SimilarityTransform(translation, rot, center, scale);

    if(remesh) _generateMesh();

    _computeTextureCoords();
    _getBdryColourDifferences();
    ComputeInterpolant();
}
void FastLaplaceComper::SetSourcePoly(pt_t *pts, int n)
{
    _sourcePoly.assign(pts, pts+n);
    _generateMesh();
    _computeTextureCoords();
}