Drawing#

public class Drawing#

Provides functionality for drawing objects in the flight scene, the map view, the editor and the tracking station.

Note

For drawing and interacting with the user interface, see the UI service. Objects drawn by a client are removed when that client disconnects.

Line addLine(org.javatuples.Triplet<Double, Double, Double> start, org.javatuples.Triplet<Double, Double, Double> end, SpaceCenter.ReferenceFrame referenceFrame, boolean visible)#

Draw a line in the scene.

Parameters:
  • start (org.javatuples.Triplet) – Position of the start of the line.

  • end (org.javatuples.Triplet) – Position of the end of the line.

  • referenceFrame (SpaceCenter.ReferenceFrame) – Reference frame that the positions are in.

  • visible (boolean) – Whether the line is visible.

Game Scenes:

Flight, Tracking Station, Editor Vab, Editor Sph

Line addDirection(org.javatuples.Triplet<Double, Double, Double> direction, SpaceCenter.ReferenceFrame referenceFrame, float length, boolean visible)#

Draw a direction vector in the scene, starting from the origin of the given reference frame.

Parameters:
  • direction (org.javatuples.Triplet) – Direction to draw the line in.

  • referenceFrame (SpaceCenter.ReferenceFrame) – Reference frame that the direction is in and defines the start position.

  • length (float) – The length of the line.

  • visible (boolean) – Whether the line is visible.

Game Scenes:

Flight, Tracking Station, Editor Vab, Editor Sph

Line addDirectionFromCom(org.javatuples.Triplet<Double, Double, Double> direction, SpaceCenter.ReferenceFrame referenceFrame, float length, boolean visible)#

Draw a direction vector in the scene, from the center of mass of the active vessel.

Parameters:
  • direction (org.javatuples.Triplet) – Direction to draw the line in.

  • referenceFrame (SpaceCenter.ReferenceFrame) – Reference frame that the direction is in.

  • length (float) – The length of the line.

  • visible (boolean) – Whether the line is visible.

Game Scenes:

Flight

java.util.List<Line> addAxes(SpaceCenter.ReferenceFrame referenceFrame, float length, boolean visible)#

Draw the axes of a reference frame in the scene, as arrows from its origin.

Parameters:
  • referenceFrame (SpaceCenter.ReferenceFrame) – The reference frame.

  • length (float) – The length of each axis.

  • visible (boolean) – Whether the axes are visible.

Returns:

The lines for the x, y and z axes, colored red, green and blue.

Game Scenes:

Flight, Tracking Station, Editor Vab, Editor Sph

Polygon addPolygon(java.util.List<org.javatuples.Triplet<Double, Double, Double>> vertices, SpaceCenter.ReferenceFrame referenceFrame, boolean visible)#

Draw a polygon in the scene, defined by a list of vertices.

Parameters:
  • vertices (java.util.List) – Vertices of the polygon.

  • referenceFrame (SpaceCenter.ReferenceFrame) – Reference frame that the vertices are in.

  • visible (boolean) – Whether the polygon is visible.

Game Scenes:

Flight, Tracking Station, Editor Vab, Editor Sph

Polyline addPolyline(java.util.List<org.javatuples.Triplet<Double, Double, Double>> vertices, SpaceCenter.ReferenceFrame referenceFrame, boolean visible)#

Draw an open line through a list of vertices in the scene.

Parameters:
Game Scenes:

Flight, Tracking Station, Editor Vab, Editor Sph

Circle addCircle(org.javatuples.Triplet<Double, Double, Double> center, org.javatuples.Triplet<Double, Double, Double> normal, double radius, SpaceCenter.ReferenceFrame referenceFrame, boolean visible)#

Draw a circle in the scene.

Parameters:
  • center (org.javatuples.Triplet) – Position of the center of the circle.

  • normal (org.javatuples.Triplet) – Normal of the plane of the circle.

  • radius (double) – Radius of the circle, in meters.

  • referenceFrame (SpaceCenter.ReferenceFrame) – Reference frame that the position and normal are in.

  • visible (boolean) – Whether the circle is visible.

Game Scenes:

Flight, Tracking Station, Editor Vab, Editor Sph

Note

Throws an exception if the normal is zero.

Arc addArc(org.javatuples.Triplet<Double, Double, Double> center, org.javatuples.Triplet<Double, Double, Double> normal, org.javatuples.Triplet<Double, Double, Double> startDirection, double angle, double radius, SpaceCenter.ReferenceFrame referenceFrame, boolean visible)#

Draw an arc of a circle in the scene.

Parameters:
  • center (org.javatuples.Triplet) – Position of the center of the arc.

  • normal (org.javatuples.Triplet) – Normal of the plane of the arc.

  • startDirection (org.javatuples.Triplet) – Direction from the center to the start of the arc.

  • angle (double) – Angle of the arc, in radians.

  • radius (double) – Radius of the arc, in meters.

  • referenceFrame (SpaceCenter.ReferenceFrame) – Reference frame that the position and directions are in.

  • visible (boolean) – Whether the arc is visible.

