Hi,
I noticed, that when I try map texture on Sphere generated by
Mesh.Sphere(...) metod
this.mesh = Mesh.Sphere(this.device, this.planetRadius, 32, 32);
CustomVertex.PositionNormalTextured[] vb =
(CustomVertex.PositionNormalTextured[])this.mesh.LockVertexBuffer(typeof(Cu stomVertex.PositionNormalTextured),
0, this.mesh.NumberVertices);
double R = this.planetRadius;
double theta, theta2;
double x1, y1;
for (int i = 0; i < this.mesh.NumberVertices; ++i)
{
theta = Math.Asin(vb[i].Y / R); //-PI/2~PI/2
theta2 = Math.Atan2(vb[i].Z, vb[i].X); //-PI~PI
x1 = (theta2 / Math.PI / 2.0) + 0.5; //0.0~ 1.0
y1 = ((theta / Math.PI * 2.0) + 1.0) / 2.0;
vb[i].Tu = (float)x1;
vb[i].Tv = 1.0f - (float)y1;
}
this.mesh.UnlockVertexBuffer();
in place, when start and end of the tetxture connect togeter ( when
vb[i].Tu has values 0 i 1 ) a strange narrow strip occurs, which has
color of pixels like points with vb[i].Tu = 0.5.
It is not transparency / alpha blending - there could not be seen
pixel behind sphere.
It is not probably problems with ZBuffer ( like descripted here:
http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html ) - I had
set:
presentParameters.AutoDepthStencilFormat = DepthFormat.D24X8;
and zNearClipPlane in device.Transform.Projection to 1.
I checked rounding and accuracy of calculations ( float, double
casting etc. )
I tried also values of vb[i].Tu close to 0 and 1 ( less to 0.001 or
higher to 0.999 ) set to 0 and 1, but it doesn't helps.
What is interesting, when I changed device.RenderState.FillMode to
WireFrame I can see, that this strip has not connected with vertex -
the wrong color is a small part of traingle - not cover whole triangle
from vertex to vertex.
for any help thanks in advance