Sign in to follow this  
Yoyoyoyo

Making a sphere XNA

Recommended Posts

Yoyoyoyo    121
Ok, so i've been searching but couldn't find a way. I want to generate a sphere with normals, and texture uv coords.

If perhaps someone can share their knowledge on the matter.

I don't want to use a model as i want control over the sphere(LOD etc).

Share this post


Link to post
Share on other sites
arbitus    440
[quote name='Rexxaw(Forgrim's mate)' timestamp='1305735368' post='4812579']
Ok, so i've been searching but couldn't find a way. I want to generate a sphere with normals, and texture uv coords.

If perhaps someone can share their knowledge on the matter.

I don't want to use a model as i want control over the sphere(LOD etc).
[/quote]

You can generate a sphere by imagining it as a set of quads determined by the lines of latitude and longitude, much like the surface of the earth. Each vertex of the sphere is intersection of latitude and longitude, the tex coordinates are determined by the angles of the component vectors, and the normals are formed by the vector that passes through that point on the surface of the sphere. You can create latitude and longitude by rotating an axis vector about the various axes. This should be enough information to get started, and I do have code handy that already does this, but I am assuming you would prefer to figure this out with a bit of help?

Share this post


Link to post
Share on other sites
Yoyoyoyo    121
I will absorb that! (Put's kettle on for a cup of coffee)..


[i]..Rotating an axis vector about the various axes.[/i]

This bit i find hard to visualise.

Share this post


Link to post
Share on other sites
Daaark    3553
[url="http://paulbourke.net/miscellaneous/sphere_cylinder/"]http://paulbourke.net/miscellaneous/sphere_cylinder/[/url] Google was no help at all.

Share this post


Link to post
Share on other sites
arbitus    440
[quote name='Rexxaw(Forgrim's mate)' timestamp='1305746802' post='4812688']
I will absorb that! (Put's kettle on for a cup of coffee)..


[i]..Rotating an axis vector about the various axes.[/i]

This bit i find hard to visualise.
[/quote]

(If Z is the up vector) A Z unit vector rotated about the Y or X axes gives you the latitude and rotating an X or Y unit vector about the Z axis gives you longitude. This is essentially the basics behind spherical coordinates that Daaark has linked you to, and that website explains it well.

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