Rotating engine nacelles with pitch
Moderators: winston, another_commander
Rotating engine nacelles with pitch
Hello
My first post on here, i've been playing with my first OXP, which is a ship thats supposed to be a fast frigate/blockade runner etc.
With a nod to the 'starbridge' (and also the neolite fer-de-lance for looks) I wanted to rotate the engines, which i have made as separate sub entities as the ship pitches and yaws, which would account for a very manoeuvrable able ship despite its size.
Any idea how i could rotate the sub entities as the ship yaws and pitches, is this even possible in oolite? I've included the wings files in the oxp should anybody else want to play, i've yet to texture the ship and the stats are waaayy to uber at the moment as i'm still building.
http://www.filedropper.com/dawnshipoxp
Thanks,
Dave
My first post on here, i've been playing with my first OXP, which is a ship thats supposed to be a fast frigate/blockade runner etc.
With a nod to the 'starbridge' (and also the neolite fer-de-lance for looks) I wanted to rotate the engines, which i have made as separate sub entities as the ship pitches and yaws, which would account for a very manoeuvrable able ship despite its size.
Any idea how i could rotate the sub entities as the ship yaws and pitches, is this even possible in oolite? I've included the wings files in the oxp should anybody else want to play, i've yet to texture the ship and the stats are waaayy to uber at the moment as i'm still building.
http://www.filedropper.com/dawnshipoxp
Thanks,
Dave
- Diziet Sma
- ---- E L I T E ----
- Posts: 6312
- Joined: Mon Apr 06, 2009 12:20 pm
- Location: Aboard the Pitviper S.E. "Blackwidow"
Re: Rotating engine nacelles with pitch
G'day, and welcome aboard, daveangel!
That's quite an intro, for your first post.. you've been well and truly bitten by the Darkside, eh?
Interesting idea you have for the engines, and a nice looking ship, too..
I'm afraid I can't help with your rotation question, but I'd imagine it's just a question of applying the correct math to it.. hopefully some of our clever boffins will be along soon to help out.
That's quite an intro, for your first post.. you've been well and truly bitten by the Darkside, eh?
Interesting idea you have for the engines, and a nice looking ship, too..
I'm afraid I can't help with your rotation question, but I'd imagine it's just a question of applying the correct math to it.. hopefully some of our clever boffins will be along soon to help out.
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied
Re: Rotating engine nacelles with pitch
How comfortable are you with quaternions? (If the answer is not very, don't worry, no-one else understands them either)
At a high level, what you need to do is:
- set a (Javascript) ship script on the ship
- have that script, when the ship is spawned, start a frame callback (a short piece of code which runs every frame)
- the frame callback then reads the 'roll', 'pitch' and 'yaw' parameters of the ship to get its current turn rates, and writes appropriate values to the 'orientation' parameter of each engine subentity.
The Quaternion rotate function is the easiest way to get a quaternion for a rotation around an arbitrary vector. For subentities, the identity quaternion [1,0,0,0] aligns the subentity to the ship's standard XYZ axes. So, to do the pitch up and down in your right-hand screenshot, you'd want to rotate their orientation quaternion around their X axis.
In this case, probably easiest is to have the frame callback reset the orientation to [1,0,0,0] at the start of its run, and then apply the correct series of rotations for the turn rate as it goes, rather than trying to incrementally adjust the orientation a frame at a time.
Good luck...
At a high level, what you need to do is:
- set a (Javascript) ship script on the ship
- have that script, when the ship is spawned, start a frame callback (a short piece of code which runs every frame)
- the frame callback then reads the 'roll', 'pitch' and 'yaw' parameters of the ship to get its current turn rates, and writes appropriate values to the 'orientation' parameter of each engine subentity.
The Quaternion rotate function is the easiest way to get a quaternion for a rotation around an arbitrary vector. For subentities, the identity quaternion [1,0,0,0] aligns the subentity to the ship's standard XYZ axes. So, to do the pitch up and down in your right-hand screenshot, you'd want to rotate their orientation quaternion around their X axis.
In this case, probably easiest is to have the frame callback reset the orientation to [1,0,0,0] at the start of its run, and then apply the correct series of rotations for the turn rate as it goes, rather than trying to incrementally adjust the orientation a frame at a time.
Good luck...
Re: Rotating engine nacelles with pitch
Thanks Cim.
Do you know of any other ships that use addFrameCallBack so i can find an example?
Then i just need to work out how to reference the subentity.
Kind regards,
Dave
Do you know of any other ships that use addFrameCallBack so i can find an example?
Then i just need to work out how to reference the subentity.
Kind regards,
Dave
Re: Rotating engine nacelles with pitch
That looks soo cool reminds me a bit of the ship from phantom menace, the silver sleek machine.... or maybe not, possibly Years ago maybe 8 or 9 years ago i made a station a sirf station (cant remember what the initials stand for now) where the subentities revolved within and around the static structure, but obviously that obviously didnt involve frame callacks etc, (as i'm way to thick) but the engine concept is an amazing idea, and hope to see it flying soon!
Re: Rotating engine nacelles with pitch
I seam to have hit a hurdle almost immediately, can anyone tell my what illegal character i have at line 1 as the java console tells me, or is this a red herring and there is another problem
Thanks,
Dave
Code: Select all
this.name = “Dawn”;
this.author = “Dave Adcock”;
this.copyright = "� 2014 Dave Adcock.”;
this.description = “Rotate nacelles with pitch for vectored thrust.”;
this.version = “1.0”;
this.shipLaunchedFromStation = function(station)
{
// Initialise frame callback
this.callbackID = addFrameCallback(this.moveEngines.bind(this));
this.QPort = new Quaternion([1,0,0,0]);
this.QStarboard = new Quaternion([0,0,0,1]);
}
this.shipSpawned = function ()
{
// Add launcher for AI
}
this.shipDied = function ()
{
// release callback
}
this.moveEngines = function()
{
//Set Nacelles
//Port
this.ship.subEntities[0].orientation = this.QPort;
//Starboard
this.ship.subEntities[1].orientation = this.QStarboard;
}
this.shipDockedWithStation = function(station)
{
// remove callback
}
Dave
-
- Quite Grand Sub-Admiral
- Posts: 6682
- Joined: Wed Feb 28, 2007 7:54 am
Re: Rotating engine nacelles with pitch
Probably it is a file encoding issue. Is the file UTF-8, ANSI encoded or other? I think most files in Oolite are UTF-8 without Byte Order Mark encoded.
Also, if you are on Windows and are using Notepad, you should switch to another text editor. Notepad is known to cause problems with the Oolite text files.
Also, if you are on Windows and are using Notepad, you should switch to another text editor. Notepad is known to cause problems with the Oolite text files.
- Disembodied
- Jedi Spam Assassin
- Posts: 6885
- Joined: Thu Jul 12, 2007 10:54 pm
- Location: Carter's Snort
Re: Rotating engine nacelles with pitch
Copyright symbol looks like it's not displaying properly ... whether this is the problem or just a symptom, I don't know.daveangel wrote:Code: Select all
this.copyright = "� 2014 Dave Adcock.”;
- Diziet Sma
- ---- E L I T E ----
- Posts: 6312
- Joined: Mon Apr 06, 2009 12:20 pm
- Location: Aboard the Pitviper S.E. "Blackwidow"
Re: Rotating engine nacelles with pitch
Notepad++ is what we usually recommend for Windows users.another_commander wrote:Probably it is a file encoding issue. Is the file UTF-8, ANSI encoded or other? I think most files in Oolite are UTF-8 without Byte Order Mark encoded.
Also, if you are on Windows and are using Notepad, you should switch to another text editor. Notepad is known to cause problems with the Oolite text files.
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied
Re: Rotating engine nacelles with pitch
OK, it defiantly was an encoding problem, really weird though because i had to completely start again in text wrangler - no copy and pasting - i must of had a character hidden somewhere!
Thanks for the help.
Thanks for the help.
Re: Rotating engine nacelles with pitch
OK, really making progress now.
Just need to change the location on where the engines rotate on and then move the exhaust plume
Just need to change the location on where the engines rotate on and then move the exhaust plume
Code: Select all
this.name = "Dawn";
this.author = "Dave Angel";
this.copyright = "2014 Dave Angel"
this.description = "rotate engine nacelles with pitch for vectored thrust";
this.version = 1.0;
this.shipLaunchedFromStation = function(station)
{
//initialise frame callback
this.callbackID = addFrameCallback(this.moveEngines.bind(this));
this.QPort = new Quaternion([1,0,0,0]);
this.QStarboard = new Quaternion([1,0,0,0]);
this.percentPitch = 0.0;
this.percentRoll = 0.0;
this.rotationPort = 0.0;
this.rotationStarboard = 0.0;
}
this.shipSpawned = function()
{
//Place holder for AI initialisation
}
this.moveEngines = function()
{
//Get Pitch and Roll
this.percentPitch = (player.ship.pitch/player.ship.maxPitch);
this.percentRoll = (player.ship.roll/player.ship.maxRoll);
if (this.percentPitch != 0)
{
this.rotationPort = (this.percentPitch);
this.rotationStarboard = (this.percentPitch);
}
if (this.percentRoll!= 0)
{
this.rotationPort = (this.percentRoll*-1);
this.rotationStarboard = (this.percentRoll);
}
//Set nacelles
//Port
this.ship.subEntities[0].orientation = this.QPort.rotateX(this.rotationPort);
//Starboard
this.ship.subEntities[1].orientation = this.QStarboard.rotateX(this.rotationStarboard);
}
this.shipDockedWithStation = function(station)
{
//Place holder to remove callback
}
- Norby
- ---- E L I T E ----
- Posts: 2577
- Joined: Mon May 20, 2013 9:53 pm
- Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
- Contact:
Re: Rotating engine nacelles with pitch
Hi daveangel and welcome here!
Very promising first posts.
I suggest to play with Quaternion calculator to see the logic behind the numbers (thanks to the author, I found it in a signature in this forum).
I am using rotations in [wiki]ReverseControl[/wiki] OXP, maybe the code will be useful.
Very promising first posts.
I suggest to play with Quaternion calculator to see the logic behind the numbers (thanks to the author, I found it in a signature in this forum).
I am using rotations in [wiki]ReverseControl[/wiki] OXP, maybe the code will be useful.
- ClymAngus
- ---- E L I T E ----
- Posts: 2514
- Joined: Tue Jul 08, 2008 12:31 am
- Location: London England
- Contact:
Re: Rotating engine nacelles with pitch
Ah! The Starbridge! Yes I kind of ripped that off to to make the kirin...
I like where your going with this however!
I like where your going with this however!
Re: Rotating engine nacelles with pitch
Just also be aware that the exhaust plumes aren't visible to JS in 1.77.1, but if I understand things correctly they will be available as special sub-entities in 1.80 when it's released.
So you may need to hang on a little while until it's fully released for a general release of the ship for people who aren't working with trunk. But aside from that it's looking good, you seem to have things in hand (if you survive the battle with the quaternions without your brain turning to evil juice).
So you may need to hang on a little while until it's fully released for a general release of the ship for people who aren't working with trunk. But aside from that it's looking good, you seem to have things in hand (if you survive the battle with the quaternions without your brain turning to evil juice).
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
- Cody
- Sharp Shooter Spam Assassin
- Posts: 16081
- Joined: Sat Jul 04, 2009 9:31 pm
- Location: The Lizard's Claw
- Contact:
Re: Rotating engine nacelles with pitch
<sniggers> Doctor, my brain hurts!Thargoid wrote:... if you survive the battle with the quaternions without your brain turning to evil juice.
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
And any survivors, their debts I will certainly pay. There's always a way!