Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Some suggestions #1

Merged
merged 1 commit into from Feb 14, 2012

Conversation

Projects
None yet
2 participants
Contributor

slembcke commented Feb 14, 2012

I made a little CCSprite subclass to draw the terrain using alpha cut. You could expand that to do some multi-texturing and draw some nice high res terrain. It does a full refresh of the texture for each change. I didn't really profile it, but it seems to run fine that way. If the performance is fine and you can avoid the extra trouble of doing a partial refresh of the texture, I would.

I'd recommend inverting your colors, Chipmunk expects the value returned by the sampler to represent density. 0 is low density, and 1 is high density. Also you can use the values as an alpha texture in OpenGL without having to invert them.

I'd avoid indexed color bitmaps, especially if you are copying the raw bytes out of a CGImage loaded from one. It means that you are copying color indexes, not actual color values. If you use an anti-aliased greyscale png, you can get a smoother contour out of the terrain anyway.

Your don't need to fiddle with the bitmap in your pointInsideTerrain: method. You can just ask the sampler what the density at the point is.

Hmm... I think those were the only changes I made really.

Birkemose added a commit that referenced this pull request Feb 14, 2012

@Birkemose Birkemose merged commit 1308fc1 into Birkemose:master Feb 14, 2012

Owner

Birkemose commented Feb 15, 2012

Hi Scott

Have been busy, so haven't had time to check you updates until now.
Thanks for showing how to get a CCSprite from the CGBitmapContext, and for
you time on this. I think it ended up as a good demo. Has a lot of watchers.
My own thought on this is, that many simply do not understand how easy and
powerful obj-chipmunk is. When I look at Box2D code ( or plain vanilla
chipmunk for that matter ), it really is a pain to watch :)
I was wondering, if there was a niche for making a lightweight obj-c
implementation of chipmunk?

I will do multipass rendering in my final implementation. This will be an
iPad only app, and terrain bitmap will be 512 * 128 mapped into a 2048 *
512 scrollable terrain made from a 1024 * 1024. I tested sampling over 4
pixels, and it looks great.
I will promote the techniques and chipmunk more, as I progress.

/Birkemose

2012/2/14 slembcke <
reply@reply.github.com

I made a little CCSprite subclass to draw the terrain using alpha cut. You
could expand that to do some multi-texturing and draw some nice high res
terrain. It does a full refresh of the texture for each change. I didn't
really profile it, but it seems to run fine that way. If the performance is
fine and you can avoid the extra trouble of doing a partial refresh of the
texture, I would.

I'd recommend inverting your colors, Chipmunk expects the value returned
by the sampler to represent density. 0 is low density, and 1 is high
density. Also you can use the values as an alpha texture in OpenGL without
having to invert them.

I'd avoid indexed color bitmaps, especially if you are copying the raw
bytes out of a CGImage loaded from one. It means that you are copying color
indexes, not actual color values. If you use an anti-aliased greyscale png,
you can get a smoother contour out of the terrain anyway.

Your don't need to fiddle with the bitmap in your pointInsideTerrain:
method. You can just ask the sampler what the density at the point is.

Hmm... I think those were the only changes I made really.

You can merge this Pull Request by running:

git pull https://github.com/slembcke/td master

Or you can view, comment on it, or merge it online at:

#1

-- Commit Summary --

  • bunch changes and drawing the terrain

-- File Changes --

M td.xcodeproj/project.pbxproj (194)
A td/Resources/terraindemo.png (0)
M td/pgeTerrain.h (3)
M td/pgeTerrain.m (50)
M td/pgeWorld.m (4)

-- Patch Links --

https://github.com/Birkemose/td/pull/1.patch
https://github.com/Birkemose/td/pull/1.diff


Reply to this email directly or view it on GitHub:
#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment