Giter Site home page Giter Site logo

opengl-c-solarsystem's Introduction

Solar System

This is an animated solar system model implemented with OpenGL and FreeGLUT in C.

Screenshot

Screenshot

Features

  • Texture.
  • Lighting.
  • Camera moving.
  • Sun, eight planets and moon.
  • Axis tilt and orbit inclination (Visualizing the formation of midnight sun).
  • Astronomical data from Wikipedia.

Usage

  • Preset views:
    • 1/2: Far / near top-down view.
    • 3/4: Far / near perspective view.
    • 5/6: Far / near view at ecliptic.
    • 7/8: Far / near perspective view on x-axis.
  • Viewport:
    • W/S: Forward / backward.
    • A/D: Left / right.
    • Q/E: Up / down.
    • Mouse wheel: Forward / backward.
    • Mouse dragging: Move scene around camera.
  • Rotation:
    • -/(+/=): Time forward / backward.
    • [/]: Speed up / down. This also has an influence on current time.
  • Debugging:
    • P: Print viewport vectors.

Texture

Texture are taken from solarsystemscope.com which are licensed under CC BY 3.0, and exported in TGA format for use.

Lighting

Lighting is implemented with glLightfv(), a point light source positioned at the center of sun. Since sun itself is a light-emitting object, its lighting is simply turned off.

Camera moving

gluLookAt() is used for the viewing matrix, while the program keeps track of the eye position, look direction and up direction vectors. Keyboard and mouse input adjust these values accordingly.

Data

Astronomical data are taken from the planet pages on Wikipedia. In order to keep the size and offset of this model reasonable, values are scaled by functions to present a sensible rendering, while maintaining their relative magnitude.

You can get an impression of the actual scale of solar system at If the Moon Were Only 1 Pixel.

Both physical and orbital data of every planet is kept as a body_t, with a null-terminated body_t * array field containing its children. They are initialized as globals at the beginning of the program.

opengl-c-solarsystem's People

Contributors

zhanghai avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.