further updates to renderer

This commit is contained in:
Sakimori 2022-01-19 15:19:30 -05:00
parent 95f71c3430
commit fc138a4cb0
2 changed files with 9 additions and 4 deletions

View file

@ -44,7 +44,7 @@ class Planet:
self.name = name
self.mass = mass
self.radius = radius
self.rotationPercentage = 0.00
self.rotationPercentage = 0.04
self.rotationPeriod = rotationPeriod
def rotate(self, timeDelta:"Seconds"):
@ -69,6 +69,10 @@ class DecayPoint(DisplayPoint):
self.currentDecayTick = 0
self.color = (max((self.color[0]-5, 0)), max((self.color[1]-5, 0)), max((self.color[2]-5, 0)))
def copy(self):
"""returns a distinct copy of the point"""
return DecayPoint(self.location, self.color)
Planet.Earth = Planet("Earth", config()["earthMass"], config()["earthRadius"], 86400)
def physicsUpdate(objects, orbitlines, deltaTime):
@ -116,7 +120,7 @@ if __name__=="__main__":
pygame.display.flip()
else:
if not imageThread.is_alive():
imageThread = threading.Thread(target=camera.renderImage, args=(sat,))
imageThread = threading.Thread(target=camera.renderImage, args=(sat, thisEarth, orbitlines))
imageThread.start()
display = False
window.fill((0,0,0))

View file

@ -131,9 +131,10 @@ class Camera:
self.surface.blit(screenSurface, (0,0))
def renderImage(self, sat:"OrbitingBody"):
def renderImage(self, sat:"OrbitingBody", planet:"Planet", points):
"""generates a single image and saves it to disk"""
frozenSat = sat.location
rotValue = math.modf(planet.rotationPercentage * 12)[0] * 3.14159 / 6 #get percentage of 1/12 of a revolution
winWidth, winHeight = self.surface.get_size()
winDistance = winWidth * numpy.cos(numpy.radians(self.hFOV)/2) / 2 #distance for a virtual screen to exist in-space to give the correct FOV
vecToCenter = Point.subtract(self.target.location, self.location)
@ -175,7 +176,7 @@ class Camera:
continue
try:
long = math.modf((math.acos(xPrime / self.target.radius) / (3.141592/6.0)))[0] #pi/6 = 30 degrees
long = math.modf(((math.acos((xPrime) / self.target.radius)) / (3.141592/6.0)))[0] #pi/6 = 30 degrees
except:
screenSurface.set_at((column, row), (20,20,20))
continue