From fc138a4cb020110405bad017ad358522524566a6 Mon Sep 17 00:00:00 2001 From: Sakimori Date: Wed, 19 Jan 2022 15:19:30 -0500 Subject: [PATCH] further updates to renderer --- OrbitSim.py | 8 ++++++-- renderer.py | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/OrbitSim.py b/OrbitSim.py index 0fa8ff1..d98f177 100644 --- a/OrbitSim.py +++ b/OrbitSim.py @@ -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)) diff --git a/renderer.py b/renderer.py index 86c63a6..e9003e5 100644 --- a/renderer.py +++ b/renderer.py @@ -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