Page 1 of 1

placing objects in oolite space - understanding the co-ords

Posted: Sun Jun 20, 2010 12:55 am
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!)

Posted: Sun Jun 20, 2010 7:54 am
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.

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

Posted: Sun Jun 20, 2010 8:23 am
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.

Posted: Sun Jun 20, 2010 8:25 am
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.

Posted: Sun Jun 20, 2010 8:50 am
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]

Posted: Sun Jun 20, 2010 8:57 am
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.)

Posted: Sun Jun 20, 2010 9:09 am
by Thargoid
Ah yes, didn't see you'd added the offset a little below with the +0.5.

Posted: Sun Jun 20, 2010 12:14 pm
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...)

Posted: Sun Jun 20, 2010 12:36 pm
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

Posted: Sun Jun 20, 2010 12:48 pm
by DaddyHoggy
@KW - nice one. Downloaded!

Posted: Sun Jun 20, 2010 1:42 pm
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...

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

Posted: Sun Jun 20, 2010 2:56 pm
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?

Posted: Sun Jun 20, 2010 3:03 pm
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...