• Advertisement
Sign in to follow this  

directX : Problem in Sphere Texture Mapping

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

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Finally , I solve the problem by this code :
device.SetRenderState(RenderStates.Wrap0, true);

Thank you very much

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement