Jump to content

  • Log In with Google      Sign In   
  • Create Account

MacD

Member Since 30 Mar 2010
Offline Last Active Jan 05 2013 10:21 AM

Posts I've Made

In Topic: Why is this terrain using 4d simplex noise not tiling?

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 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...

In Topic: Why is this terrain using 4d simplex noise not tiling?

30 October 2012 - 05:28 PM

Thank you for looking it over. Thank you even more for the reply!

I knew I was doing something bad by replacing the static loopxy0 with a variable absxy, but it was the only thing which led to a resulting terrain. Looking at your explanation, am I correct that loopxy0 will always be 0 (if you take the noise from the range 0 to (tilewidth*NoOfTiles)?

Then I could define loopx/y/0/1 and dx and dy outside of the whole loop, and then define mapx and mapy per tile, instead of per pixel, but I would have to do the second s and t calculations (which I had commented out)?

I'm just trying to get this to work, so for now all I'm trying is to get a tiling from 0 to (tilewidth*NumberOfTiles) ... wouldn't that also mean that in
p=p*(ranges.mapx1-ranges.mapx0)/(ranges.loopx1-ranges.loopx0);
q=q*(ranges.mapy1-ranges.mapy0)/(ranges.loopy1-ranges.loopy0);
the loop1-loop0 is always constant, and map1-map0 (call this: dxmap) is also always a tilewidth or a tileheight (because for each tile, mapx0 AND mapx1 shift a tile's width?

Hmm, I think I'm starting to get it: and I think I understand now why using absx/y DID give me a terrain where loopxy0 didn't! I'll give it a shot right now!

PS: sorry about the code; it looked fine in preview Posted Image I added a couple of carriage returns in one code block and now it seems to display ... ok. When I post the page looks ok too, but when I reload the page, everything is back to one-liners!

In Topic: [.net] C# CF 3.5 why isn't this loop being entered?

30 April 2010 - 06:56 AM

Yup, that was it.

Thanks for looking through this; I guess I'm still not an experienced enough coder to catch on to things like that. I'd screwed around with everything in that loop statement, EXCEPT for that :) Now I hope you've taught me another troubleshooting tip.

Thanks for the lesson, Mike :)

In Topic: [.net] C# CF3.5 Cannot get portion of image to draw using DrawImage()

31 March 2010 - 10:41 AM

*thud*

*thud*

*thud*

That's the sound of my head hitting my desk.

You were absolutely right about where I was pointing my destRect...I thought I was being clever with the programatic referencing, and I'd done just about everything to troubleshoot this, but everything seemed correct, the bitmap was displaying correctly in a test picbox, the increments were incrementing properly....

Sigh :)

Thank you bundles for looking over my code ... I was just blind from looking over it myself :)

Now to add animation and I'll have a nice little moving score counter :)

In Topic: Need recommendations for beginning with C#

30 March 2010 - 04:54 PM

I found the O'Reilly "Programming C#" (I have the c# 3.0, fifth edition, but there'll be an uptodate one available) book to be a good start for c#. Much better than those "c# in 21 days/24 hours" books. A bit basic maybe for someone with a lot of programming experience, but it does touch a few topics you mentioned.

Of course, this place has a whole c# workshop forum attached, so you could check there?

PARTNERS