mirror of
https://github.com/quantum5/punyverse.git
synced 2025-04-24 13:11:57 -04:00
Used 3D rotation to calculate the normals.
This commit is contained in:
parent
e138e2d382
commit
6138402b01
|
@ -193,26 +193,24 @@ def normal_sphere(r, divide, tex, normal, lighting=True, fv4=GLfloat * 4):
|
||||||
t = theta / pi
|
t = theta / pi
|
||||||
v = min(int(t * height), height - 1)
|
v = min(int(t * height), height - 1)
|
||||||
x, y, z = normal[u, v]
|
x, y, z = normal[u, v]
|
||||||
nx, ny, nz = sin(theta) * cos(phi2), sin(theta) * sin(phi2), cos(theta)
|
dx, dy, dz = sin(theta) * cos(phi2), sin(theta) * sin(phi2), cos(theta)
|
||||||
#delta = normal[u, v] / 255.
|
nx, ny, nz = x / 128. - 1, y / 128. - 1, z / 128. - 1
|
||||||
#glNormal3f(nx + delta, ny + delta, nz + delta)
|
nx, nz = cos(theta) * nx + sin(theta) * nz, -sin(theta) * nx + cos(theta) * nz
|
||||||
#glNormal3f(nx + x / 64., ny + y / 64., nz + z / 64.)
|
nx, ny = cos(phi2) * nx - sin(phi2) * ny, sin(phi2) * nx + cos(phi2) * ny
|
||||||
glNormal3f(nx + x / 128. - 1, ny + y / 128. - 1, nz + z / 128. - 1)
|
glNormal3f(nx, ny, nz)
|
||||||
#glNormal3f(nx, ny, nz)
|
|
||||||
glTexCoord2f(s, 1 - t)
|
glTexCoord2f(s, 1 - t)
|
||||||
glVertex3f(r * nx, r * ny, r * nz)
|
glVertex3f(r * dx, r * dy, r * dz)
|
||||||
|
|
||||||
s = phi1 / TWOPI # x
|
s = phi1 / TWOPI # x
|
||||||
u = min(int(s * width), width - 1)
|
u = min(int(s * width), width - 1)
|
||||||
x, y, z = normal[u, v]
|
x, y, z = normal[u, v]
|
||||||
nx, ny, nz = sin(theta) * cos(phi1), sin(theta) * sin(phi1), cos(theta)
|
dx, dy, dz = sin(theta) * cos(phi1), sin(theta) * sin(phi1), cos(theta)
|
||||||
#delta = normal[u, v] / 255.
|
nx, ny, nz = x / 128. - 1, y / 128. - 1, z / 128. - 1
|
||||||
#glNormal3f(nx + delta, ny + delta, nz + delta)
|
nx, nz = cos(theta) * nx + sin(theta) * nz, -sin(theta) * nx + cos(theta) * nz
|
||||||
#glNormal3f(nx + x / 64., ny + y / 64., nz + z / 64.)
|
nx, ny = cos(phi2) * nx - sin(phi2) * ny, sin(phi2) * nx + cos(phi2) * ny
|
||||||
glNormal3f(nx + x / 128. - 1, ny + y / 128. - 1, nz + z / 128. - 1)
|
glNormal3f(nx, ny, nz)
|
||||||
#glNormal3f(nx, ny, nz)
|
|
||||||
glTexCoord2f(s, 1 - t)
|
glTexCoord2f(s, 1 - t)
|
||||||
glVertex3f(r * nx, r * ny, r * nz)
|
glVertex3f(r * dx, r * dy, r * dz)
|
||||||
glEnd()
|
glEnd()
|
||||||
|
|
||||||
glDisable(GL_TEXTURE_2D)
|
glDisable(GL_TEXTURE_2D)
|
||||||
|
|
Loading…
Reference in a new issue