Sign in to follow this  
JustJim

Creating a Sphere from a Cube

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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?

Share this post


Link to post
Share on other sites

Okay My Motivation is, that I want to build procedural planets with LOD. For that reason I searched the web and found, that using a Cube or Icosahedron and morph

it into a sphere is a good way because of the forms and because it is easy to subdivide.

But I run into a lot of problems...

First of all I got managed to create the Quad-Tree with the Icosahedron/Cube which goes to a depth I desire. 

Then I got managed to load the nodes into a list and give them an Index. 

Then i got managed to differ between distances and thus load deeper nodes when getting nearer to the triangles/quads, so a part of it gets a higher subdivide level.

 

My Problem is this freaking frustum culling which won't work.

I tried to calculate the angle between Cam-CenterOfSphere and Cam-Point and see if it is in 45° range, but it gives me crazy results.

Then I recently used BoundingSpheres and BoundingFrustum which is also giving me crazy results as it clips away part of the sphere

which are in the Frustum while it keeps parts of the Sphere which are outside.

 

I defently don't get this to work.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this