0
\$\begingroup\$

Not sure how accurate the question was but I'll put it this way. I'm developing a game where player will construct his/her own stuff, like bridge, building etc. using cocos2d-iphone and Box2D. First they'll draw the draft on a blueprint and then what's drawn will be transported to physics engine and finally the bodies will be wrapped with costumes. Let's say we're building a bridge and the bridge is going to be made of wood. I don't want the wood to be plain brown, I rather want it to be more natural, have some woody patterns on it. Here's my problem: A bridge component might be of any length, how can I achieve maximum realistic wood pattern? The only idea that comes to my mind is to take an image, slice it into 1 pixel width images, number them by order and attach them side by side upon need. Do you have any other suggestions? What's the general practice?

\$\endgroup\$
  • 1
    \$\begingroup\$ You could use a program like photoshop to create a seamless pattern (tiles where each of the four edges match the opposite side). Then, in your program, when the user draws something, you calculate how many tiles are needed to fill the shape the user drew. Draw the grid of tiles side-by-side and use the player-drawn shape to draw an alpha layer on top. Save the resulting image, and use that for the object image. The pattern won't follow the geometry, but I think this method would be relatively easy for you (to program) and the iphone (to render). \$\endgroup\$ – NauticalMile Oct 4 '13 at 3:51
3
\$\begingroup\$

Good points from NauticalMile. You could download one of many free textures that are already set up to tile nicely, or create one yourself using Photoshop or similar. To make the scaling match use the length of the wood pieces as the tiling factor. Alternately if you are strongly against visible repetition you could use a pixel shader instead of a texture. Wood grain, marble and various other materials have been simulated decently with variations on Perlin noise.

|improve this answer|||||
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.