Ejemplo n.º 1
0
void CameraDX::updateProj()
{
	MatF4 perspective;
	ZeroMemory(&perspective, sizeof(MatF4));

	perspective.m[0][0] = 1/(Aspect()*(tan(FOV()/2)));
	perspective.m[1][1] = 1/(tan(FOV()/2));
	perspective.m[2][2] = ZFar()/(ZFar() - ZNear());
	perspective.m[2][3] = 1.0f;
	perspective.m[3][2] = (-ZNear() * ZFar())/(ZFar() - ZNear());

	projection = perspective;
}
Ejemplo n.º 2
0
CameraDX::CameraDX(float aspect, float fov, float zf, float zn, float zoomedIn, float zoomedOut) : Camera(zoomedIn, zoomedOut)
{
	Aspect(aspect);
	FOV(fov);
	ZFar(zf);
	ZNear(zn);
}
Ejemplo n.º 3
0
        void Slice::setup_draw (int axis, Projection& with_projection)
        {
          // info for projection:
          float fov = FOV() / (float) (with_projection.width()+with_projection.height());
          float depth = 2.0 * std::max (std::max (
                image()->header().vox(0) * image()->header().dim(0), 
                image()->header().vox(1) * image()->header().dim(1)), 
              image()->header().vox(2) * image()->header().dim(2));

          // set up projection & modelview matrices:
          GL::mat4 P = GL::ortho (
              -with_projection.width()*fov, with_projection.width()*fov,
              -with_projection.height()*fov, with_projection.height()*fov,
              -depth, depth);
          GL::mat4 M = snap_to_image() ? GL::mat4 (image()->interp.image2scanner_matrix()) : GL::mat4 (orientation());
          GL::mat4 MV = adjust_projection_matrix (M, axis) * GL::translate (-target());
          with_projection.set (MV, P);
        }
