Skip to content

Commit

Permalink
free cam cli option
Browse files Browse the repository at this point in the history
  • Loading branch information
redthing1 committed Feb 25, 2022
1 parent 3b1b24e commit 1f5a8be
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 7 additions & 2 deletions demo/celtest/source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Game : Core {
enum HEIGHT = 540;

public static string custom_mdl1_path = null;
public static bool free_look = false;

this() {
super(WIDTH, HEIGHT, "celtest");
Expand All @@ -31,10 +32,14 @@ class Game : Core {

int main(string[] args) {
bool verbose;
auto help = getopt(args, "verbose|v", &verbose, "model|m", &Game.custom_mdl1_path);
auto help = getopt(args,
"verbose|v", &verbose,
"model|m", &Game.custom_mdl1_path,
"free-cam|f", &Game.free_look,
);

if (help.helpWanted) {
defaultGetoptPrinter("Usage: ./a [--model /path/to/model.glb]", help.options);
defaultGetoptPrinter("Usage: ./a [--model /path/to/model.glb] [-f]", help.options);
return 1;
}

Expand Down
8 changes: 6 additions & 2 deletions demo/celtest/source/play.d
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ class PlayScene : Scene3D {
sphr1_model.effect = new Effect(lights.shader, Colors.WHITE);

// add a camera to look at the mdl1
set_orbit_cam();
if (Game.free_look) {
set_free_cam();
} else {
set_orbit_cam();
}

// // draw a grid at the origin
// auto grid = create_entity("grid");
Expand Down Expand Up @@ -125,7 +129,7 @@ class PlayScene : Scene3D {
}

// if SPACE is pressed, toggle camera orbit vs free look
if (Input.is_key_pressed(Keys.KEY_SPACE)) {
if (Input.is_key_pressed(Keys.KEY_F)) {
if (cam.entity.has_component!CameraOrbit) {
cam.entity.remove_component!CameraOrbit;
set_free_cam();
Expand Down

0 comments on commit 1f5a8be

Please sign in to comment.