Jump to content

World, screen and scaled spaces


Recommended Posts

Hi, we (RemoteTech team) are perplexed by a coordination-space issue (link). Our problem is basically that satellite connection lines in Map View (aka planetarium) sometimes invert in axis for no apparent reason. We tracked down to the offending codes in our RT codebase (link).

var start = camera.WorldToScreenPoint(ScaledSpace.LocalToScaledSpace(edge.A.Position));
var end = camera.WorldToScreenPoint(ScaledSpace.LocalToScaledSpace(edge.B.Position));
//the edge (A, B) is a connection between two satellites/ground stations
//Position is in the world space

We observed that the start and end vectors sometimes are suddenly shifted when a player's camera satisfies the conditions for shifting KSP's scaled space factor/offset, resulting in providing completely different vectors to RemoteTech codes. Given that we, the fresh blood for RT, are relatively new to the KSP mod scene, we seek the assistance of expert modders regarding KSP's world, screen and scaled spaces.

Our question is: How should we solve the problem, that may be linked to KSP's inner codes in LocalToScaledSpace()?

//Decompiled ScaledSpace class of KSP
public static Vector3d LocalToScaledSpace(Vector3d localSpacePoint)
{
  return localSpacePoint * (double)ScaledSpace.InverseScaleFactor - ScaledSpace.totalOffset;
}

 

Edited by TaxiService
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...