-
Uses the
c++17standard forconstexpr if, structured bindings,string_view, and more -
Non-local variables are given a prefix
| Prefix | Usage | Example |
|---|---|---|
m_ |
non-public member variables | class Foo { int m_bar; }; |
s_ |
static variables | static float s_lastTime; |
k_ |
constants | static const int k_maxSize = 400; |
g_ |
global variables | extern string g_usedInfrequently; |
u_ |
shader uniforms | uniform vec3 u_color; |
i_ |
shader invocation variables | vec3 i_totalLift; |
-
#definesshould only be used when absolutely necessary. Use constant variables to preserve type and code sense -
Source code is organized by project into
srcandincludedirectories.srcshould contain any code that is not to be used by other projects.includeshould contain a directory with the same name as the project, which contains any headers to be used by other projects -
Resources, such as shaders, meshes, images, etc. are kept in the
resourcesdirectory and are organized by project
Common is a static library and serves as a catch-all project for any more "general purpose" code that is used accross multiple projects. All other projects use it. This project contains the Global.hpp header, included nearly everywhere, which contains some absolutely fundamental typedefs and includes.
RLD (Realtime Lift and Drag) is a static library and contains the actual meat and potatoes of the repository, even if it currently has only one header and one source file. It contains the functions for simulating lift and drag on a model given a bunch of variables. It is designed like a public interface, such that it can be easily be used by other projects and depends only on the Common project.
UI (User Interface) is a static library designed to meet the GUI and user input needs of the repo. It follows a typical object-oriented Component class heirarchy, and contains classes for text, text fields, graphs, texture viewers, and groups to organize all these. To be honest, it's a little half-baked. It provides only the functionality that was necessary at the time - it has no buttons or sliders - and it's probably not the best designed. However, it works, and is infinitely better than a million hard-defined constants and pages of reused rendering code.
Visualizer is an executable for visualizing the realtime lift and drag simulation at work. It features a front and side view of the model in its current simulation state. The simulation can be stepped through one slice at a time, or whole sweeps at once. Additionally, it shows curves of the lift, drag, and torq values per slice and per angle of attack. Visualizer uses the Common, RLD, and UI projects.
Controls
spaceto step to the next sliceshift-spaceto do a whole sweep, or finish the current onectrl-spaceto toggle angle of attack auto progression. When sweeping, will automatically progress to the next angle of attackupordownto increment or decrement the angle of attack and perform a sweeprightorleftto increase or decrease the angle of attack and perform a sweep once releasedoandito increase or decrease the rudder anglekandjto increase or decrase the elevator anglemandnto increase or decrease the aileron angle- The graphs can be manipulated
dragto move the curvesscrollto zoom in or outshift-scrollto zoom the range onlyctrl-scrollto zoom the domain only=to reset
- The texture viewers can be manipulated
dragto move the texturescrollto zoom in or out=to reset
- The model viewer can be manipulated
dragto rotate the camera around the originscrollto zoom in or out
- Many of the variable texts can be edited by clicking the value, typing whatever, and then pressing
enter
FlightSim is an executable and a basic flight simulator using the RLD technology. Uses the Common, RLD, and UI projects.
Controls
worsto pitch up or downaordto yaw left or rightqoreto roll left or rightspaceto thrustkto toggle wind-viewshiftwhen in wind-view to view orthographicallyrto reset the simulationpto pause the simulationdragto rotate the cameraescto exit
ClothSim is an executable and cloth simulator using the RLD technology. Primarily set up for simulating a jib sail, but can be set up to simulate a flag or any other cloth object. Features option to see forces on each cloth vertex, or visualize the cloth vertex constraints. Additionally shows the front RLD texture. Uses the Common, RLD, and UI projects.
Controls
dragto rotate the camerascrollto zoom in or outleftorrightto rotate the sail CCW or CWupordownto extend or retract the clewright-clickto "blow" on sailzto disable rld simulationxto do one sweep per framecto do one slice per framespaceto step one slice- The texture viewer can be manipulated
dragto move the texturescrollto zoom in or out
The cloth simulation is done via a basic varlet integration approach in a similar manner as described in this article. There are two key differences however. First, the data is stored on the GPU and the algorithm is performed in parallel using OpenGL. Second, while the approach in the article is tailored specifically for rectangular cloth, we support cloth of any shape, so long as appropriate constraints can be provided. Although lacking self-collision functionality, the result is performant and otherwise realistic.