Page 1 of 1

when ship is in a system

Posted: Sun Apr 05, 2009 3:02 pm
by dagg
will this be right?

Code: Select all

un->Position()==SystemLocation(_Universe->activeStarSystem()->getFileName())

Re: when ship is in a system

Posted: Tue Apr 07, 2009 5:03 am
by ace123
Not at all!
Notice that you are losing information when you do "_Universe->activeStarSystem()", so anything that is true there will only be true for the whole system--and all units within the system.

The un->Position() is a 3d coordinate with double values (QVector) of the 3d position within the system, usually units relative to the sun and some predetermined axes.

System Location is a 3d vector from the center of the galaxy, in relative units (usually a much smaller scale, I think they might be in light years or something like that). These are not as accurate and only used for the Navigation Computer map, so they are inaccurate floating point values (Vector). So you aren't even allowed to interchange the two.

May I ask why it would be useful to have those two values be equal?

Re: when ship is in a system

Posted: Tue Apr 07, 2009 6:49 am
by dagg
has mentioned in another topic, I'm working on adding support to custom distance between systems (depending on system xyz values and a value from the config file), now I've got the system to system working but I want to add the ability to retrieve the position of the unit in the galaxy (let say I went from one planet to another and halfway I want to go to a third planet) so I need to calculate the the distance from that position to the new destination system.

Re: when ship is in a system

Posted: Thu Apr 09, 2009 12:02 am
by ace123
ah-- In that case, you have to decide how big you want the gap between systems to be, call it GalaxyScale.

I take it you are trying to do something like (player->Position - target->Position() + (SystemLocation(player->activeSystem) - SystemLocation(target->activeSystem)) * GalaxyScale)

You need to make sure to do the subtractions in the right order so that you lose the smallest amount of significant digits.

Re: when ship is in a system

Posted: Fri Apr 10, 2009 7:13 am
by dagg
here is what I'm trying to do:
I've generated a new galaxy based on distances. the distances are calculated using the euler formula, moreover, I read from the config file the ratio of the map.
then I multiply the distance I got with the ratio and I have the distances already in km (the map is generated from light year base scale)
not sure how it is helping me in that situation?

Re: when ship is in a system

Posted: Tue Apr 14, 2009 6:45 am
by dagg
still don't understand how this formula helps me...

Re: when ship is in a system

Posted: Wed Apr 15, 2009 1:36 am
by ace123
I probably don't understand your question.
I think the issue is that VS does not take into account accurate distances when in transit between systems.

The problem is that there is no real concept of the distance from your ship to a system. Either you are in a system, or you are not in a system. The whole thing about being able to travel far from the sun to teleport to another system is really a hack, so it doesn't take into account anything other than how far you are from the sun. I like to think of it more like a sort of autopilot--where you just kind of go to sleep while traveling between systems.

The way things used to work for jumping between systems, before the recent change, is that there would be a crosshair and you go need to be traveling in that direction. If you choose to change to a different target system then the crosshair will move.

If you want everything to work right, the only way will be to combine everything into one system, but then there are obvious performance considerations.

Re: when ship is in a system

Posted: Wed Apr 15, 2009 9:01 am
by dagg
so why not use the external coordinates? e.g. the xyz from milkey_way.xml?

will you consider changing this?