Jump to content

  • Log In with Google      Sign In   
  • Create Account


randomly generated planet / rock


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Monkan   Members   -  Reputation: 529

Like
0Likes
Like

Posted 18 December 2011 - 02:58 PM

Hi,

I want to make a randomly generated planet that is not a perfect sphere. So I was thinking of a way to do this and I figured if I create a shape like a soccer ball (icosahedron I think?) with quite a few faces and verts then I could apply perlin noise to all the verts to create a random shape that is still spherical-ish.
So I created one in Blender, subdivided it a few times, exported as an .OBJ and imported it into my program. Applied my Perlin noise and got the effect I desired, however, I have now run into a few problems so I have a few questions I would like to ask please and see if there is a better way of tackling this problem.

1. How easy is it to create the soccer ball shape in code? And can anyone help me with the maths of how I would do it? This way I wouldn't need to export and import .OBJ files when I want to change how subdivided the shape is and could maybe apply the Perlin Noise at the same time as creating each vert.

2. I think I know how to create new normals after I've applied the Perlin Noise (using the cross product for each face), but how can I calculate new texture coordinates?

3. Is there a better way to achieve the effect I want or am I on the right track? Eventually I will want things to move across the surface (like Mario Galaxy) and so will add gravity and collisions but I think I know how to do these things just about (Gravity will be simple and I will use triangle intersections with objects and the planet mesh) and can cross that bridge when I get to it.

Any help or advice or interesting resources would be greatly appreciated.

Thanks.
"To know the road ahead, ask those coming back."

Sponsor:

#2 Tsus   Members   -  Reputation: 987

Like
2Likes
Like

Posted 18 December 2011 - 03:56 PM

Hi!

1. How easy is it to create the soccer ball shape in code? And can anyone help me with the maths of how I would do it?

A good method for computing spheres with equally sized triangles is to use the Loop subdivision, described in the thesis of Charles Loop, found here.

2. I think I know how to create new normals after I've applied the Perlin Noise (using the cross product for each face), but how can I calculate new texture coordinates?

Texcoords can be computed by projecting the vertex on a unit sphere (such that coordinates are in [0..1]) and then use arc sin to generate coordinates that are evenly distributed on the sphere.
vn = normalize(v);
tu = arcsin(vn.x)/PI + 0.5 
tv = arcsin(vn.y)/PI + 0.5
You find more on that matter here.
If you add much perlin noise your texture will start to stretch, though. So thats a rather simple approach.

3. Is there a better way to achieve the effect I want or am I on the right track? Eventually I will want things to move across the surface (like Mario Galaxy) and so will add gravity and collisions but I think I know how to do these things just about (Gravity will be simple and I will use triangle intersections with objects and the planet mesh) and can cross that bridge when I get to it.

I’d probably do it the same way, so I think you’re on the right track. As for the physics stuff, I’d recommend to use a middleware for that. Collision detection is doable, but the proper handling of the collision events (computing new velocities, torque, resolving intersections, simulating several time steps ahead, debugging etc) requires a huge amount of work. Sure, if you’re interested in learning how to that than of course give it a try (I did it too), but if you like to focus more on the game (mechanics, replay value, achievements, punishments, feedback...) than make your life a little easier. :)

Hope this helps a little!

Acagamics e.V. – IGDA Student Game Development Club (University of Magdeburg, Germany)


#3 Monkan   Members   -  Reputation: 529

Like
0Likes
Like

Posted 18 December 2011 - 06:58 PM

Cool, Thanks Tsus,

This looks like some really good stuff, I'm gonna have a good read through that paper and try to get something working tomorrow. As for the texture coords, the technique detailed looks good enough for now and very simple to implement, so I'll stick with that but may have to expand on it later if the texture is shrinking and stretching in places.

I think I will attempt to implement these things 1st and then think about all the physics and things. Middle-ware is an option I have been considering, although this is a learning exercise so I want to do as much myself as I can, however, I also want to have something to show for it at the end instead of just giving up, so not having to do everything my self will probably be a good idea.

Thanks again for the help, I've got a good starting point to go from now.

If anyone else has any suggestions or comments I would love to hear them.

Thanks.
"To know the road ahead, ask those coming back."




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS