SFML community forums
Help => Graphics => Topic started by: Evan on April 07, 2010, 05:36:03 pm
-
Hello all, I was wondering if SFML would be able to apply a texture to a shape (an object to be drawn to the screen) that was generated at start-up to the screen. Here's the situation:
I'm generating a 2d planet based on feedback from a Perlin noise function. This planet has vertexes at every degree around its surface ( 360 degrees, 360 vertexes). Each of these vertexes is a randomly generated distance from the center of the planet.
Here is a photo of a planet being rendered in Game Maker 8 (which is a bit to slow...)
(http://i742.photobucket.com/albums/xx62/EvanSch/Screeny1-1.png)
I was wondering if this would be possible to render in SFML using the Shape class, also if it would be possible to tile a texture over the planet's surface.
Thanks for reading.
-
Hi
I was wondering if this would be possible to render in SFML using the Shape class
No, the shape has to be convex.
also if it would be possible to tile a texture over the planet's surface.
This is not possible in SFML.
-
And by coding your own Drawable class?
You define a center point, the 360 contours points, making 360 triangles, then applying a piece of texture on each triangle during the render.
It isn't possible with the Shape or Sprite class, but by creating your own Drawable, it could be possible.
-
You define a center point, the 360 contours points, making 360 triangles
This works only if the shape is "almost convex", ie. if segments from center to contour points never cross an edge. That seems to be true here, but otherwise the algorithm gets much harder.
Such a shape should even work with sf::Shape, actually.