Permalink
Browse files

Apply view pitch to flight direction (optionally).

  • Loading branch information...
1 parent e5b7f18 commit 9e67c1cc031680248f25bc4f8be2769c8e8b891f @kpreid committed May 29, 2012
Showing with 27 additions and 5 deletions.
  1. +8 −1 config.js
  2. +12 −2 cubes.html
  3. +7 −2 player.js
View
@@ -20,22 +20,29 @@
Object.keys(config).forEach(function (k) { config[k].setToDefault(); });
}});
+ // controls/view options
defineOption("controls", "object", Input.defaultBindings);
+ defineOption("pitchRelativeFlight", "boolean", false);
defineOption("fov", "number", 60);
defineOption("renderDistance", "number", 100);
defineOption("mouseTurnRate", "number", 4); // radians/second/half-screen-width
+
+ // rendering quality options
defineOption("lighting", "boolean", true);
defineOption("smoothLighting", "boolean", true);
defineOption("bumpMapping", "boolean", true);
defineOption("fsaa", "boolean", false);
defineOption("cubeParticles", "boolean", false);
defineOption("sound", "boolean", true);
+
+ // debug-ish options
defineOption("noclip", "boolean", false);
defineOption("alwaysGenerateWorld", "boolean", false);
defineOption("debugTextureAllocation", "boolean", false);
defineOption("debugForceRender", "boolean", false);
defineOption("debugPlayerCollision", "boolean", false);
-
+
+ // world generation options
defineOption("generate_wx", "number", 400);
defineOption("generate_wy", "number", 128);
defineOption("generate_wz", "number", 400);
View
@@ -236,12 +236,19 @@ <h2>Import</h2>
<h2>Options</h2>
<form onsubmit="return false;">
+ <h3>View</h3>
+
<div class="optionline">Field of view: <input type="range" step="any" min="45" max="140" value="60" size="4" id="fov"></div>
<script>main.config.fov.bindControl("fov");</script>
<div class="optionline">Draw distance: <input type="range" step="any" min="10" max="500" value="100" size="4" id="renderDistance"></div>
<script>main.config.renderDistance.bindControl("renderDistance");</script>
<div class="optionline">Turn rate: <input type="range" step="any" min="0" max="10" value="5" size="4" id="mouseTurnRate"></div>
<script>main.config.mouseTurnRate.bindControl("mouseTurnRate");</script>
+ <div class="optionline"><label><input type="checkbox" id="pitchRelativeFlight"> Pitch-relative flight</label></div>
+ <script>main.config.pitchRelativeFlight.bindControl("pitchRelativeFlight");</script>
+
+ <h3>Graphics</h3>
+
<div class="optionline"><label><input type="checkbox" id="lighting"> Lighting</label></div>
<script>main.config.lighting.bindControl("lighting");</script>
<div class="optionline"><label><input type="checkbox" id="smoothLighting"> Smooth lighting</label></div>
@@ -250,13 +257,16 @@ <h2>Options</h2>
<script>main.config.bumpMapping.bindControl("bumpMapping");</script>
<div class="optionline"><label><input type="checkbox" id="cubeParticles"> Cubical particles</label></div>
<script>main.config.cubeParticles.bindControl("cubeParticles");</script>
+ <div class="optionline"><label><input type="checkbox" id="fsaa"> Fake 2× FSAA (I have fillrate to burn)</label></div>
+ <script>main.config.fsaa.bindControl("fsaa");</script>
+
+ <h3>Sound</h3>
+
<div class="optionline"><label><input type="checkbox" id="enableSound"> Sound</label></div>
<script>
document.getElementById("enableSound").disabled = !cubes.Audio.supported;
main.config.sound.bindControl("enableSound");
</script>
- <div class="optionline"><label><input type="checkbox" id="fsaa"> Fake 2× FSAA (I have fillrate to burn)</label></div>
- <script>main.config.fsaa.bindControl("fsaa");</script>
<h3>Controls</h3>
View
@@ -239,11 +239,16 @@
var EPSILON = 1e-3;
function stepPlayer(timestep) {
var body = currentPlace.body;
-
var floor = body.getFloor();
+ // determine coordinate system for movement control
+ var controlOrientation = mat4.identity(mat4.create());
+ mat4.rotateY(controlOrientation, body.yaw);
+ if (body.flying && config.pitchRelativeFlight.get() /* && is mouselook mode? */) {
+ mat4.rotateX(controlOrientation, pitch);
+ }
+
// apply movement control to velocity
- var controlOrientation = mat4.rotateY(mat4.identity(mat4.create()), body.yaw);
var movAdj = vec3.create();
mat4.multiplyVec3(controlOrientation, movement, movAdj);
vec3.scale(movAdj, body.flying ? FLYING_SPEED : WALKING_SPEED);

0 comments on commit 9e67c1c

Please sign in to comment.