coolroar

Members
  • Content Count

    46
  • Joined

  • Last visited

  • Days Won

    1

coolroar last won the day on August 19

coolroar had the most liked content!

About coolroar

  • Rank
    Advanced Member
  • Birthday 02/05/1947

Contact Methods

  • Website URL
    https://jounce.space

Profile Information

  • Gender
    Male
  • Location
    Reno, Nevada, US

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hi Steven, Here is one way -- paste this into your createScene function: // other stuff ... var rotationRate = .00002, winCntrX = engine.getRenderWidth(true)/2, winCntrY = engine.getRenderHeight(true)/2; window.addEventListener("resize", function () {// in case user adjusts window engine.resize(); winCntrX = engine.getRenderWidth(true)/2, // current screen center X winCntrY = engine.getRenderHeight(true)/2; // current screen center Y }); scene.registerBeforeRender(function(){ // other stuff ... var mx = (scene.pointerX-winCntrX) * rotationRate, // get rotation increments my = -(scene.pointerY-winCntrY) * rotationRate; camera.rotation.y += mx; // increment rotation camera.rotation.x += -my; if (camera.rotation.x > Math.PI/2.2) camera.rotation.x = Math.PI/2.2; // up limit if (camera.rotation.x < -Math.PI/2.2) camera.rotation.x = -Math.PI/2.2; // down limit // other stuff ... }); Here's an example: https://www.babylonjs-playground.com/index.html#PFC6AM Have fun! πŸ’₯
  2. coolroar

    Cameras Discussion - Inputs Incongruity

    " ...Using right/left arrow keys (per the instructions)..." Oops, did not intend to leave in the roll control. My understanding: you want to be able to steer the ship in any direction away from straight ahead using yaw and pitch and have the consequential roll cancelled. [right?] That is what the PG does: https://www.babylonjs-playground.com/index.html#2M2LCV It does the pitch and yaw and has resulting roll (relative to World) zeroed (lines 108, 109). My understanding of "...auto roll control..." is that the roll is undesirable, so after yaw and pitch I zero the roll. If my understanding is correct but my solution doesn't produce the expected effect, then ... /// Well, more later, need sleep...
  3. coolroar

    Cameras Discussion - Inputs Incongruity

    ... Because https://www.babylonjs-playground.com/index.html#2M2LCV see lines 108, 109 (instantaneous roll correction I dreamed up last night). Compare with https://www.babylonjs-playground.com/index.html#PFC6AM just works on UniversalCamera.rotation. This seems to make auto roll correction moot. [sorry πŸ€’ ] But all this is just preliminaries for much grander goals: Epic Space Game! πŸ’₯ Right?
  4. coolroar

    Cameras Discussion - Inputs Incongruity

    Hey Phuein, awsome! To better understand what's going on, I added celestial compass to a new version of the above PG: https://www.babylonjs-playground.com/index.html#7MNJ8A Also set camera.fov = 2; for a wider view. Here is similar using UniversalCamera: https://www.babylonjs-playground.com/index.html#2UFUC3#9 I worry that if you are successful implementing immediate roll correction, it will be practically the same as universalCamera. I hope I'm wrong and that you can make it happen, 'cause I've given up on it. Admire your persistence and agility on github. πŸ˜ƒ ☘️
  5. coolroar

    Camera mode like freelancer game

    I've worked up a "flying through space" camera that might be applicable: https://www.babylonjs-playground.com/index.html#Q1RH6C I used the technique in my ZOOM game at jounce.space. Here is a thread where Phuein is trying to create a camera rolls so "up" is always in the same direction: and here: Good luck! πŸ˜ƒ ☘️
  6. coolroar

    Cameras Discussion - Inputs Incongruity

    This has already been done, it's called BABYLON.UniversalCamera(...)! I believe that if you successfully automatically adjust roll continuously so that the horizon stays level, you'll have BABYLON.UniversalCamera the hard way. Hmm... I may be going out on a limb with that. See my April 3 post: πŸ’‘ !
  7. coolroar

    Cameras Discussion - Inputs Incongruity

    Weighing in re. @JohnK 's post: I regard camera.yawPitchRoll(y,p,r) in https://www.babylonjs-playground.com/index.html#Q1RH6C to be applicable to either aircraft, spacecraft, submarines, or ?. Aircraft example: The aircraft's bank indicator points in the direction of the vectorSum(gravity, lateralAcceleration). (lateralAcceleration derived from aircraft's turn rate.) The pilot in real time controls yaw and roll for the desired turn, keeping the aircraft's roll aligned with the bank indicator. I don't try to calculate yaw, pitch, & roll; I am in the loop, increasing or decreasing yaw, pitch, & roll according to the bank indicator, the view, and where I want to go. Although https://www.babylonjs-playground.com/index.html#Q1RH6C has no gravity, it does show how to control yaw, pitch, roll with mouse and arrow keys. Spacecraft example: I have quibbles with the info at http://wtamu.edu/~cbaird/sq/2013/02/16/what-kind-of-space-ships-can-make-banking-turns/ . Baird says: "A space ship turns by reorienting and then firing its engines in the desired direction..." If the spaceship was flying "west" the intended turn to "south" as illustrated does not remove the "westward" velocity component. At some point the ship must have a thrust component opposite the original velocity. This illustration shows my speculation of the most efficient way to change course: So the pilot would use "attitude thrusters" to continuously orient the main thrusters perpendicular to the current course until achieving the desired course. But in sci-fi movies and games people want to bank and swoop and dog-fight etc. Here is a PG that uses an arbitrary bank: https://www.babylonjs-playground.com/#UL7W2M The terrain and stuff is just decoration; without it the PG would resemble typical s.f. fictional physics. 😏
  8. coolroar

    Cameras Discussion - Inputs Incongruity

    Clarification of my previous post: "... you will get roll as you yaw when pitch != 0" should be: " the horizon will tilt (relative to your craft) as you yaw when pitch != 0". The tilted horizon makes you think your craft rolled. (Since at computer we lack the physical sensations of yaw, pitch, & roll). Imagine: You are heading North, straight and level. Then you pitch to straight up. Then you yaw PI/2 to the left. What is your heading? Describe the horizon as seen looking straight ahead. You are headed West, the horizon appears vertical with the ground out the left window. With no craft roll! Pitch(PI/2), Yaw(PI/2) = Roll(PI/2), Pitch(PI/2) = Yaw(PI/2), Roll(PI/2) A series of yaws and pitches can equal a roll: Roll(PI/2) = Pitch(PI/2), Yaw(PI/2), Pitch(-PI/2). (Check my work? πŸ™„) I hope I'm not blathering stuff you already know. 😏 For the benefit of others, I'll also post this to
  9. coolroar

    3D Spaceship Camera

    Clarification of my previous post: "... you will get roll as you yaw when pitch != 0" should be: " the horizon will tilt (relative to your craft) as you yaw when pitch != 0". The tilted horizon makes you think your craft rolled. (Since at computer we lack the physical sensations of yaw, pitch, & roll). Imagine: You are heading North, straight and level. Then you pitch to straight up. Then you yaw PI/2 to the left. What is your heading? Describe the horizon as seen looking straight ahead. You are headed West, the horizon appears vertical with the ground out the left window. With no craft roll! Pitch(PI/2), Yaw(PI/2) = Roll(PI/2), Pitch(PI/2) = Yaw(PI/2), Roll(PI/2) A series of yaws and pitches can equal a roll: Roll(PI/2) = Pitch(PI/2), Yaw(PI/2), Pitch(-PI/2). (Check my work? πŸ™„) I hope I'm not blathering stuff you already know. 😏 For the benefit of others, I'll also post this to
  10. coolroar

    Cameras Discussion - Inputs Incongruity

    "...suffers from a mysterious bug where moving the camera in a circle will slowly Roll it." Do you know that you will get roll naturally as you yaw when pitch != 0 ? Test with pitch locked to zero: https://www.babylonjs-playground.com/index.html#Q1RH6C#2 Try locking pitch to 0.01 etc. (line 80). 😲 ❔
  11. coolroar

    3D Spaceship Camera

    Does "...loses the straight angle..." mean "...the screen point for zero attitude change..."? I think I noticed that once. If true, I don't know why. Work-a-round: periodic re-center: https://www.babylonjs-playground.com/index.html#Q1RH6C#1 "...camera slowly rolling..." I'm not sure what you mean. You know of course that you will get roll as you yaw when pitch != 0. ☘️ 😏
  12. coolroar

    3D Spaceship Camera

    Ok. fine. sheesh. function addYawPitchRollFunction(ob, gravity) { ob.rotationQuaternion = new BABYLON.Quaternion(); ob.rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(ob.rotation.y, ob.rotation.x, ob.rotation.z);// Initialize to current rotation. ob.myGrav ο»Ώ= gravity;ο»Ώ // Set some gravity for autoBank() function. ob.yawPitchRoll = function(yaw, pitch, roll) { var axis = new BABYLON.Vector3(0, 0, -1); // Set an axis to 'z' (roll). var partRotQuat = new BABYLON.Quaternion(); // A var to hold partial rotation. BABYLON.Quaternion.RotationAxisToRef(axis, roll, partRotQuat); // put roll in partRotQuat this.rotationQuaternion.multiplyInPlace(partRotQuat); // Apply roll to rotationQuaternion. // Set axis to '-x' (pitch) and put pitch in partRotQuat. BABYLON.Quaternion.RotationAxisToRef(axis.set(-1, 0, 0), pitch, partRotQuat); this.rotationQuaternion.multiplyInPlace(partRotQuat); // Apply pitch to rotationQuaternion. // Set axis to 'y' (yaw) and put yaw in partRotQuat. BABYLON.Quaternion.RotationAxisToRef(axis.set(0, 1, 0), yaw, partRotQuat); this.rotationQuaternion.multiplyInPlace(partRotQuat); // Apply yaw to rotationQuaternion. this.rotationQuaternion.toEulerAnglesToRef(this.rotation); // Apply rotationQuaternion to (camera.rotation) } ob.autoBank = function(yaw, pitch, speed) { var axis = new BABYLON.Vector3(0, 0, -1); // Set an axis to 'z' (roll). var partRotQuat = new BABYLON.Quaternion(); // A var to hold partial rotation. var fudge = 222; // Whatever, change to make bank angle seem appropriate. var roll = Math.atan2(-yaw*fudge*speed, this.myGrav);// Roll (bank) based on speed, turn rate, & gravity. // get current camera.rotation, substitute roll for camera.rotation.z. this.rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, roll); // Set axis to '-x' (pitch) and put pitch in partRotQuat. BABYLON.Quaternion.RotationAxisToRef(axis.set(-1, 0, 0), pitch, partRotQuat); this.rotationQuaternion.multiplyInPlace(partRotQuat); // Apply pitch to rotationQuaternion. // Set axis to 'y' (yaw) and put yaw in partRotQuat. BABYLON.Quaternion.RotationAxisToRef(axis.set(0, 1, 0), yaw, partRotQuat); this.rotationQuaternion.multiplyInPlace(partRotQuat); // Apply yaw to rotationQuaternion. this.rotationQuaternion.toEulerAnglesToRef(this.rotation);// Apply rotationQuaternion to (camera.rotation) } ob.clearYawPitchRoll = function() { this.rotationQuaternion.set(0, 0, 0, 1); this.rotation.set(0,0,0); } }ο»Ώ πŸ™„
  13. coolroar

    3D Spaceship Camera

    Sorry my code is so obscure & cryptic, but I'm not inclined to add anything except that you can see autoBank() in use here: https://www.babylonjs-playground.com/#UL7W2M Good luck with your projects.
  14. coolroar

    3D Spaceship Camera

    Tested only in examples referred to in this topic and at ZOOM. Agree "this should be applied to the Universal camera, so it can move in 3D freely out-of-the-box". I don't know how to merge to the code-base, and I don't care to learn it at this time. But I'd be happy if someone else were to do that. Here it is with both yawPitchRoll() and autoBank(), plus clearYawPitchRoll(). function addYawPitchRollFunction(ob, gravity) { ob.rotationQuaternion = new BABYLON.Quaternion(); ob.rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(ob.rotation.y, ob.rotation.x, ob.rotation.z); ob.myGrav = gravity; ob.yawPitchRoll = function(yaw, pitch, roll) { var axis = new BABYLON.Vector3(0, 0, -1); var partRotQuat = new BABYLON.Quaternion(); BABYLON.Quaternion.RotationAxisToRef(axis, roll, partRotQuat); this.rotationQuaternion.multiplyInPlace(partRotQuat); BABYLON.Quaternion.RotationAxisToRef(axis.set(-1, 0, 0), pitch, partRotQuat); this.rotationQuaternion.multiplyInPlace(partRotQuat); BABYLON.Quaternion.RotationAxisToRef(axis.set(0, 1, 0), yaw, partRotQuat); this.rotationQuaternion.multiplyInPlace(partRotQuat); this.rotationQuaternion.toEulerAnglesToRef(this.rotation); } ob.autoBank = function(yaw, pitch, speed) { var axis = new BABYLON.Vector3(0, 0, -1); var partRotQuat = new BABYLON.Quaternion(); var roll = Math.atan2(-yaw*222*speed, this.myGrav); this.rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, roll); BABYLON.Quaternion.RotationAxisToRef(axis.set(-1, 0, 0), pitch, partRotQuat); this.rotationQuaternion.multiplyInPlace(partRotQuat); BABYLON.Quaternion.RotationAxisToRef(axis.set(0, 1, 0), yaw, partRotQuat); this.rotationQuaternion.multiplyInPlace(partRotQuat); this.rotationQuaternion.toEulerAnglesToRef(this.rotation); } ob.clearYawPitchRoll = function() { this.rotationQuaternion.set(0, 0, 0, 1); this.rotation.set(0,0,0); } } Cheers -- πŸ‘€ βœ… ✨!
  15. coolroar

    3D Spaceship Camera

    Ok, try this: https://www.babylonjs-playground.com/index.html#Q1RH6C Edit: add playground instructions: ///// Mouse point to desired yaw pitch ///// Left-right arrow keys for roll. ///// ✨ ✈️