placing objects in oolite space - understanding the co-ords

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: another_commander, winston

Post Reply
User avatar
DaddyHoggy
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 8501
Joined: Tue Dec 05, 2006 9:43 pm
Location: Newbury, UK
Contact:

placing objects in oolite space - understanding the co-ords

Post by DaddyHoggy »

I would like to place 10 objects parallel to the imaginary line betwixt nav buoy and docking port, but offset (by 1km) and equi-spaced along that line, is that doable?

Related to this question the following questions:

Is there a rule about which systems have coriolis stations, dodecs, isos (natively - I know oxps can alter this)?

Is there a way to check what kind of station the system already has before replacing it.

Sub-question: How do you replace a station with one of your own?

sub-sub-question: If somebody has Griff's stations (coriolis specifically) and possibly Gritty stations installed too and I want to introduce an alternative version of the Coriolis too - is there a way to make them all play nicely together - I want my version of the Coriolis to be very rare - say 1 in 200 (+/- 50) visits to a system where a Coriolis should be the station type.

Happy to be told RTFM (although a wee nudge in the direction of the right wiki page would be much appreciated).

TIA

(Suddenly I'm a noob again!)
Selezen wrote:
Apparently I was having a DaddyHoggy moment.
Oolite Life is now revealed here
User avatar
Killer Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 2269
Joined: Tue Jan 02, 2007 12:38 pm

Post by Killer Wolf »

this is the bit in Wiki about the coords
http://wiki.alioth.net/index.php/Method ... ding_ships
not tried it myself but my new OXP needs an item somewhere near the WS beacon so i'll lurk this thread for answers!
you'll note this page says stuff appears "near" a point, so i'm not sure how accurate placement is. CmdMcLane can probbly explain stuff better as he pop'd various asteroids and sentinels in his OXP.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: placing objects in oolite space - understanding the co-o

Post by JensAyton »

DaddyHoggy wrote:
I would like to place 10 objects parallel to the imaginary line betwixt nav buoy and docking port, but offset (by 1km) and equi-spaced along that line, is that doable?
Yes. Got your linear algebra hat on?

First, I’m not going to use the nav buoy itself, because you’d have to search for it, there might be more than one, and there might be none since it’s destructible. Instead, I’ll tell you that the buoy is placed 10000 m in front of the station.

Also, you’ll need a vector perpendicular to the station->nav buoy vector. I’ll just construct one randomly.

Code: Select all

this.distributeLitterInVerge = function (role, count, range)
{
    let station = system.mainStation;
    let buoyDirection = station.orientation.vectorForward(); // Unit vector towards buoy

    // Get a random unit vector not parallel or antiparallel to buoyDirection
    let sideVector = null;
    do
    {
        sideVector = Vector3D.randomDirection();
    } while (buoyDirection.dot(sideVector) == 0.0);

    // Exchange sideVector for a vector perpendicular to buoyDirection
    sideVector = sideVector.cross(buoyDirection).multiply(range);

    let basePosition = sideVector.add(station.position);
    let spacing = 10000 / count;
    
    for (let i = 0; i < count; i++)
    {
        let distance = spacing * (i + 0.5);
        let position = buoyDirection.multiply(distance).add(basePosition);
        
        let added = system.addShips(role, 1, position, 0);
        if (added.length > 0)
        {
            added = added[0];
            
            // addShips doesn’t guarantee full precision.
            added.position = position;
        }
    }
}
DaddyHoggy wrote:
Related to this question the following questions:

Is there a rule about which systems have coriolis stations, dodecs, isos (natively - I know oxps can alter this)?
Systems with a techLevel > 10 get either dodecahedron (75 % chance) or icosahedron (25 % chance).
DaddyHoggy wrote:
Is there a way to check what kind of station the system already has before replacing it.
system.mainStation.primaryRole
DaddyHoggy wrote:
Sub-question: How do you replace a station with one of your own?
You can’t.

That is to say, once the main station is created, it’s the one true main station, unless you remove it – at which point a new main station is chosen at random from the stations in the system.

You can specify a main station role in planetinfo.plist, in which case you’ll need to check what the station type is by going there and looking.

None of this is even relevant if you just want to introduce a new variant with one of the standard station roles.
DaddyHoggy wrote:
sub-sub-question: If somebody has Griff's stations (coriolis specifically) and possibly Gritty stations installed too and I want to introduce an alternative version of the Coriolis too - is there a way to make them all play nicely together - I want my version of the Coriolis to be very rare - say 1 in 200 (+/- 50) visits to a system where a Coriolis should be the station type.
Use role weights just like with normal ships.

Code: Select all

roles = "coriolis(0.05)";
Note that with a probability this low, it’s possible it won’t show up anywhere.
Last edited by JensAyton on Sun Jun 20, 2010 12:47 pm, edited 6 times in total.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

Killer Wolf wrote:
this is the bit in Wiki about the coords
http://wiki.alioth.net/index.php/Method ... ding_ships
That stuff’s paleolithic. Don’t even look at it.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

And if you replace

Code: Select all

let spacing = 10000 / 10; 
with

Code: Select all

let spacing = 10000 / (count + 1);
You'll get equally spaced rather than 1km fixed distances between the spawned entities, as another variant given the code doesn't fix the count at 10.[/code]
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

D’oh. It was supposed to be 10000/count. (Not count + 1, because there’s a half-space offset. Which is more æsthetically pleasing is of course for Mr. Hoggy to decide.)
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

Ah yes, didn't see you'd added the offset a little below with the +0.5.
User avatar
DaddyHoggy
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 8501
Joined: Tue Dec 05, 2006 9:43 pm
Location: Newbury, UK
Contact:

Post by DaddyHoggy »

Thank-you - I will play, fail, and get back to you... :wink:

For the moment a final related question (well it's related for me) - is there a way to reverse the model data in a .dat and turn it back into a .obj (so it can be loaded into a 3D modelling tool, edited and saved back out before redoing the .obj -> .dat)?

Ahruman - the code example is much appreciated - I am grateful for such a precise (but generic) example!

Also, if I stick to systems that are TL <=10 they should all be Coriolis stations? (other OXPs notwithstanding), so I could add my Coriolis variant in a system and it may or may not be a station that could be visited by the player (I'm thinking of the station that is placed with the Tionisla Orbital Graveyard - it's just another station - if you know where it is you can go see it, dock with it). Therefore I could have a higher percentage chance of appearance, simply because people would have to chose to visit? Or, it could just be one of the stations that is randomly chosen from the station list when the system is created... (not sure which I would prefer to happen...)
Selezen wrote:
Apparently I was having a DaddyHoggy moment.
Oolite Life is now revealed here
User avatar
Killer Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 2269
Joined: Tue Jan 02, 2007 12:38 pm

Post by Killer Wolf »

"That stuff’s paleolithic. Don’t even look at it." oh, heh.

if we're (i'm) wanting to add our own stations to a system, given we can't replace the game's choice of main station how do we place it in orbit say 90 or 180 around the planet from the game station, and orient the face towards the planet?

edit, @ DH :
there's a reverse Python script called DAT2OBJ you ca use, should be in here somewhere i believe
https://bb.oolite.space/viewtopic.ph ... bj&start=0
User avatar
DaddyHoggy
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 8501
Joined: Tue Dec 05, 2006 9:43 pm
Location: Newbury, UK
Contact:

Post by DaddyHoggy »

@KW - nice one. Downloaded!
Selezen wrote:
Apparently I was having a DaddyHoggy moment.
Oolite Life is now revealed here
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Post by Kaks »

Killer Wolf wrote:

if we're (i'm) wanting to add our own stations to a system, given we can't replace the game's choice of main station how do we place it in orbit say 90 or 180 around the planet from the game station, and orient the face towards the planet?
You can specify which main station to use for a specific system inside planetinfo.plist

