예제 #1
0
	Matrix4* BMaxObject::GetRenderMatrix(Matrix4& mxWorld, int nRenderNumber /*= 0*/)
	{
		mxWorld.identity();

		// order of rotation: roll * pitch * yaw , where roll is applied first. 
		bool bIsIdentity = true;

		float fScaling = GetScaling();
		if (fScaling != 1.f)
		{
			Matrix4 matScale;
			ParaMatrixScaling((Matrix4*)&matScale, fScaling, fScaling, fScaling);
			mxWorld = (bIsIdentity) ? matScale : matScale.Multiply4x3(mxWorld);
			bIsIdentity = false;
		}

		float fYaw = GetYaw();
		if (fYaw != 0.f)
		{
			Matrix4 matYaw;
			ParaMatrixRotationY((Matrix4*)&matYaw, fYaw);
			mxWorld = (bIsIdentity) ? matYaw : matYaw.Multiply4x3(mxWorld);
			bIsIdentity = false;
		}

		if (GetPitch() != 0.f)
		{
			Matrix4 matPitch;
			ParaMatrixRotationX(&matPitch, GetPitch());
			mxWorld = (bIsIdentity) ? matPitch : matPitch.Multiply4x3(mxWorld);
			bIsIdentity = false;
		}

		if (GetRoll() != 0.f)
		{
			Matrix4 matRoll;
			ParaMatrixRotationZ(&matRoll, GetRoll());
			mxWorld = (bIsIdentity) ? matRoll : matRoll.Multiply4x3(mxWorld);
			bIsIdentity = false;
		}

		// world translation
		Vector3 vPos = GetRenderOffset();
		mxWorld._41 += vPos.x;
		mxWorld._42 += vPos.y;
		mxWorld._43 += vPos.z;

		return &mxWorld;
	}
예제 #2
0
bool cPlayer::SaveToDisk()
{
    cFile::CreateFolder(FILE_IO_PREFIX + AString("players"));

    // create the JSON data
    Json::Value JSON_PlayerPosition;
    JSON_PlayerPosition.append(Json::Value(GetPosX()));
    JSON_PlayerPosition.append(Json::Value(GetPosY()));
    JSON_PlayerPosition.append(Json::Value(GetPosZ()));

    Json::Value JSON_PlayerRotation;
    JSON_PlayerRotation.append(Json::Value(GetRotation()));
    JSON_PlayerRotation.append(Json::Value(GetPitch()));
    JSON_PlayerRotation.append(Json::Value(GetRoll()));

    Json::Value JSON_Inventory;
    m_Inventory.SaveToJson(JSON_Inventory);

    Json::Value root;
    root["position"]       = JSON_PlayerPosition;
    root["rotation"]       = JSON_PlayerRotation;
    root["inventory"]      = JSON_Inventory;
    root["health"]         = m_Health;
    root["xpTotal"]        = m_LifetimeTotalXp;
    root["xpCurrent"]      = m_CurrentXp;
    root["air"]            = m_AirLevel;
    root["food"]           = m_FoodLevel;
    root["foodSaturation"] = m_FoodSaturationLevel;
    root["foodTickTimer"]  = m_FoodTickTimer;
    root["foodExhaustion"] = m_FoodExhaustionLevel;
    root["world"] = GetWorld()->GetName();

    if (m_GameMode == GetWorld()->GetGameMode())
    {
        root["gamemode"] = (int) eGameMode_NotSet;
    }
    else
    {
        root["gamemode"] = (int) m_GameMode;
    }

    Json::StyledWriter writer;
    std::string JsonData = writer.write(root);

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

    cFile f;
    if (!f.Open(SourceFile, cFile::fmWrite))
    {
        LOGERROR("ERROR WRITING PLAYER \"%s\" TO FILE \"%s\" - cannot open file", m_PlayerName.c_str(), SourceFile.c_str());
        return false;
    }
    if (f.Write(JsonData.c_str(), JsonData.size()) != (int)JsonData.size())
    {
        LOGERROR("ERROR WRITING PLAYER JSON TO FILE \"%s\"", SourceFile.c_str());
        return false;
    }
    return true;
}
예제 #3
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);
	}
}
/**
 * {@inheritDoc}
 */
