Sign in to follow this  
tiramisung

directX : Problem in Sphere Texture Mapping

Recommended Posts

Hi, I'm new developer. I have a problem relate to sphere texture mapping. The code i wrote the code to create texture as function below: protected Texture CreateOverlayTexture(string image) { string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); Texture t = TextureLoader.FromFile(device, @path + "\\" + image); return t; } The code for create sphere vertex function is : private void CreateSphereVertex() { sphereMesh = Mesh.Sphere(device, 1.0f, 130, 500); VertexFormats format = VertexFormats.PositionNormal | VertexFormats.Texture1; Mesh tempSphere = sphereMesh.Clone(sphereMesh.Options.Value, format, device); sphereMesh.Dispose(); sphereMesh = tempSphere; CustomVertex.PositionNormalTextured[] verts = (CustomVertex.PositionNormalTextured[])sphereMesh.VertexBuffer.Lock (0, typeof(CustomVertex.PositionNormalTextured), LockFlags.None, sphereMesh.NumberVertices); for (int i = 0; i < verts.Length; i++) { verts[i].Y * verts[i].Y + verts[i].Z * verts[i].Z)); float v = (float)(Math.Acos(verts[i].Y) / Math.PI); float u = (float)((Math.Atan2(verts[i].Z, -1 * verts[i].X) / Math.PI + 2.5f) * 0.5f); verts[i].Tu = u; verts[i].Tv = v; } sphereMesh.VertexBuffer.Unlock(); } However, the sphere display a split line. You can view the result from this link :http://cid-26aa6206f749ee6e.skydrive.live.com/self.aspx/.Public/texturemap.png May i know how to solve this problem to delete that split line? Thank you very much :p

Share this post


Link to post
Share on other sites
Its probably a singularity caused by the trig math (the equation probably explodes towards +-infinity somewhere)

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