Its initial position will be assigned by the system populator, but you can change its position and orientation from javascript.

If you add a world script with a shipWillExitWitchSpace event, you can test if you're in the right system / the main station is 'your' station, then provide all the appropriate changes in there: reposition it, change its orientation, add more bits & bobs floating in space nearby, etc...


Actually, this is just half of the story... To make sure the player will see the exact same system if they load a game previously saved from inside 'your' station, you also need some code in shipWillLaunchFromStation: in there you need to check to see if your code has already modified the system the way you want it, and if not, call the shipWillExitWitchSpace code to rearrange the system exactly the way it should be...
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
Zieman
---- E L I T E ----
---- E L I T E ----
Posts: 680
Joined: Tue Sep 01, 2009 11:55 pm
Location: in maZe

Re: placing objects in oolite space - understanding the co-o

Post by Zieman »

Ahruman wrote:
Systems with a techLevel > 10 get either dodecahedron (75 % chance) or icosahedron (25 % chance).
Is this hardcoded or can you alter these probabilities with .plist -tampering?
...and keep it under lightspeed!

Friendliest Meteor Police that side of Riedquat

[EliteWiki] Far Arm ships
[EliteWiki] Z-ships
[EliteWiki] Baakili Far Trader
[EliteWiki] Tin of SPAM
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Post by Kaks »

You should be able to alter the standard populator behaviour by adding the right conditions inside planetinfo.plist... unfortunately Brain is a bit broken atm so can't provide the right example...
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
Post Reply