void ADIS16448_IMU::UpdateTable() {
  auto table = GetTable();
  if (table) {
    table->PutNumber("Value", GetAngle());
    table->PutNumber("Pitch", GetPitch());
    table->PutNumber("Roll", GetRoll());
    table->PutNumber("Yaw", GetYaw());
    table->PutNumber("AccelX", GetAccelX());
    table->PutNumber("AccelY", GetAccelY());
    table->PutNumber("AccelZ", GetAccelZ());
    table->PutNumber("AngleX", GetAngleX());
    table->PutNumber("AngleY", GetAngleY());
    table->PutNumber("AngleZ", GetAngleZ());
  }
}
예제 #5
0
void Stable(void)
{
	static double gval[3];
	static double pre_pitch, pitch, pre_roll, roll;
	int i;
	if(timer_nowtime() - STABLETIMER > FRESHTIME)
	{
		ReadGSensor();
		gval[0] = (double)(G_AXIS_VALUE[0]);
		gval[1] = (double)(G_AXIS_VALUE[1]);
		gval[2] = (double)(G_AXIS_VALUE[2]);
		pitch = (GetPitch(gval)- 5.0*DEG_TO_RAD)*0.5 + pre_pitch*0.5;
		roll = (GetRoll(gval) - 4.5*DEG_TO_RAD)*0.5 + pre_roll*0.5;
	
	
		BODY_PITCH = BODY_PITCH + STABLE_P*pitch + (pitch - pre_pitch)*STABLE_D/FRESHTIME;
		BODY_ROLL = BODY_ROLL + STABLE_P*roll + (roll - pre_roll)*STABLE_D/FRESHTIME;

		if(BODY_PITCH > 60.0*DEG_TO_RAD)
			BODY_PITCH = 60.0*DEG_TO_RAD;
		else if(BODY_PITCH < -60.0*DEG_TO_RAD)
			BODY_PITCH = -60.0*DEG_TO_RAD;
		if(BODY_ROLL > 60.0*DEG_TO_RAD)
			BODY_ROLL = 60.0*DEG_TO_RAD;
		else if(BODY_ROLL < -60.0*DEG_TO_RAD)
			BODY_ROLL = -60.0*DEG_TO_RAD;
			
		
		for(i =0 ; i < 6; i++ )
		{
			LEGPOS[0] = LEGGOAL[3*i] - cos(J3MAP[i])*20.0;
			LEGPOS[1] = LEGGOAL[3*i+1] - sin(J3MAP[i])*20.0;
			LEGPOS[2] = LEGGOAL[3*i+2];
			Transform(BODY_YAW, BODY_PITCH, BODY_ROLL, LEGPOS);
			AdjustPos(POS_GAIN, LEGPOS);
			CenterToJoint3(LEGPOS,i,J3GOAL);
			Joint3ToJoint2(J3GOAL, J2GOAL);
			JointAngle(LEGPOS, J2GOAL,i,JANGLE);
			SetJoint(JANGLE,i);	
			rcservo_SetAction(POSITION, STABLETIME);
			STABLETIMER = timer_nowtime(); 
		}
		pre_pitch = pitch;
		pre_roll = roll;
	}
	rcservo_PlayAction();
}
예제 #6
0
파일: Group.cpp 프로젝트: Aion/caldari
void Group::CountRollVote(uint64 playerGUID, uint64 Guid, uint32 NumberOfPlayers, uint8 Choise)
{
    vector<Roll>::iterator roll = GetRoll(Guid);
    if (roll == RollId.end())
        return;

    map<uint64, RollVote>::iterator itr = roll->playerVote.find(playerGUID);
    // this condition means that player joins to the party after roll begins
    if (itr == roll->playerVote.end())
        return;

    if (roll->loot)
        if (roll->loot->items.size() == 0)
            return;

    switch (Choise)
    {
        case 0:                                             //Player choose pass
        {
            SendLootRoll(0, playerGUID, 128, 128, *roll);
            roll->totalPass++;
            itr->second = PASS;
        }
        break;
        case 1:                                             //player choose Need
        {
            SendLootRoll(0, playerGUID, 1, 1, *roll);
            roll->totalNeed++;
            itr->second = NEED;
        }
        break;
        case 2:                                             //player choose Greed
        {
            SendLootRoll(0, playerGUID, 2, 2, *roll);
            roll->totalGreed++;
            itr->second = GREED;
        }
        break;
    }
    if (roll->totalPass + roll->totalGreed + roll->totalNeed >= roll->totalPlayersRolling)
    {
        CountTheRoll(roll, NumberOfPlayers);
    }
}
예제 #7
0
파일: Player.cpp 프로젝트: Kortak/MCServer
bool cPlayer::SaveToDisk()
{
	cFile::CreateFolder(FILE_IO_PREFIX + AString("players"));

	// create the JSON data
	Json::Value JSON_PlayerPosition;
	JSON_PlayerPosition.append(Json::Value(GetPosX()));
	JSON_PlayerPosition.append(Json::Value(GetPosY()));
	JSON_PlayerPosition.append(Json::Value(GetPosZ()));

	Json::Value JSON_PlayerRotation;
	JSON_PlayerRotation.append(Json::Value(GetYaw()));
	JSON_PlayerRotation.append(Json::Value(GetPitch()));
	JSON_PlayerRotation.append(Json::Value(GetRoll()));

	Json::Value JSON_Inventory;
	m_Inventory.SaveToJson(JSON_Inventory);

	Json::Value root;
	root["position"]       = JSON_PlayerPosition;
	root["rotation"]       = JSON_PlayerRotation;
	root["inventory"]      = JSON_Inventory;
	root["health"]         = m_Health;
	root["xpTotal"]        = m_LifetimeTotalXp;
	root["xpCurrent"]      = m_CurrentXp;
	root["air"]            = m_AirLevel;
	root["food"]           = m_FoodLevel;
	root["foodSaturation"] = m_FoodSaturationLevel;
	root["foodTickTimer"]  = m_FoodTickTimer;
	root["foodExhaustion"] = m_FoodExhaustionLevel;
	root["world"]          = GetWorld()->GetName();
	root["isflying"]       = IsFlying();

	if (m_GameMode == GetWorld()->GetGameMode())
	{
		root["gamemode"] = (int) eGameMode_NotSet;
	}
	else
	{
		root["gamemode"] = (int) m_GameMode;
	}

	Json::StyledWriter writer;
	std::string JsonData = writer.write(root);

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

	cFile f;
	if (!f.Open(SourceFile, cFile::fmWrite))
	{
		LOGERROR("ERROR WRITING PLAYER \"%s\" TO FILE \"%s\" - cannot open file", GetName().c_str(), SourceFile.c_str());
		return false;
	}
	if (f.Write(JsonData.c_str(), JsonData.size()) != (int)JsonData.size())
	{
		LOGERROR("ERROR WRITING PLAYER JSON TO FILE \"%s\"", SourceFile.c_str()); 
		return false;
	}

	// Save 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);
	if (!StatSerializer.Save())
	{
		LOGERROR("Could not save stats for player %s", GetName().c_str());
		return false;
	}

	return true;
}
예제 #8
0
파일: Player.cpp 프로젝트: cedeel/MCServer
bool cPlayer::SaveToDisk()
{
	cFile::CreateFolder(FILE_IO_PREFIX + AString("players/"));  // Create the "players" folder, if it doesn't exist yet (#1268)
	cFile::CreateFolder(FILE_IO_PREFIX + AString("players/") + m_UUID.substr(0, 2));

	// create the JSON data
	Json::Value JSON_PlayerPosition;
	JSON_PlayerPosition.append(Json::Value(GetPosX()));
	JSON_PlayerPosition.append(Json::Value(GetPosY()));
	JSON_PlayerPosition.append(Json::Value(GetPosZ()));

	Json::Value JSON_PlayerRotation;
	JSON_PlayerRotation.append(Json::Value(GetYaw()));
	JSON_PlayerRotation.append(Json::Value(GetPitch()));
	JSON_PlayerRotation.append(Json::Value(GetRoll()));

	Json::Value JSON_Inventory;
	m_Inventory.SaveToJson(JSON_Inventory);

	Json::Value JSON_EnderChestInventory;
	cEnderChestEntity::SaveToJson(JSON_EnderChestInventory, m_EnderChestContents);

	Json::Value root;
	root["position"]            = JSON_PlayerPosition;
	root["rotation"]            = JSON_PlayerRotation;
	root["inventory"]           = JSON_Inventory;
	root["enderchestinventory"] = JSON_EnderChestInventory;
	root["health"]              = m_Health;
	root["xpTotal"]             = m_LifetimeTotalXp;
	root["xpCurrent"]           = m_CurrentXp;
	root["air"]                 = m_AirLevel;
	root["food"]                = m_FoodLevel;
	root["foodSaturation"]      = m_FoodSaturationLevel;
	root["foodTickTimer"]       = m_FoodTickTimer;
	root["foodExhaustion"]      = m_FoodExhaustionLevel;
	root["isflying"]            = IsFlying();
	root["lastknownname"]       = GetName();
	root["SpawnX"]              = GetLastBedPos().x;
	root["SpawnY"]              = GetLastBedPos().y;
	root["SpawnZ"]              = GetLastBedPos().z;

	if (m_World != NULL)
	{
		root["world"] = m_World->GetName();
		if (m_GameMode == m_World->GetGameMode())
		{
			root["gamemode"] = (int) eGameMode_NotSet;
		}
		else
		{
			root["gamemode"] = (int) m_GameMode;
		}
	}
	else
	{
		// This happens if the player is saved to new format after loading from the old format
		root["world"]    = m_LoadedWorldName;
		root["gamemode"] = (int) eGameMode_NotSet;
	}

	Json::StyledWriter writer;
	std::string JsonData = writer.write(root);

	AString SourceFile = GetUUIDFileName(m_UUID);

	cFile f;
	if (!f.Open(SourceFile, cFile::fmWrite))
	{
		LOGWARNING("Error writing player \"%s\" to file \"%s\" - cannot open file. Player will lose their progress.",
			GetName().c_str(), SourceFile.c_str()
		);
		return false;
	}
	if (f.Write(JsonData.c_str(), JsonData.size()) != (int)JsonData.size())
	{
		LOGWARNING("Error writing player \"%s\" to file \"%s\" - cannot save data. Player will lose their progress. ",
			GetName().c_str(), SourceFile.c_str()
		);
		return false;
	}

	// Save 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);
	if (!StatSerializer.Save())
	{
		LOGWARNING("Could not save stats for player %s", GetName().c_str());
		return false;
	}

	return true;
}