Example #1
0
//-----------------------------------------------------------------------------
// Purpose: Rolls the camera's right axis toward the camera's up axis a given
//			number of degrees.
//-----------------------------------------------------------------------------
void CCamera::Roll(float fDegrees)
{
	if (fDegrees != 0)
	{
		float fRoll = GetRoll();
		fRoll += fDegrees;
		SetRoll(fRoll);
	}
}
Example #2
0
//----------------------------------------------------------------------------------------------------------
//                                      Camera
//----------------------------------------------------------------------------------------------------------
//Camera::Camera(char *Nom, Ufloat sx, Ufloat sy )
Camera::Camera(LPCSTR Nom) {
    nom = Nom;

    SetPos(PosParDefaut);
    SetTarg(TargParDefaut);
    SetRoll(.0f);
    SetFov(75.f);
    CalcVue();

//  SetClipFenetre( sx, sy );
    Viewport viewport;   // viewport de la camera

    UpdateProjectMatrix();
    UpdateTransMatrix();
    UpdatePlans();

    Spos = NULL;
    Starg = NULL;
    Sroll = NULL;
    Sfov = NULL;
    callbackAnim = NULL;
}
CRenderableAnimatedInstanceModel::CRenderableAnimatedInstanceModel(const std::string &Name, const std::string &CoreName)
{
  m_AnimatedInstanceModel = NULL;
  m_bIsOk = true;
  CAnimatedCoreModel * l_AnimatedCoreModel = CORE->GetAnimatedModelManager()->GetResource(CoreName);

  if (l_AnimatedCoreModel == NULL)
  {
    m_bIsOk = false;
  }
  else
  {
    m_AnimatedInstanceModel = new CAnimatedInstanceModel();
    m_AnimatedInstanceModel->Initialize(l_AnimatedCoreModel);
    m_AnimatedInstanceModel->InitD3D(CORE->GetRenderManager());
    
    SetName(Name);
    SetPitch(0.0);
    SetPosition(0.0);
    SetRoll(0.0);
    SetVisible(false);
    SetYaw(0.0);
  }
}
Example #4
0
bool cPlayer::LoadFromDisk()
{
	LoadPermissionsFromDisk();

	AString SourceFile;
	Printf(SourceFile, "players/%s.json", GetName().c_str() );

	cFile f;
	if (!f.Open(SourceFile, cFile::fmRead))
	{
		// This is a new player whom we haven't seen yet, bail out, let them have the defaults
		return false;
	}

	AString buffer;
	if (f.ReadRestOfFile(buffer) != f.GetSize())
	{
		LOGWARNING("Cannot read player data from file \"%s\"", SourceFile.c_str()); 
		return false;
	}
	f.Close(); //cool kids play nice

	Json::Value root;
	Json::Reader reader;
	if (!reader.parse(buffer, root, false))
	{
		LOGWARNING("Cannot parse player data in file \"%s\", player will be reset", SourceFile.c_str());
	}

	Json::Value & JSON_PlayerPosition = root["position"];
	if (JSON_PlayerPosition.size() == 3)
	{
		SetPosX(JSON_PlayerPosition[(unsigned int)0].asDouble());
		SetPosY(JSON_PlayerPosition[(unsigned int)1].asDouble());
		SetPosZ(JSON_PlayerPosition[(unsigned int)2].asDouble());
		m_LastPos = GetPosition();
	}

	Json::Value & JSON_PlayerRotation = root["rotation"];
	if (JSON_PlayerRotation.size() == 3)
	{
		SetYaw      ((float)JSON_PlayerRotation[(unsigned int)0].asDouble());
		SetPitch    ((float)JSON_PlayerRotation[(unsigned int)1].asDouble());
		SetRoll     ((float)JSON_PlayerRotation[(unsigned int)2].asDouble());
	}

	m_Health              = root.get("health", 0).asInt();
	m_AirLevel            = root.get("air",            MAX_AIR_LEVEL).asInt();
	m_FoodLevel           = root.get("food",           MAX_FOOD_LEVEL).asInt();
	m_FoodSaturationLevel = root.get("foodSaturation", MAX_FOOD_LEVEL).asDouble();
	m_FoodTickTimer       = root.get("foodTickTimer",  0).asInt();
	m_FoodExhaustionLevel = root.get("foodExhaustion", 0).asDouble();
	m_LifetimeTotalXp     = (short) root.get("xpTotal", 0).asInt();
	m_CurrentXp           = (short) root.get("xpCurrent", 0).asInt();
	m_IsFlying            = root.get("isflying", 0).asBool();

	m_GameMode = (eGameMode) root.get("gamemode", eGameMode_NotSet).asInt();

	if (m_GameMode == eGameMode_Creative)
	{
		m_CanFly = true;
	}
	
	m_Inventory.LoadFromJson(root["inventory"]);

	m_LoadedWorldName = root.get("world", "world").asString();

	// Load the player stats.
	// We use the default world name (like bukkit) because stats are shared between dimensions/worlds.
	cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetName(), GetName(), &m_Stats);
	StatSerializer.Load();
	
	LOGD("Player \"%s\" was read from file, spawning at {%.2f, %.2f, %.2f} in world \"%s\"",
		GetName().c_str(), GetPosX(), GetPosY(), GetPosZ(), m_LoadedWorldName.c_str()
	);
	
	return true;
}
Example #5
0
bool cPlayer::LoadFromDisk()
{
    LoadPermissionsFromDisk();

    // Log player permissions, cause it's what the cool kids do
    LOGINFO("Player %s has permissions:", m_PlayerName.c_str() );
    for( PermissionMap::iterator itr = m_ResolvedPermissions.begin(); itr != m_ResolvedPermissions.end(); ++itr )
    {
        if( itr->second ) LOGINFO("%s", itr->first.c_str() );
    }

    AString SourceFile;
    Printf(SourceFile, "players/%s.json", m_PlayerName.c_str() );

    cFile f;
    if (!f.Open(SourceFile, cFile::fmRead))
    {
        // This is a new player whom we haven't seen yet, bail out, let them have the defaults
        return false;
    }

    AString buffer;
    if (f.ReadRestOfFile(buffer) != f.GetSize())
    {
        LOGWARNING("Cannot read player data from file \"%s\"", SourceFile.c_str());
        return false;
    }
    f.Close(); //cool kids play nice

    Json::Value root;
    Json::Reader reader;
    if (!reader.parse(buffer, root, false))
    {
        LOGWARNING("Cannot parse player data in file \"%s\", player will be reset", SourceFile.c_str());
    }

    Json::Value & JSON_PlayerPosition = root["position"];
    if (JSON_PlayerPosition.size() == 3)
    {
        SetPosX(JSON_PlayerPosition[(unsigned int)0].asDouble());
        SetPosY(JSON_PlayerPosition[(unsigned int)1].asDouble());
        SetPosZ(JSON_PlayerPosition[(unsigned int)2].asDouble());
        m_LastPosX = GetPosX();
        m_LastPosY = GetPosY();
        m_LastPosZ = GetPosZ();
        m_LastFoodPos = GetPosition();
    }

    Json::Value & JSON_PlayerRotation = root["rotation"];
    if (JSON_PlayerRotation.size() == 3)
    {
        SetRotation ((float)JSON_PlayerRotation[(unsigned int)0].asDouble());
        SetPitch    ((float)JSON_PlayerRotation[(unsigned int)1].asDouble());
        SetRoll     ((float)JSON_PlayerRotation[(unsigned int)2].asDouble());
    }

    m_Health              = root.get("health", 0).asInt();
    m_AirLevel            = root.get("air",            MAX_AIR_LEVEL).asInt();
    m_FoodLevel           = root.get("food",           MAX_FOOD_LEVEL).asInt();
    m_FoodSaturationLevel = root.get("foodSaturation", MAX_FOOD_LEVEL).asDouble();
    m_FoodTickTimer       = root.get("foodTickTimer",  0).asInt();
    m_FoodExhaustionLevel = root.get("foodExhaustion", 0).asDouble();
    m_LifetimeTotalXp     = (short) root.get("xpTotal", 0).asInt();
    m_CurrentXp           = (short) root.get("xpCurrent", 0).asInt();

    //SetExperience(root.get("experience", 0).asInt());

    m_GameMode = (eGameMode) root.get("gamemode", eGameMode_NotSet).asInt();

    m_Inventory.LoadFromJson(root["inventory"]);

    m_LoadedWorldName = root.get("world", "world").asString();

    LOGD("Player \"%s\" was read from file, spawning at {%.2f, %.2f, %.2f} in world \"%s\"",
         m_PlayerName.c_str(), GetPosX(), GetPosY(), GetPosZ(), m_LoadedWorldName.c_str()
        );

    return true;
}
Example #6
0
bool cPlayer::LoadFromFile(const AString & a_FileName, cWorldPtr & a_World)
{
	// Load the data from the file:
	cFile f;
	if (!f.Open(a_FileName, cFile::fmRead))
	{
		// This is a new player whom we haven't seen yet, bail out, let them have the defaults
		return false;
	}
	AString buffer;
	if (f.ReadRestOfFile(buffer) != f.GetSize())
	{
		LOGWARNING("Cannot read player data from file \"%s\"", a_FileName.c_str());
		return false;
	}
	f.Close();

	// Parse the JSON format:
	Json::Value root;
	Json::Reader reader;
	if (!reader.parse(buffer, root, false))
	{
		LOGWARNING("Cannot parse player data in file \"%s\"", a_FileName.c_str());
		return false;
	}

	// Load the player data:
	Json::Value & JSON_PlayerPosition = root["position"];
	if (JSON_PlayerPosition.size() == 3)
	{
		SetPosX(JSON_PlayerPosition[(unsigned)0].asDouble());
		SetPosY(JSON_PlayerPosition[(unsigned)1].asDouble());
		SetPosZ(JSON_PlayerPosition[(unsigned)2].asDouble());
		m_LastPos = GetPosition();
	}

	Json::Value & JSON_PlayerRotation = root["rotation"];
	if (JSON_PlayerRotation.size() == 3)
	{
		SetYaw      ((float)JSON_PlayerRotation[(unsigned)0].asDouble());
		SetPitch    ((float)JSON_PlayerRotation[(unsigned)1].asDouble());
		SetRoll     ((float)JSON_PlayerRotation[(unsigned)2].asDouble());
	}

	m_Health              = root.get("health",         0).asInt();
	m_AirLevel            = root.get("air",            MAX_AIR_LEVEL).asInt();
	m_FoodLevel           = root.get("food",           MAX_FOOD_LEVEL).asInt();
	m_FoodSaturationLevel = root.get("foodSaturation", MAX_FOOD_LEVEL).asDouble();
	m_FoodTickTimer       = root.get("foodTickTimer",  0).asInt();
	m_FoodExhaustionLevel = root.get("foodExhaustion", 0).asDouble();
	m_LifetimeTotalXp     = (short) root.get("xpTotal", 0).asInt();
	m_CurrentXp           = (short) root.get("xpCurrent", 0).asInt();
	m_IsFlying            = root.get("isflying", 0).asBool();

	m_GameMode = (eGameMode) root.get("gamemode", eGameMode_NotSet).asInt();

	if (m_GameMode == eGameMode_Creative)
	{
		m_CanFly = true;
	}
	
	m_Inventory.LoadFromJson(root["inventory"]);
	cEnderChestEntity::LoadFromJson(root["enderchestinventory"], m_EnderChestContents);

	m_LoadedWorldName = root.get("world", "world").asString();
	a_World = cRoot::Get()->GetWorld(GetLoadedWorldName(), false);
	if (a_World == NULL)
	{
		a_World = cRoot::Get()->GetDefaultWorld();
	}

	m_LastBedPos.x = root.get("SpawnX", a_World->GetSpawnX()).asInt();
	m_LastBedPos.y = root.get("SpawnY", a_World->GetSpawnY()).asInt();
	m_LastBedPos.z = root.get("SpawnZ", a_World->GetSpawnZ()).asInt();

	// Load the player stats.
	// We use the default world name (like bukkit) because stats are shared between dimensions/worlds.
	cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetName(), GetName(), &m_Stats);
	StatSerializer.Load();
	
	LOGD("Player %s was read from file \"%s\", spawning at {%.2f, %.2f, %.2f} in world \"%s\"",
		GetName().c_str(), a_FileName.c_str(), GetPosX(), GetPosY(), GetPosZ(), a_World->GetName().c_str()
	);
	
	return true;
}