# Creating a Sphere from a Cube

This topic is 1583 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey there. I've got a general Question about Morphing a Cube to a Sphere.

As stated in my other Threads, I am working with a Quad-Tree ( but that doesn't really mean anything) which stores the

coordinates for each vertex.

My problem is, when morphing the cube into a sphere, (realized with normalization) not every length is 1.

This goes for the Vertices at edges and corners. It seems as I could almost see the Quads edges and corners.

This, at the first look, does not seem like a big problem. My problem is, that I am going deeper the Quadtree, the nearer I am to the

Sphere. This means at a certain distance a small area of the sphere is more detailed. But when the sphere or the Cam rotates and as

it comes to the edges, the area gets wider as the edges are a little longer.

How can I solve that? I mean I am scaling those Spheres a huge time to model planets and this means a small irregularity results in a big one.

##### Share on other sites

Mh as noone seems to answer, I'd like to rephrase my question:

Could this problem be solved when using something with more resolution to begin with? Like a Icosahedron?

As every part of it has the same size when subdividing and normalizing and won't get stretched as a cube, I think it COULD be better.

Is my assumption correct?

##### Share on other sites

Really don't understand a single thing you're saying... are you trying to make a procedurally generated planet, or are you trying to animate a cube so that it nicely morphs into a sphere?

##### Share on other sites

I am generating a Sphere from a cube right at the moment, meaning I have the coordinates for a cube at the beginning and then let the Quad-Tree beein built which subdivides the Quads and normalizes its vertives.

This means at the end there is a sphere, which I can work with.

So I am procedurally generating a sphere atm.

Problem is with this sphere that the lengthes at the former edges are a little longer than the others, though they all got normalized.

##### Share on other sites

Not quite sure if I understand you completely, but it seems to me that the underlying problem is this:

It is impossible to cover a sphere with undistorted squares, equilateral triangles, hexagons etc. E.g. with a subdivided cube, there will be 8 corners (the original corners of the cube) with 3 edges, but all other corners have 4 edges. If you start with an icosahedron and subdivide with triangles, you will have corners with 5 and corners with 6 edges.

##### Share on other sites

How could I generate a Sphere where all vertices have the same distance to the center? Because thats my problem.

My Sphere seems to have the distance 1.0f for most of the time. But when It comes to the vertices which are at the positions of the originally Edges and Corners of the Cube they have the length of 1.0000012f which will get bigger when scaling.

##### Share on other sites

Single-precision floats only guarantee 6 significant decimals of precision.

##### Share on other sites

Yeah well could be I wronte a zero too much, either way it has a difference, which is pretty annoying when it comes up to scaling.

I rewrote my whole Quad-Tree-Logic to use Triangles instead of Quads and building a Icosahedron as a Base-Figure.

The problem seems to gets really small, as my Triangles won't get different sizes at all. All triangles have the exact same size.

One problem now is the massive grow of data using 20 faces and 12 vertices as a base instead of 12 faces  (Quad from 2 Triangles) and 8 vertices though it seems

more efficient.

The Sphere looks more detailed at lower levels. But having 20 Trees doesn't make things fast haha.

##### Share on other sites

If what you want is a "perfect" sphere, then why don't you just create a sphere model in the first place, instead of trying to make one out of a cube?

##### Share on other sites

What exactly was the motivation for you to try to create a sphere out of a cube (that's not a rhetorical question, I really wonder)? That doesn't make much sense to me, honestly. Why do you generate verticles or a cube and then modify (with huge problems) to form a sphere instead? Did you try to use google and find out how to directly generate verticles of a sphere?

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 14
• 46
• 22
• 27
• ### Forum Statistics

• Total Topics
634047
• Total Posts
3015231
×