Exemplo n.º 1
0
int calcWeatherPilotEffects(MECH * mech)
{
    MAP *map = FindObjectsData(mech->mapindex);
    int onTheGround = 1;
    int mod = 0;

    if (!map)
	return 0;

    onTheGround = (!Jumping(mech) &&
	(MechZ(mech) <= Elevation(map, MechX(mech), MechY(mech))));

    if (onTheGround) {
	if ((MapEffectHvyRain(map) || MapEffectHvySnow(map) ||
		MapEffectHighWinds(map) || MapEffectBlizzard(map)))
	    mod += 1;

	if (MechMove(mech) != MOVE_HOVER) {
	    if (HexHasDeepSnow(map, MechX(mech), MechY(mech)))
		mod += 1;

	    if (HexHasMud(map, MechX(mech), MechY(mech)))
		mod += 1;

	    if (HexHasRapids(map, MechX(mech), MechY(mech)))
		mod += 2;
	}

	return mod;
    }

    return 0;
}
Exemplo n.º 2
0
void animateCamera() {
  pScene   sc;
  pCamera  c;
  double   dazim,delev,azim,elev;
  float    cfelev,cfazim;

  if ( !animate || !ctracking )  return;
  sc = cv.scene[currentScene()];
  c  = sc->camera;
  azim  = Azimuth(c);
  elev  = Elevation(c);

  switch (cbutton) {
    case GLUT_LEFT_BUTTON:
      cfelev = 3.0;
      cfazim = 3.0;
      delev  = 2.0*(cury-starty)/(float)sc->par.ys;
      dazim  = 2.0*(curx-startx)/(float)sc->par.xs;
      if ( delev >= 0.0 ) delev *= delev;
      else                delev = -delev*delev;
      if ( dazim >= 0.0 ) dazim *= dazim;
      else                dazim  = -dazim*dazim;
      elev += cfelev * delev;
      azim -= cfazim * dazim;
      break;
    
    case GLUT_MIDDLE_BUTTON:
      break;
    case GLUT_BUTTON_3:
      puts("button3");
      break;
    case GLUT_BUTTON_4:
      puts("button4");
      break;
  }
  updateCamera(sc,c,azim,elev);
  reshapeScene(sc->par.xs,sc->par.ys);
  glutPostRedisplay();
}
Exemplo n.º 3
0
void motionCamera(int x,int y) {
  pScene   sc;
  pCamera  c;
  double   dazim,delev,azim,elev;
  float    cfelev,cfazim;

  /* keep current pos */
  curx = x;
  cury = y;

  if ( animate ) return;
  sc = cv.scene[currentScene()];
  c  = sc->camera;
  azim  = Azimuth(c);
  elev  = Elevation(c);
   switch (cbutton) {
    case GLUT_LEFT_BUTTON:
      cfelev = 50.0;
      cfazim = 50.0;
      delev  = cfelev * (y-starty)/(float)sc->par.ys;
      dazim  = cfazim * (x-startx)/(float)sc->par.xs;
      startx = x;
      starty = y;
      elev  += delev;
      azim  -= dazim;
      break;
    case GLUT_MIDDLE_BUTTON:
      break;
    case GLUT_BUTTON_3:
      puts("button3");
      break;
    case GLUT_BUTTON_4:
      puts("button4");
      break;
  }
  updateCamera(sc,c,azim,elev);
  reshapeScene(sc->par.xs,sc->par.ys);
  glutPostRedisplay();
}
Exemplo n.º 4
0
void meltSnowAndIce(MAP * map, int x, int y, int depth, int emit,
    int makeSteam)
{
    int data = 0;
    int layers = 0, oldLayers = 0;
    int snowDone = 0;
    int steamLength = 0;

    if (!map)
	return;

    if (depth <= 0)
	return;

    oldLayers = GetHexLayers(map, x, y);
    layers = oldLayers;
    data = GetHexLayerData(map, x, y);

    if ((layers & HEXLAYER_SNOW) || (layers & HEXLAYER_DEEP_SNOW)) {
	data = MAX(0, data - depth);
	steamLength = abs(data - GetHexLayerData(map, x, y));

	if (data == 0)
	    layers &= ~(HEXLAYER_SNOW | HEXLAYER_DEEP_SNOW);
	else if (data <= 1000) {
	    layers |= HEXLAYER_SNOW;
	    layers &= ~HEXLAYER_DEEP_SNOW;
	} else {
	    layers |= HEXLAYER_DEEP_SNOW;
	    layers &= ~HEXLAYER_SNOW;
	}

	SetHexLayers(map, x, y, layers);
	SetHexLayerData(map, x, y, data);

	if (emit) {
	    if (layers & HEXLAYER_DEEP_SNOW)
		snowDone = 1;

	    if (!snowDone && !((layers & HEXLAYER_SNOW) ||
		    (layers & HEXLAYER_DEEP_SNOW))) {
		HexLOSBroadcast(map, x, y,
		    "%ch%cgThe snow in $h melts to nothingness!%cn");
		snowDone = 1;
	    }

	    if (!snowDone && ((oldLayers & HEXLAYER_DEEP_SNOW) &&
		    (!(layers & HEXLAYER_DEEP_SNOW)))) {
		HexLOSBroadcast(map, x, y,
		    "%ch%cgThe snow in $h visibly melts!%cn");
		snowDone = 1;
	    }
	}
    }

    if (IsIceHex(map, x, y)) {
	if (depth >= (Elevation(map, x, y) * 200)) {
	    if (emit)
		HexLOSBroadcast(map, x, y, "The ice at $h breaks apart!");

	    breakIceAndSplashUnits(map, NULL, x, y,
		"goes swimming as ice breaks!");
	    steamLength = (Elevation(map, x, y) * 200);
	}
    }

    if ((steamLength > 0) && makeSteam) {
	if (steamLength > 90)
	    steamLength = 90 + Number(0, steamLength / 20);

	add_decoration(map, x, y, TYPE_SMOKE, SMOKE, steamLength);
    }
}
Exemplo n.º 5
0
/* draw HUD system for flight */
void drawHUD(pScene sc) {
  pCamera  c;
  pMesh    mesh;
  GLfloat  xm,ym,x,y,dx,dy,alt;
  double   azim,elev;
  int      i,j;

  if ( ddebug )  fprintf(stdout,"drawHUD\n");
  glDisable(GL_DEPTH_TEST);
  glDisable(GL_LIGHTING);

  glMatrixMode(GL_PROJECTION);
  glPushMatrix();
  glLoadIdentity();
  gluOrtho2D(-0.5,639.5,-0.5,479.5);

  c  = sc->camera;
  mesh = cv.mesh[sc->idmesh];
  glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
  glColor3f(0.0,0.5,0.0);
  glLineWidth(1.0f);
  xm = sc->par.xs / 2.0f;
  ym = sc->par.ys / 2.0f;
  glRecti(200,160,440,320);

  /* altitude */
  glColor3f(1.0,0.5,0.0);
  output2(230,330,"speed: %6.1f",1000.0f*c->spmod/sc->dmax);

  switch(c->vecup) {
    case X_AXIS: alt = (c->eye[1]+mesh->xtra)/(mesh->xmax-mesh->xmin); break;
    case Y_AXIS: alt = (c->eye[1]+mesh->ytra)/(mesh->ymax-mesh->ymin); break;
    case Z_AXIS: alt = (c->eye[1]+mesh->ztra)/(mesh->zmax-mesh->zmin); break;
    default: alt = 0.0;  break;
  }
  glColor3f(1.0,0.5,0.0);
  output2(350,330,"alt: %9.1f",1000.0f*alt);

  /* horiz rulers */
  output2(310,139.0f,"azim");
  glColor3f(0.0,1.0,0.0);
  output2(197,150,"-180");
  output2(257,150," -90");
  output2(317,150,"0");
  output2(377,150," 90");
  output2(437,150,"180");
  x = 200.0f;
  glBegin(GL_LINES);
  for (i=1; i<8; i++) {
    x += 240.0 / 8.0;
    glVertex2f(x,158.0);
    glVertex2f(x,162.0);
  }
  glEnd();
  
  /* vert rulers */
  glColor3f(0.0,1.0,0.0);
  output2(185,160,"-90");
  output2(185,200,"-45");
  output2(185,240,"0");
  output2(185,280,"45");
  output2(185,320,"90");
  y = 160.0f;
  glBegin(GL_LINES);
  for (i=1; i<8; i++) {
    y += 160.0 / 8.0;
    glVertex2f(198,y);
    glVertex2f(202,y);
  }
  glEnd();

  /* azimuth */
  azim = Azimuth(c);
  if ( azim > 0.0f )      azim =  180.0f - azim;
  else if ( azim < 0.0f ) azim = -180.0f - azim;
  x = 2.0/3.0*azim + 320.0f;
  glColor3f(1.0,0.0,0.0);
  glLineWidth(1.0);
  output2(x,143.0,"%d",azim>0 ? (int)(azim+0.5) : (int)(azim-0.5));
  glBegin(GL_LINES);
    glVertex2f(x,166.0);
    glVertex2f(x,318.0);
  glEnd();
  y  = 160.0f;
  dy = 160.0 / 8.0;
  glBegin(GL_LINES);
  for (i=0; i<8; i++) {
    glVertex2f(x-4,y);
    glVertex2f(x+4,y);
    for (j=0; j<5; j++) {
      glVertex2f(x-2,y+j*dy/5.0);
      glVertex2f(x+2,y+j*dy/5.0);
    }
    y += dy;
  }
  glEnd();
  
  /* elevation */
  elev = Elevation(c);
  if ( elev > 90.0f )       y = 320.0f;
  else if ( elev < -90.0f ) y = 160.0f;
  else y = 8.0/9.0 * elev + 240.0;
  glColor3f(1.0,0.0,0.0);
  output2(175.0,y,"%5.1f",elev);
  glBegin(GL_LINES);
    glVertex2f(206.0,y);
    glVertex2f(438.0,y);
  glEnd();
  x  = 200.0f;
  dx = 240.0f / 8.0f;
    glBegin(GL_LINES);
  for (i=1; i<=8; i++) {
    glVertex2f(x,y-4);
    glVertex2f(x,y+4);
    for (j=0; j<5; j++) {
      glVertex2f(x+j*dx/5.0,y-2);
      glVertex2f(x+j*dx/5.0,y+2);
    }
    x += dx;
  }
  glEnd();

  /* horizon */
  glLineWidth(2.0f);
  glColor3f(0.0,0.0,1.0);
  glBegin(GL_LINES);
    glVertex2f(200.0,240.0);
    glVertex2f(440.0,240.0);
  glEnd();
  glLineWidth(1.0f);

  /* HUD */
  glColor3f(1.0,0.0,0.0);
  glBegin(GL_LINES);
    glVertex2f(310,230);
    glVertex2f(330,230);
    glVertex2f(310,250);
    glVertex2f(330,250);
    
    glVertex2f(310,230);
    glVertex2f(310,234);
    glVertex2f(330,230);
    glVertex2f(330,234);
    
    glVertex2f(310,246);
    glVertex2f(310,250);
    glVertex2f(330,246);
    glVertex2f(330,250);
  glEnd();
  /*glRecti(318,238,322,242);*/
  glColor3f(0.0,1.0,0.0);
  glLineWidth(3.0f);
  glBegin(GL_LINES);
    glVertex2f(320.,235.);
    glVertex2f(320.,245.);
    glVertex2f(315.,240.);
    glVertex2f(325.,240.);
  glEnd();
  glLineWidth(1.0f);
  
  glMatrixMode(GL_PROJECTION);
  glPopMatrix();
  glMatrixMode(GL_MODELVIEW);
  glEnable(GL_DEPTH_TEST);
}
Exemplo n.º 6
0
float findC3RangeWithNetwork(MECH * mech, MECH * mechTarget,
							 float realRange, dbref * myNetwork,
							 int networkSize, dbref * c3Ref)
{
	float c3Range = 0.0;
	float bestRange = 0.0;
	int i;
	int inLOS = 0;
	int mapX, mapY;
	float hexX, hexY, hexZ;
	MECH *otherMech;
	MAP *map;

	bestRange = realRange;
	*c3Ref = 0;

	if(networkSize == 0)
		return realRange;

	for(i = 0; i < networkSize; i++) {
		otherMech = getMechInTempNetwork(i, myNetwork, networkSize);

		if(!otherMech)
			continue;

		if(!Good_obj(otherMech->mynum))
			continue;

		if(mechTarget) {
			if(otherMech == mechTarget)
				continue;

			debugC3(tprintf
					("C3RANGE-NETWORK (mech): Finding range from %d to %d.",
					 mech->mynum, mechTarget->mynum));

			c3Range = FaMechRange(otherMech, mechTarget);
			inLOS =
				InLineOfSight(otherMech, mechTarget, MechX(mechTarget),
							  MechY(mechTarget), c3Range);
		} else if((MechTargX(mech) > 0) && (MechTargY(mech) > 0)) {
			mapX = MechTargX(mech);
			mapY = MechTargY(mech);
			map = getMap(mech->mapindex);

			debugC3(tprintf
					("C3RANGE-NETWORK (hex): Finding range from %d to %d %d.",
					 mech->mynum, mapX, mapY));

			MechTargZ(mech) = Elevation(map, mapX, mapY);
			hexZ = ZSCALE * MechTargZ(mech);
			MapCoordToRealCoord(mapX, mapY, &hexX, &hexY);

			c3Range =
				FindRange(MechFX(otherMech), MechFY(otherMech),
						  MechFZ(otherMech), hexX, hexY, hexZ);
			inLOS = LOS_NB(otherMech, NULL, mapX, mapY, c3Range);
		} else {
			continue;
		}

		if(inLOS && (c3Range < bestRange)) {
			bestRange = c3Range;
			*c3Ref = otherMech->mynum;
		}
	}

	return bestRange;
}
void CTerrainWalkingView::OnTimer(UINT_PTR nIDEvent)
{
	Ogre::Quaternion Quaternion;
	CEngine *Engine = ((CTerrainWalkingApp*)AfxGetApp())->m_Engine;		
	Ogre::Root *Root = Engine->GetRoot();
	Ogre::SceneNode *RobotNode = Root->getSceneManager("Walking")->getSceneNode("Robot");
	Ogre::Entity *RobotEntity = Root->getSceneManager("Walking")->getEntity("Robot");
	Ogre::AxisAlignedBox RobotBox = RobotEntity->getBoundingBox();

	Ogre::Entity *TopographyEntity = Root->getSceneManager("Walking")->getEntity("Topography");

	Ogre::AxisAlignedBox TopographyBox = TopographyEntity->getBoundingBox();
		
	Ogre::Vector3 Start = TopographyBox.getMinimum();
	Ogre::Vector3 Finish = TopographyBox.getMaximum();

	double x = Start[0] + (Finish[0] - Start[0]) * m_RelativeDistance;
	double y = Start[1] + (Finish[1] - Start[1]) * m_RelativeDistance;
	double z = Start[2] + (Finish[2] - Start[2]) * m_RelativeDistance;
	
	Ogre::Vector3 Elevation(x, y, z);
	Ogre::Vector3 CameraMove;

	switch (nIDEvent)
	{
		case 1:

			m_Animation->addTime(0.01);
			m_RelativeDistance += 0.01;

			if (m_CollisionTools->collidesWithEntity(Elevation, Ogre::Vector3(x,y - 1,z), Ogre::Vector3(x,y + 1,z), 100.0f, 0.0f, 4294967295))
			{
				x = Elevation[0];
				y = Elevation[1] + RobotBox.getSize()[1];
				z = Elevation[2];
			}

			RobotNode->setPosition(x, y, z);
			m_Camera->lookAt(x, y, z);
			
			if (m_RelativeDistance > 1.0)
			  KillTimer(1);

		break;

		case 2:

			CameraMove[0] = -100;
			CameraMove[1] = 0;
			CameraMove[2] = 0;
			m_Camera->moveRelative(CameraMove);

		break;

		case 3:

			CameraMove[0] = 0;
			CameraMove[1] = 100;
			CameraMove[2] = 0;
			m_Camera->moveRelative(CameraMove);

			break;

		case 4:

			CameraMove[0] = 100;
			CameraMove[1] = 0;
			CameraMove[2] = 0;
			m_Camera->moveRelative(CameraMove);

			break;

		case 5:

			CameraMove[0] = 0;
			CameraMove[1] = -100;
			CameraMove[2] = 0;
			m_Camera->moveRelative(CameraMove);

			break;
	}

	Root->renderOneFrame();
	CView::OnTimer(nIDEvent);
}
Exemplo n.º 8
0
/* special keys CAMERA mode */
void specCamera(pScene sc,int key) {
  pCamera     c;
  double      dd,azim,elev;
  GLfloat     axe[3];
  int         keyact;
  
  c  = sc->camera;
  keyact = glutGetModifiers();

  axe[0] = c->speed[2];
  axe[1] = 0.0;
  axe[2] = -c->speed[0];
  dd = sqrt(axe[0]*axe[0] + axe[2]*axe[2]);
  if ( dd != 0.0f ) {
    axe[0] /= dd;
    axe[2] /= dd;
  }

  switch (key) {
  case GLUT_KEY_LEFT:
    if ( keyact & GLUT_ACTIVE_SHIFT ) {
      c->eye[0] += axe[0]*c->altinc;
      c->eye[2] += axe[2]*c->altinc;
      reshapeScene(sc->par.xs,sc->par.ys);
      glutPostRedisplay();
      return;
    }
    else {
      azim = Azimuth(c);
      elev = Elevation(c);
      azim += dazim;
    }
    break;
  case GLUT_KEY_RIGHT:
    if ( keyact & GLUT_ACTIVE_SHIFT ) {
      c->eye[0] -= axe[0]*c->altinc;
      c->eye[2] -= axe[2]*c->altinc;
      reshapeScene(sc->par.xs,sc->par.ys);
      glutPostRedisplay();
      return;
    }
    else {
      azim = Azimuth(c);
      elev = Elevation(c);
      azim -= dazim;
    }
    break;
  case GLUT_KEY_UP:
    if ( keyact & GLUT_ACTIVE_SHIFT ) {
      c->eye[1] += c->altinc;
      reshapeScene(sc->par.xs,sc->par.ys);
      glutPostRedisplay();
      return;
    }
    else {
      azim = Azimuth(c);
      elev = Elevation(c);
      elev -= delev;
    }
    break;
  case GLUT_KEY_DOWN:
    if ( keyact & GLUT_ACTIVE_SHIFT ) {
      c->eye[1] -= c->altinc;
      reshapeScene(sc->par.xs,sc->par.ys);
      glutPostRedisplay();
      return;
    }
    else {
      azim = Azimuth(c);
      elev = Elevation(c);
      elev += delev;
    }
    break;
  default:
    return;
  }

  updateCamera(sc,c,azim,elev);

  /* refresh scene */
  reshapeScene(sc->par.xs,sc->par.ys);
  glutPostRedisplay();
}
Exemplo n.º 9
0
TrackScreen::TrackScreen(QWidget *parent)
:QDialog(parent),
ReturnBtn(this),
m_ListBox(this, g_rectListBoxBase.x(), g_rectListBoxBase.y(), g_rectListBoxBase.width(), g_rectListBoxBase.height())
{
   setGeometry(0, 0, __nWidth__, __nHeight__);

// Load background image
    m_pImageBackground = GetImg(IMG_LIST_BK);

// Set Title Text
    m_pLabelTitle = new QLabel(this);
    QFont font(g_strTitleFontFamily, g_iTitleFontPointSize);
    font.setStyleStrategy(QFont::PreferAntialias);
    m_pLabelTitle->setFont(font);
    QPalette qPalette;
    qPalette.setColor( QPalette::Foreground, QColor( __TitleTextColor__ ) );
    m_pLabelTitle->setPalette( qPalette );
    m_pLabelTitle->setGeometry(g_rectTitle);
    m_pLabelTitle->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
    m_pLabelTitle->setText(g_strTitleTrack);

// Load Home button
    m_pPushButtonHome = new RtPushButton(this);
    m_pPushButtonHome->setGeometry(g_rectButtonHome);
    m_pImageHome[BUTTON_UP] = GetImg(IMG_BTN_HOME_UP);
    m_pImageHome[BUTTON_DOWN] = GetImg(IMG_BTN_HOME_DOWN);
    m_pPushButtonHome->SetImages(m_pImageHome[BUTTON_UP], m_pImageHome[BUTTON_DOWN]);
    connect(m_pPushButtonHome, SIGNAL(clicked()), this, SLOT(Home()));

// Load View On Map button
    m_pPushButtonView = new RtPushButton(this);
    m_pPushButtonView->setGeometry(g_rectButtonView);
    m_pImageMapView[BUTTON_UP] = GetImg(IMG_BTN_VIEWMAP_UP);
    m_pImageMapView[BUTTON_DOWN] = GetImg(IMG_BTN_VIEWMAP_DOWN);
    m_pPushButtonView->SetImages(m_pImageMapView[BUTTON_UP], m_pImageMapView[BUTTON_DOWN]);
    QString strViewText = QString("View On Map");
    QRect rectViewText = QRect(1,45,63,12);
    m_pPushButtonView->SetButtonText(strViewText,rectViewText);
    connect(m_pPushButtonView, SIGNAL(clicked()), this, SLOT(ViewOnMap()));

// Load Elevation button
    m_pPushButtonElevation = new RtPushButton(this);
    m_pPushButtonElevation->setGeometry(g_rectButtonElevation);
    m_pImageElevation[BUTTON_UP] = GetImg(IMG_BTN_ELEVATION_UP);
    m_pImageElevation[BUTTON_DOWN] = GetImg(IMG_BTN_ELEVATION_DOWN);
    m_pPushButtonElevation->SetImages(m_pImageElevation[BUTTON_UP], m_pImageElevation[BUTTON_DOWN]);
    QString strElevationText = QString("Elev. Plot");
    QRect rectElevationText(1,45,63,12);
    m_pPushButtonElevation->SetButtonText(strElevationText,rectElevationText);
    connect(m_pPushButtonElevation, SIGNAL(clicked()), this, SLOT(Elevation()));

// Load Edit button
    m_pPushButtonEdit = new RtPushButton(this);
    m_pPushButtonEdit->setGeometry(g_rectButtonEdit);
    m_pImageEdit[BUTTON_UP] = GetImg(IMG_BTN_EDIT_UP);
    m_pImageEdit[BUTTON_DOWN] = GetImg(IMG_BTN_EDIT_DOWN);
    m_pPushButtonEdit->SetImages(m_pImageEdit[BUTTON_UP], m_pImageEdit[BUTTON_DOWN]);
    QString strEditText = QString("Edit");
    QRect rectEditText = QRect(1,45,63,12);
    m_pPushButtonEdit->SetButtonText(strEditText,rectEditText);
    connect(m_pPushButtonEdit, SIGNAL(clicked()), this, SLOT(Edit()));

// Load Share button
    m_pPushButtonShare = new RtPushButton(this);
    m_pPushButtonShare->setGeometry(g_rectButtonShare);
    m_pImageShare[BUTTON_UP] = GetImg(IMG_BTN_SHARE_UP);
    m_pImageShare[BUTTON_DOWN] = GetImg(IMG_BTN_SHARE_DOWN);
    m_pPushButtonShare->SetImages(m_pImageShare[BUTTON_UP], m_pImageShare[BUTTON_DOWN]);
    QString strShareText = QString("Share");
    QRect rectShareText = QRect(1,45,63,12);
    m_pPushButtonShare->SetButtonText(strShareText,rectShareText);
    connect(m_pPushButtonShare, SIGNAL(clicked()), this, SLOT(Share()));

    m_iSelect = -1;

// Load ListBox
    connect(&m_ListBox, SIGNAL(ButtonSelect(int)), this, SLOT(ListSelect(int)));
    connect(&m_ListBox, SIGNAL(ButtonScroll()), this, SLOT(ListScroll(void)));

/*
    for(int j=0;j<LIST_ICON_NUM;j++)
        m_pImageIcons[j] = GetImg((IMG_ID)(IMG_TRACK_LIST_ICON1+j));
*/
	EnableFunctionButton(false);

	//delay display content for better user experence
	m_pListTimer = new QTimer(this);
	connect(m_pListTimer, SIGNAL(timeout()), this, SLOT(UpdateListbox()));
	m_pListTimer->start(200);
}