Beispiel #1
0
static int Leave_DS_Bay(MAP * map, MECH * ds, MECH * mech, dbref frombay)
{
	MECH *car = NULL;

	StopBSuitSwarmers(FindObjectsData(mech->mapindex), mech, 1);
	MechLOSBroadcast(mech, "has left the bay.");
	/* We escape confines of the bay to open air/land! */
	mech_Rsetmapindex(GOD, (void *) mech, tprintf("%d", ds->mapindex));
	if(MechCarrying(mech) > 0)
		car = getMech(MechCarrying(mech));
	if(car)
		mech_Rsetmapindex(GOD, (void *) car, tprintf("%d", ds->mapindex));
	DOCHECKMA0(mech->mapindex == map->mynum,
			   "Fatal error: Unable to find the map 'ship is on.");
	loud_teleport(mech->mynum, mech->mapindex);
	if(car)
		loud_teleport(car->mynum, mech->mapindex);
	mech_notify(mech, MECHALL, "You have left the bay.");
	DS_Place(ds, mech, frombay);
	if(car)
		MirrorPosition(mech, car, 0);
	MechLOSBroadcasti(mech, ds, "has left %s's bay.");
	mech_notify(ds, MECHALL, tprintf("%s has left the bay.",
									 GetMechID(mech)));
	ContinueFlying(mech);
	if(In_Character(mech->mynum) && Location(MechPilot(mech)) != mech->mynum) {
		mech_notify(mech, MECHALL,
					"%ch%cr%cf%ciINTRUDER ALERT! INTRUDER ALERT!%c");
		mech_notify(mech, MECHALL,
					"%ch%cr%cfAutomatic self-destruct sequence initiated.%c");
		mech_shutdown(GOD, (void *) mech, "");
	}
	return 1;
}
Beispiel #2
0
/*
   Lookup inverse warp map, goes from fisheye mesh coordinates (x,y),
   treat them as (u,v), lookup the warp map (x,y).
   Original (ux,vy) ranges from -1 to 1
   (tu,tv) ranges from 0 to 1
   (ix iy) ranges from 0 to meshnx and meshny
*/
void EstimateWarp(double u,double v,double *x,double *z,double *br) {
  int i,n,ix,iy;
  double tu,tv;
  double mu,longitude,latitude;
  XYZ p1,p,p0;
  
  double domeradius = 2.5;
  double mirrorradius = 0.3;
  XYZ mirrorpos = {2.4,0,0};
  XYZ projectorpos = {1.85,0,0};
  double aspectratio = 4/3.0;
  double throwdist = 1.5;
  XYZ frustum[4];
  
  if (_s2fd_options->dometype == MIRROR1) {
    
    // Location of projection plane, 1 unit in front of projector
    for (i=0;i<4;i++)
      frustum[i].x = projectorpos.x + 1;
    frustum[0].y = -0.5/throwdist;
    frustum[1].y = -0.5/throwdist;
    frustum[2].y = 0.5/throwdist;
    frustum[3].y = 0.5/throwdist;
    frustum[0].z = 0;
    frustum[1].z = 1.0/(throwdist*aspectratio);
    frustum[2].z = 1.0/(throwdist*aspectratio);
    frustum[3].z = 0;

    // longitude and latitude, latitude clampd at pi/2
    // latitude = 0 at north pole of dome, pi/2 at horizon of dome
    longitude = atan2(v,u); // -pi to pi
    latitude  = PID2 * sqrt(u*u + v*v);
    if (latitude > PID2)
      latitude = PID2;
    
    // p1 is the point on the dome, dome centered at the origin
    p1.x = domeradius * sin(latitude) * sin(longitude);
    p1.y = domeradius * sin(latitude) * cos(longitude);
    p1.z = domeradius * cos(latitude);
    
    // Calculate the reflection position on the dome
    if ((n = MirrorPosition(mirrorpos,mirrorradius,p1,projectorpos,&p0)) != 0) {
      fprintf(stderr,"Error %d, at (%g,%g) = (%g,%g)\n",n,u,v,latitude,longitude);
    }
    
    // Calculate the point "p" on the projection plane
    mu = (frustum[0].x - projectorpos.x) / (p0.x - projectorpos.x);
    p.x = frustum[0].x;
    p.y = projectorpos.y + mu * (p0.y - projectorpos.y);
    p.z = projectorpos.z + mu * (p0.z - projectorpos.z);
    
    // Set brigthness
    *br = 1;
    if (p1.x > 0)
      *br = 1 - p1.x / domeradius;
    if (*br < 0)
      *br = 0;
    if (p1.x >= mirrorpos.x)
      *br = -1;
    
    p.y *= throwdist;
    p.y *= 2;
    p.y *= aspectratio;
    p.z *= throwdist;
    p.z *= aspectratio;
    p.z *= 2;
    p.z -= 1;
    *x = p.y;
    *z = p.z;
    
  } else { // WARPMAP
    
    tu = (u + 1) / 2.0;
    if (tu < 0) tu = 0;
    if (tu > 1) tu = 1;
    
    tv = (v + 1) / 2.0;
    if (tv < 0) tv = 0;
    if (tv > 1) tv = 1;
    
    ix = (int)(tu * (meshnx - 1));
    iy = (int)(tv * (meshny - 1));
    
    *x  = mesh[ix][iy].x;
    *z  = mesh[ix][iy].y;
    *br = mesh[ix][iy].i;
  }
}