Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

JBScreen.JBScreenMapFlat


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
// ============================================================================
// JBScreenMapFlat
// Copyright 2003 by Mychaeel <mychaeel@planetjailbreak.com>
// $Id: JBScreenMapFlat.uc,v 1.1.1.1 2003/06/30 22:05:18 mychaeel Exp $
//
// Renders a flat, isometric minimap on a ScriptedTexture.
// ============================================================================


class JBScreenMapFlat extends JBScreenMap
  placeable;


// ============================================================================
// Replication
// ============================================================================

replication {

  reliable if (Role == ROLE_Authority)
    CoordPlane,
    CoordBounds,
    CoordCustom;
  }


// ============================================================================
// Types
// ============================================================================

enum ECoordPlane {

  CoordPlane_ViewTop,    // UnrealEd top view
  CoordPlane_ViewFront,  // UnrealEd front view
  CoordPlane_ViewSide,   // UnrealEd side view
  CoordPlane_Custom,     // custom coordinate system
  };


struct TCoordBounds {

  var() float Top;       // coordinate corresponding to upper  texture edge
  var() float Left;      // coordinate corresponding to left   texture edge
  var() float Right;     // coordinate corresponding to right  texture edge
  var() float Bottom;    // coordinate corresponding to bottom texture edge
  };


// The custom coordinate system users can set up here is defined as follows:
//
//   LocationOrigin         World location corresponding to the lower-left
//                          corner of the texture. (This value has one degree
//                          of freedom due to the isometric projection.)
//
//   VectorAxisHorizontal   Axes defining the projected plane in the world.
//   VectorAxisVertical     The length of these vectors defines the distance in
//                          world space along the edges of the texture from
//                          corner to corner. The axes don't have to be
//                          perpendicular, but they must be non-zero.

struct TCoordCustom {

  var() vector LocationOrigin;        // location of coordinate system origin
  var() vector VectorAxisHorizontal;  // scaled vector horizontal texture axis
  var() vector VectorAxisVertical;    // scaled vector vertical   texture axis
  };


// ============================================================================
// Properties
// ============================================================================

var() ECoordPlane  CoordPlane;   // coordinate plane locations are projected on

var() TCoordBounds CoordBounds;  // coordinate bounds for top, front, side view
var() TCoordCustom CoordCustom;  // coordinate system for custom view


// ============================================================================
// PrepareCoords
//
// Translates any of the simplified coordinate views to their coordinate
// system representation. Flips the coordinate system so that the origin is
// set into the upper-left texture corner, and inverts the axis vectors.
// ============================================================================

simulated protected function bool PrepareCoords() {

  local vector VectorAxes;

  if (CoordPlane != CoordPlane_Custom) {
     if (CoordBounds.Left == CoordBounds.Right ||
         CoordBounds.Top  == CoordBounds.Bottom)
       return False;

    CoordCustom.LocationOrigin       = vect(0,0,0);
    CoordCustom.VectorAxisHorizontal = vect(0,0,0);
    CoordCustom.VectorAxisVertical   = vect(0,0,0);
    
    VectorAxes.X = CoordBounds.Right - CoordBounds.Left;
    VectorAxes.Y = CoordBounds.Top   - CoordBounds.Bottom;
    }

  switch (CoordPlane) {
    case CoordPlane_ViewTop:
      CoordCustom.LocationOrigin.X = CoordBounds.Left;
      CoordCustom.LocationOrigin.Y = CoordBounds.Bottom;
      CoordCustom.VectorAxisHorizontal.X = VectorAxes.X;
      CoordCustom.VectorAxisVertical  .Y = VectorAxes.Y;
      break;
    
    case CoordPlane_ViewFront:
      CoordCustom.LocationOrigin.X = CoordBounds.Left;
      CoordCustom.LocationOrigin.Z = CoordBounds.Bottom;
      CoordCustom.VectorAxisHorizontal.X = VectorAxes.X;
      CoordCustom.VectorAxisVertical  .Z = VectorAxes.Y;
      break;
    
    case CoordPlane_ViewSide:
      CoordCustom.LocationOrigin.Y = CoordBounds.Left;
      CoordCustom.LocationOrigin.Z = CoordBounds.Bottom;
      CoordCustom.VectorAxisHorizontal.Y = VectorAxes.X;
      CoordCustom.VectorAxisVertical  .Z = VectorAxes.Y;
      break;
    }

  if (VSize(CoordCustom.VectorAxisHorizontal) == 0.0 ||
      VSize(CoordCustom.VectorAxisVertical)   == 0.0)
    return False;

  CoordCustom.LocationOrigin += CoordCustom.VectorAxisVertical;
  CoordCustom.VectorAxisHorizontal *= SizeScriptedTexture.X /  Square(VSize(CoordCustom.VectorAxisHorizontal));
  CoordCustom.VectorAxisVertical   *= SizeScriptedTexture.Y / -Square(VSize(CoordCustom.VectorAxisVertical));

  return True;
  }


// ============================================================================
// CalcLocation
//
// Calculates and returns the texture pixel coordinates corresponding to the
// given world coordinates.
// ============================================================================

simulated function vector CalcLocation(vector LocationWorld) {

  local vector LocationIcon;
  
  LocationWorld -= CoordCustom.LocationOrigin;
  LocationIcon.X = LocationWorld dot CoordCustom.VectorAxisHorizontal;
  LocationIcon.Y = LocationWorld dot CoordCustom.VectorAxisVertical;
  
  return LocationIcon;
  }


// ============================================================================
// Defaults
// ============================================================================

defaultproperties {

  CoordPlane = CoordPlane_ViewTop;
  CoordBounds = (Top=8192,Left=-8192,Right=8192,Bottom=-8192);
  }

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Di 1.7.2003 00:05:18.000 - Creation time: Do 14.8.2014 09:58:43.030 - Created with UnCodeX