Game Scenes:

Flight, Tracking Station, Editor Vab, Editor Sph

Note

The arc turns counterclockwise about the normal, seen from the side it points to. Throws an exception if the normal is zero, or the start direction is parallel to it.

OrbitPath addOrbit(SpaceCenter.Orbit orbit, boolean visible)#

Draw the path of an orbit in the scene.

Parameters:
  • orbit (SpaceCenter.Orbit) – The orbit.

  • visible (boolean) – Whether the path is visible.

Game Scenes:

Flight, Tracking Station

Note

The path follows the orbit as it changes, and ends where the orbit leaves the sphere of influence of its body.

Point addPoint(org.javatuples.Triplet<Double, Double, Double> position, SpaceCenter.ReferenceFrame referenceFrame, boolean visible)#

Draw a point in the scene, as a dot that keeps its size on screen.

Parameters:
  • position (org.javatuples.Triplet) – Position of the point.

  • referenceFrame (SpaceCenter.ReferenceFrame) – Reference frame that the position is in.

  • visible (boolean) – Whether the point is visible.

Game Scenes:

Flight, Tracking Station, Editor Vab, Editor Sph

Box addBox(org.javatuples.Triplet<Double, Double, Double> center, org.javatuples.Triplet<Double, Double, Double> size, SpaceCenter.ReferenceFrame referenceFrame, org.javatuples.Quartet<Double, Double, Double, Double> rotation, boolean visible)#

Draw the edges of a box in the scene.

Parameters:
  • center (org.javatuples.Triplet) – Position of the center of the box.

  • size (org.javatuples.Triplet) – Lengths of the sides of the box along its x, y and z axes, in meters.

  • referenceFrame (SpaceCenter.ReferenceFrame) – Reference frame that the position and rotation are in.

  • rotation (org.javatuples.Quartet) – Rotation of the box, as a quaternion.

  • visible (boolean) – Whether the box is visible.

Game Scenes:

Flight, Tracking Station, Editor Vab, Editor Sph

Sphere addSphere(org.javatuples.Triplet<Double, Double, Double> center, double radius, SpaceCenter.ReferenceFrame referenceFrame, boolean visible)#

Draw a solid sphere in the scene.

Parameters:
  • center (org.javatuples.Triplet) – Position of the center of the sphere.

  • radius (double) – Radius of the sphere, in meters.

  • referenceFrame (SpaceCenter.ReferenceFrame) – Reference frame that the position is in.

  • visible (boolean) – Whether the sphere is visible.

Game Scenes:

Flight, Tracking Station, Editor Vab, Editor Sph

Text addText(String text, SpaceCenter.ReferenceFrame referenceFrame, org.javatuples.Triplet<Double, Double, Double> position, org.javatuples.Quartet<Double, Double, Double, Double> rotation, boolean visible)#

Draw text in the scene.

Parameters:
  • text (String) – The string to draw.

  • referenceFrame (SpaceCenter.ReferenceFrame) – Reference frame that the text position is in.

  • position (org.javatuples.Triplet) – Position of the text.

  • rotation (org.javatuples.Quartet) – Rotation of the text, as a quaternion.

  • visible (boolean) – Whether the text is visible.

Game Scenes:

Flight, Tracking Station, Editor Vab, Editor Sph

NavballMarker addNavballMarker(org.javatuples.Triplet<Double, Double, Double> direction, SpaceCenter.ReferenceFrame referenceFrame, boolean visible)#

Draw a marker on the navball, pointing in the given direction.

Parameters:
  • direction (org.javatuples.Triplet) – Direction that the marker points in.

  • referenceFrame (SpaceCenter.ReferenceFrame) – Reference frame that the direction is in.

  • visible (boolean) – Whether the marker is visible.

Game Scenes:

Flight

MapMarker addMapMarker(org.javatuples.Triplet<Double, Double, Double> position, SpaceCenter.ReferenceFrame referenceFrame, MapMarkerIcon icon, String caption, boolean visible)#

Draw a marker in the map view, with one of the game’s own map icons.

Parameters:
  • position (org.javatuples.Triplet) – Position of the marker.

  • referenceFrame (SpaceCenter.ReferenceFrame) – Reference frame that the position is in.

  • icon (MapMarkerIcon) – The icon that the marker is drawn with.

  • caption (String) – The caption shown when the mouse is over the marker.

  • visible (boolean) – Whether the marker is visible.

Game Scenes:

Flight, Tracking Station

Image addImage(byte[] data)#

Load an image that markers can be drawn with, from the contents of a PNG or JPEG file. The transparency of a PNG image is kept.

Parameters:
  • data (byte[]) – The contents of the image file.

Game Scenes:

Flight, Tracking Station, Editor Vab, Editor Sph

Note

Throws an exception if the data is not a PNG or JPEG image.

void clear(boolean clientOnly)#

Remove all objects being drawn.

Parameters:
  • clientOnly (boolean) – If true, only remove objects created by the calling client.

Game Scenes:

Flight, Tracking Station, Editor Vab, Editor Sph