Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Texturing a Procedurally generated shape  (Read 2560 times)

0 Members and 1 Guest are viewing this topic.

Evan

  • Newbie
  • *
  • Posts: 1
    • View Profile
Texturing a Procedurally generated shape
« 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...)


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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Texturing a Procedurally generated shape
« Reply #1 on: April 07, 2010, 05:53:23 pm »
Hi

Quote
I was wondering if this would be possible to render in SFML using the Shape class

No, the shape has to be convex.

Quote
also if it would be possible to tile a texture over the planet's surface.

This is not possible in SFML.
Laurent Gomila - SFML developer

Spidyy

  • Sr. Member
  • ****
  • Posts: 493
    • View Profile
Texturing a Procedurally generated shape
« Reply #2 on: April 07, 2010, 07:00:00 pm »
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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Texturing a Procedurally generated shape
« Reply #3 on: April 07, 2010, 07:10:07 pm »
Quote
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.
Laurent Gomila - SFML developer