feat(orbit-animation): cycle animation
This commit is contained in:
		
							parent
							
								
									3a71a4899d
								
							
						
					
					
						commit
						ad281f5b68
					
				
							
								
								
									
										15
									
								
								src/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								src/main.cpp
									
									
									
									
									
								
							| @ -73,12 +73,25 @@ int main() | |||||||
|         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | ||||||
| 
 | 
 | ||||||
|         float time = glfwGetTime(); |         float time = glfwGetTime(); | ||||||
|  |         const float orbitalPeriod = 6.284; | ||||||
| 
 | 
 | ||||||
|  |         const int ANIM_ORBITING = 0; | ||||||
|  |         const int ANIM_ECCENTRICITY = 1; | ||||||
|  |         int animation = (int)(time / orbitalPeriod) % 2 == 1; | ||||||
|  | 
 | ||||||
|  |         glm::vec3 pos; | ||||||
|  |         if (animation == ANIM_ORBITING) | ||||||
|  |         { | ||||||
|  |             pos = orbit.getPosition(time); | ||||||
|  |         } | ||||||
|  |         else if (animation == ANIM_ECCENTRICITY) | ||||||
|  |         { | ||||||
|             float e = .25 + .2 * sin(time); |             float e = .25 + .2 * sin(time); | ||||||
|             keplerianElements[astro::eccentricityIndex] = e; |             keplerianElements[astro::eccentricityIndex] = e; | ||||||
|             orbit.setElements(keplerianElements); |             orbit.setElements(keplerianElements); | ||||||
| 
 | 
 | ||||||
|         glm::vec3 pos = orbit.getPosition(time); |             pos = orbit.getPosition(0); | ||||||
|  |         } | ||||||
|         orbiter.setPosition(pos); |         orbiter.setPosition(pos); | ||||||
| 
 | 
 | ||||||
|         // Render lit objects
 |         // Render lit objects
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user