Ejemplo n.º 4
0
void draw_world()
{
        int i,j, slot;
        int dx, dy;  // coordinates on screen!
        int color;
        level_t *level;

        level = world->curlevel;             // make sure world->curlevel is correct!

        werase(wmap);
        FOV(player, level);
        if(game->context == CONTEXT_DUNGEON)
                FOVlight(player, level);     // only necessary in dungeon

        /*
         * in this function, (j,i) are the coordinates on the map,
         * dx,dy = coordinates on screen.
         * so, player->py/px describes the upper left corner of the map
         */
        for(i = ppx, dx = 0; i <= (ppx + game->mapw); i++, dx++) {
                for(j = ppy, dy = 0; j <= (ppy + game->maph); j++, dy++) {
                        if(j < level->ysize && i < level->xsize) {
                                if(hasbit(level->c[j][i].flags, CF_VISITED)) {
                                        color = cc(j,i);
                                        if(game->context == CONTEXT_DUNGEON)
                                                wattron(wmap, A_BOLD);

                                        if(hasbit(level->c[j][i].flags, CF_LIT)) {
                                                wattroff(wmap, A_BOLD);
                                                color = level->c[j][i].litcolor;
                                        }

                                        gtmapaddch(dy, dx, color, mapchars[(int) level->c[j][i].type]);

                                        /*
                                        if(level->c[j][i].height < 0) {
                                                color = COLOR_RED;
                                                c = 48+(0 - level->c[j][i].height);
                                        } else {
                                                color = COLOR_BLUE;
                                                c = 48+level->c[j][i].height;
                                        }

                                        gtmapaddch(dy, dx, color, c);
                                        */

                                        if(level->c[j][i].inventory) {
                                                wattroff(wmap, A_BOLD);
                                                if(level->c[j][i].inventory->gold > 0) {
                                                        wattron(wmap, A_BOLD);
                                                        gtmapaddch(dy, dx, COLOR_YELLOW, objchars[OT_GOLD]);
                                                        wattroff(wmap, A_BOLD);
                                                } else {                                                         // TODO ADD OBJECT COLORS!!!
                                                        slot = get_first_used_slot(level->c[j][i].inventory);
                                                        if(level->c[j][i].inventory->num_used > 0 && slot >= 0 && level->c[j][i].inventory->object[slot]) {
                                                                color = level->c[j][i].inventory->object[slot]->color;
                                                                gtmapaddch(dy, dx, color, objchars[level->c[j][i].inventory->object[slot]->type]);
                                                        }
                                                }
                                        }

                                        if(hasbit(level->c[j][i].flags, CF_HAS_DOOR_CLOSED))
                                                gtmapaddch(dy, dx, color, '+');
                                        else if(hasbit(level->c[j][i].flags, CF_HAS_DOOR_OPEN))
                                                gtmapaddch(dy, dx, color, '\'');
                                        else if(hasbit(level->c[j][i].flags, CF_HAS_STAIRS_DOWN))
                                                gtmapaddch(dy, dx, COLOR_WHITE, '>');
                                        else if(hasbit(level->c[j][i].flags, CF_HAS_STAIRS_UP))
                                                gtmapaddch(dy, dx, COLOR_WHITE, '<');
                                }


                                if(level->c[j][i].visible && level->c[j][i].monster /*&& actor_in_lineofsight(player, level->c[j][i].monster)*/)
                                        gtmapaddch(dy, dx, COLOR_RED, (char) level->c[j][i].monster->c);

                                if(level->c[j][i].type == AREA_WALL) {
                                        gtmapaddch(dy, dx, COLOR_PLAIN, mapchars[DNG_WALL]);
                                }
                        if(j == ply && i == plx)
                                gtmapaddch(dy, dx, COLOR_PLAYER, '@');
                        }
                }
        }

        wattron(wmap, COLOR_PAIR(COLOR_NORMAL));
        box(wmap, ACS_VLINE, ACS_HLINE);
        //wcolor_set(wmap, 0, 0);
}
Ejemplo n.º 5
0
bool CCheatMgr::Process( CheatCode nCheatCode, CParsedMsg &cMsg )
{
	if ( nCheatCode <= CHEAT_NONE || nCheatCode >= CHEAT_MAX ) return false;

#ifdef _FINAL
	// Don't do cheats in multiplayer...
    if (IsMultiplayerGame())
	{
		// Well, okay, let them toggle between 1st and 3rd person ;)
		// and, well, blood is pretty cool...
		switch ( nCheatCode )
		{
			case CHEAT_CHASETOGGLE:
				ChaseToggle();
			break;

			case CHEAT_EXITLEVEL:	// exit the current level
				SetExitLevel();
			break;

			case CHEAT_NEXTMISSION:	// exit the current mission
				NextMission();
			break;

			case CHEAT_BOOT:		// boot players
				BootPlayer(cMsg);
			break;

			default :
				return false;
			break;
		}

		m_bPlayerCheated = LTTRUE;
		return true;
	}
#endif // _FINAL

	// process cheat codes
	switch ( nCheatCode )
	{
		case CHEAT_GOD:			// god mode toggle
			SetGodMode(!s_CheatInfo[nCheatCode].bActive);
		break;

		case CHEAT_SKILLZ:		// give em skill points
			GetSkills();
		break;

		case CHEAT_ARMOR:		// full armor
			SetArmor();
		break;

		case CHEAT_HEALTH:		// full health
			SetHealth();
		break;

		case CHEAT_EXITLEVEL:	// exit the current level
			SetExitLevel();
		break;

		case CHEAT_VERSION:		// display version info
			Version();
		break;

		case CHEAT_BUILDGUID:	// display build guid
			BuildGuid();
		break;

		case CHEAT_INVISIBLE:	// time to mess with the AI
			SetInvisible(!s_CheatInfo[nCheatCode].bActive);
		break;

		case CHEAT_BODYGOLFING:	// bodies fly far	
			BodyGolfing(!s_CheatInfo[nCheatCode].bActive);
		break;

		case CHEAT_POS:			// show/hide player position
			SetPos(!s_CheatInfo[nCheatCode].bActive);
		break;

#ifndef _TO2DEMO
		
		case CHEAT_KFA:			// give em everything
			SetKFA();
		break;

		case CHEAT_AMMO:		// full ammo
			SetAmmo();
		break;

		case CHEAT_MODSQUAD:	// give all mods for current weapons
			ModSquad();
		break;

		case CHEAT_CONSOLE:
			SetConsole(!s_CheatInfo[nCheatCode].bActive);
		break;

		case CHEAT_NEXTMISSION:	// exit the current mission
			NextMission();
		break;

		case CHEAT_BOOT:	// exit the current mission
			BootPlayer(cMsg);
		break;

		case CHEAT_FULL_WEAPONS:   // give all weapons
			SetFullWeapons();
		break;

		case CHEAT_SNOWMOBILE:	  // spawn in snowmobile
			Snowmobile(!s_CheatInfo[nCheatCode].bActive);
		break;

		case CHEAT_FULL_GEAR:	// give all gear
			FullGear();
		break;

		case CHEAT_TEARS:	      // toggle tears cheat
			Tears(!s_CheatInfo[nCheatCode].bActive);
		break;

		case CHEAT_GIMMEGUN:
			GimmeGun( cMsg );
		break;

		case CHEAT_GIMMEMOD:
			GimmeMod( cMsg );
		break;

		case CHEAT_GIMMEGEAR:
			GimmeGear( cMsg );
		break;

		case CHEAT_GIMMEAMMO:
			GimmeAmmo( cMsg );
		break;

		case CHEAT_ENDGAME:
			ToggleEndgameFlag();
		break;

#ifndef _FINAL

		case CHEAT_CHASETOGGLE:	   // toggle 3rd person view
			ChaseToggle();
		break;

		case CHEAT_CLIP:		// toggle clipping mode
			SetClipMode(!s_CheatInfo[nCheatCode].bActive);
		break;

		case CHEAT_TELEPORT:	// teleport to beginning
			Teleport();
		break;

		case CHEAT_CAM_POSROT:    // show/hide camera position/rotation
			SetCamPosRot(!s_CheatInfo[nCheatCode].bActive);
		break;

		case CHEAT_POSWEAPON:		    // toggle adjust of weapon pos
			PosWeapon(!s_CheatInfo[nCheatCode].bActive);
		break;

  		case CHEAT_POSWEAPON_MUZZLE:	// toggle adjust of weapon muzzle pos
  			PosWeaponMuzzle(!s_CheatInfo[nCheatCode].bActive);
  		break;

  		case CHEAT_WEAPON_BREACHOFFSET:	// toggle adjust of weapon breach offset pos
  			WeaponBreachOffset(!s_CheatInfo[nCheatCode].bActive);
  		break;

		case CHEAT_LIGHTSCALE:	      // toggle client light scale offset
			LightScale(!s_CheatInfo[nCheatCode].bActive);
		break;

		case CHEAT_LIGHTADD:	      // toggle client light add offset
			LightAdd(!s_CheatInfo[nCheatCode].bActive);
		break;

		case CHEAT_FOV:				// toggle fov cheat
			FOV(!s_CheatInfo[nCheatCode].bActive);
		break;

		case CHEAT_REMOVEAI:	  // remove all ai
			RemoveAI(!s_CheatInfo[nCheatCode].bActive);
		break;

		case CHEAT_TRIGGERBOX:	  // toggle trigger boxes on/off
			TriggerBox(!s_CheatInfo[nCheatCode].bActive);
		break;

		case CHEAT_POS1STCAM:	  // toggle 1st person camera adjust on/off
			Pos1stCam(!s_CheatInfo[nCheatCode].bActive);
		break;

#endif  // _FINAL
#endif // _TO2DEMO

		default:
			return false;			// skip setting global cheat indicator for unhandled cheats
	}

    m_bPlayerCheated = LTTRUE;

	return true;
}
Ejemplo n.º 6
0
double get_distance_TRIG(const ParticleAnalysisReport& r, double height) {
    double theta = angle_offset(RESOLUTION().Y()/2 - r.center_mass_y, RESOLUTION().Y(), FOV().Y());
    return (height/std::tan(theta));
}