Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualMacD

Posted 03 November 2012 - 12:40 AM

Pffffttt. Finally got it running!

My main problem was that I didn't really grok the distinctions and relations between the mapping of the total loop, the resulting noisemap and the final tiles I wanted. I was trying a lot of wierd things with the mapx/y chunks, partial mapping etc. I think I saw pics of every way this could go wrong Posted Image

Anyway, in the end it was quite easy: I just set the submap to the size of the loop and grabbed chunks of that using an offset:

for (int i = 0; i<numberOfTilesHeightInt; i++)
{
for (int j = 0; j<numberOfTilesWidthInt; j++)
{
for (int localy = (i * tileheight); localy < ((i+1) * tileheight); localy++)
{
for (int localx = (j * tilewidth); localx < ((j+1) * tilewidth); localx++)
{
s = (double) localx / (double) m_dxloop;
t = (double) localy / (double) m_dyloop;

nx = m_loopx0 + Math.cos(s * 2 * Math.PI)*m_dxloop/(2*Math.PI);
ny = m_loopy0 + Math.cos(t * 2 * Math.PI)*m_dyloop/(2*Math.PI);
nz = m_loopx0 + Math.sin(s * 2 * Math.PI)*m_dxloop/(2*Math.PI);
nw = m_loopy0 + Math.sin(t * 2 * Math.PI)*m_dyloop/(2*Math.PI);

noise = SimplexNoise4D.noise(nx* scalingfactor, ny * scalingfactor, nz * scalingfactor, nw * scalingfactor);
noise = ((noise + 1) / 2);
noisedpixelsarray[(localx - (j * tilewidth))+ ((localy - (i*tileheight)) * tilewidth)] = tileColor;
}
}
noiseTileBitmap.setPixels(noisedpixelsarray, 0, tilewidth, 0, 0, tilewidth, tileheight);

//draw the colour noisemap in grayscale:
tmpTileCanvas.drawBitmap(noiseTileBitmap, null, dstRect, tmpPaint);
//and draw on h-index-w-index text:
_tmpTileCanvas.drawText("w" + String.valueOf(j) + "-" + String.valueOf(i), tmpTileBitmap.getWidth() * 0.5f, tmpTileBitmap.getHeight() * 0.5f, penPaint);

saveTile(tmpTileBitmap, j, i);
}
}

Anyway, thanks for helping me out! Now I'm off to find some good octaves and making some postprocessing routines Posted Image

PS: wtf? CODE tags eat my newlines again?!? It looks OK in preview, but as soon as I post and reload the page, it's all one line? Well, let's see what removing the tags does...

#1MacD

Posted 03 November 2012 - 12:37 AM

Pffffttt. Finally got it running!

My main problem was that I didn't really grok the distinctions and relations between the mapping of the total loop, the resulting noisemap and the final tiles I wanted. I was trying a lot of wierd things with the mapx/y chunks, partial mapping etc. I think I saw pics of every way this could go wrong Posted Image

Anyway, in the end it was quite easy: I just set the submap to the size of the loop and grabbed chunks of that using an offset:

for (int i = 0; i<numberOfTilesHeightInt; i++)
	 {	
	  for (int j = 0; j<numberOfTilesWidthInt; j++)
	  {
	 	 for (int localy = (i * tileheight); localy < ((i+1) * tileheight); localy++)
	   {
		for (int localx = (j * tilewidth); localx < ((j+1) * tilewidth); localx++)
		{
	 		 s = (double) localx / (double) m_dxloop;
	 		 t = (double) localy / (double) m_dyloop;

	 		 nx = m_loopx0 + Math.cos(s * 2 * Math.PI)*m_dxloop/(2*Math.PI);
	 		 ny = m_loopy0 + Math.cos(t * 2 * Math.PI)*m_dyloop/(2*Math.PI);
	 		 nz = m_loopx0 + Math.sin(s * 2 * Math.PI)*m_dxloop/(2*Math.PI);
	 		 nw = m_loopy0 + Math.sin(t * 2 * Math.PI)*m_dyloop/(2*Math.PI);

	 		 noise = SimplexNoise4D.noise(nx* scalingfactor, ny * scalingfactor, nz * scalingfactor, nw * scalingfactor);
	 		 noise = ((noise + 1) / 2);
	 		 noisedpixelsarray[(localx  - (j * tilewidth))+ ((localy - (i*tileheight)) * tilewidth)] = tileColor;
		}
	   }
	 	 noiseTileBitmap.setPixels(noisedpixelsarray, 0, tilewidth, 0, 0, tilewidth, tileheight);
	  
	   //draw the colour noisemap in grayscale:
	 	 tmpTileCanvas.drawBitmap(noiseTileBitmap, null, dstRect, tmpPaint);
		  //and draw on h-index-w-index text:
		  _tmpTileCanvas.drawText("w" + String.valueOf(j) + "-" + String.valueOf(i), tmpTileBitmap.getWidth() * 0.5f, tmpTileBitmap.getHeight() * 0.5f, penPaint);
	  
	   saveTile(tmpTileBitmap, j, i);
	  }
	 }

Anyway, thanks for helping me out! Now I'm off to find some good octaves and making some postprocessing routines :)

PARTNERS