directX : Problem in Sphere Texture Mapping

Started by
2 comments, last by tiramisung 13 years, 11 months ago
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.Y * verts.Y + verts.Z * verts.Z)); float v = (float)(Math.Acos(verts.Y) / Math.PI); float u = (float)((Math.Atan2(verts.Z, -1 * verts.X) / Math.PI + 2.5f) * 0.5f); verts.Tu = u; verts.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
Advertisement
Its probably a singularity caused by the trig math (the equation probably explodes towards +-infinity somewhere)
http://www.gearboxsoftware.com/
Then any idea to solve this trig math?
Thanks
Finally , I solve the problem by this code :
device.SetRenderState(RenderStates.Wrap0, true);

Thank you very much

This topic is closed to new replies.

Advertisement