mirror of
https://github.com/quantum5/punyverse.git
synced 2025-04-24 13:11:57 -04:00
Properly handle background objects.
This commit is contained in:
parent
b54601f9f7
commit
13867d7fd0
|
@ -18,6 +18,8 @@ G = 6.67384e-11 # Gravitation Constant
|
||||||
|
|
||||||
|
|
||||||
class Entity(object):
|
class Entity(object):
|
||||||
|
background = False
|
||||||
|
|
||||||
def __init__(self, name, location, rotation=(0, 0, 0), direction=(0, 0, 0)):
|
def __init__(self, name, location, rotation=(0, 0, 0), direction=(0, 0, 0)):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.location = location
|
self.location = location
|
||||||
|
@ -97,6 +99,8 @@ class Belt(Entity):
|
||||||
|
|
||||||
|
|
||||||
class Sky(Entity):
|
class Sky(Entity):
|
||||||
|
background = True
|
||||||
|
|
||||||
def __init__(self, world, info):
|
def __init__(self, world, info):
|
||||||
pitch = world.evaluate(info.get('pitch', 0))
|
pitch = world.evaluate(info.get('pitch', 0))
|
||||||
yaw = world.evaluate(info.get('yaw', 0))
|
yaw = world.evaluate(info.get('yaw', 0))
|
||||||
|
@ -291,7 +295,7 @@ class SphericalBody(Body):
|
||||||
glCallList(self.sphere_id)
|
glCallList(self.sphere_id)
|
||||||
|
|
||||||
def _draw_atmosphere(self, cam, glMatrixBuffer=GLfloat * 16):
|
def _draw_atmosphere(self, cam, glMatrixBuffer=GLfloat * 16):
|
||||||
with glMatrix(self.location), glRestore(GL_ENABLE_BIT):
|
with glMatrix(self.location), glRestore(GL_ENABLE_BIT | GL_CURRENT_BIT):
|
||||||
matrix = glMatrixBuffer()
|
matrix = glMatrixBuffer()
|
||||||
glGetFloatv(GL_MODELVIEW_MATRIX, matrix)
|
glGetFloatv(GL_MODELVIEW_MATRIX, matrix)
|
||||||
matrix[0: 3] = [1, 0, 0]
|
matrix[0: 3] = [1, 0, 0]
|
||||||
|
@ -299,17 +303,17 @@ class SphericalBody(Body):
|
||||||
matrix[8:11] = [0, 0, 1]
|
matrix[8:11] = [0, 0, 1]
|
||||||
glLoadMatrixf(matrix)
|
glLoadMatrixf(matrix)
|
||||||
|
|
||||||
glEnable(GL_BLEND)
|
|
||||||
if self.atmosphere_id:
|
if self.atmosphere_id:
|
||||||
glCallList(self.atmosphere_id)
|
glCallList(self.atmosphere_id)
|
||||||
|
|
||||||
if self.corona_id:
|
if self.corona_id:
|
||||||
x, y, z = cam.direction()
|
x, y, z = cam.direction()
|
||||||
glTranslatef(-x, -y, -z)
|
glTranslatef(-x, -y, -z)
|
||||||
|
glEnable(GL_BLEND)
|
||||||
glCallList(self.corona_id)
|
glCallList(self.corona_id)
|
||||||
|
|
||||||
def _draw_clouds(self):
|
def _draw_clouds(self):
|
||||||
with glMatrix(self.location, self.rotation), glRestore(GL_ENABLE_BIT):
|
with glMatrix(self.location, self.rotation), glRestore(GL_ENABLE_BIT | GL_CURRENT_BIT):
|
||||||
glEnable(GL_BLEND)
|
glEnable(GL_BLEND)
|
||||||
glEnable(GL_ALPHA_TEST)
|
glEnable(GL_ALPHA_TEST)
|
||||||
glCallList(self.cloudmap_id)
|
glCallList(self.cloudmap_id)
|
||||||
|
|
|
@ -406,6 +406,7 @@ class Applet(pyglet.window.Window):
|
||||||
get_distance = entity_distance(x, y, z)
|
get_distance = entity_distance(x, y, z)
|
||||||
if x != world.x or y != world.y or z != world.z:
|
if x != world.x or y != world.y or z != world.z:
|
||||||
world.tracker.sort(key=get_distance, reverse=True)
|
world.tracker.sort(key=get_distance, reverse=True)
|
||||||
|
world.tracker.sort(key=attrgetter('background'), reverse=True)
|
||||||
world.x, world.y, world.z = x, y, z
|
world.x, world.y, world.z = x, y, z
|
||||||
|
|
||||||
for entity in world.tracker:
|
for entity in world.tracker:
|
||||||
|
|
Loading…
Reference in a new issue