本文整理汇总了C++中ogre::Degree类的典型用法代码示例。如果您正苦于以下问题:C++ Degree类的具体用法?C++ Degree怎么用?C++ Degree使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Degree类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processUnbufferedMouseInput
bool PlaypenApp::processUnbufferedMouseInput(Ogre::Real dt)
{
// The following code checks how far the mouse has move since
// the last poll. This data can be used to rotate the camera
// around its X and Y axes (pitch and yaw, respectively).
Ogre::Degree rotY = -mInputDevice->getMouseRelativeX() * mRotateSpeed;
Ogre::Degree rotX = -mInputDevice->getMouseRelativeY() * mRotateSpeed;
// Use the relative mouse motion to rotate the camera.
mPhysicalCamera->yawRelative(rotY.valueDegrees());
mPhysicalCamera->pitchRelative(rotX.valueDegrees());
// Check mouse button states.
if (true == mInputDevice->getMouseButton(0))
{
// The left mouse button is down.
mPhysicalCamera->grasp();
}
else
{
// The left mouse button is up.
mPhysicalCamera->release();
}
// Return true to continue looping.
return true;
}
示例2:
TEST_F(TestDataProxyConverters, TestDegree)
{
Ogre::Degree res = mDataProxy.get<Ogre::Degree>("degree").first;
ASSERT_FLOAT_EQ(10.1, res.valueDegrees());
res = Ogre::Degree(50.5);
mDataProxy.put("degree_m", res);
ASSERT_EQ(mDataProxy.get<std::string>("degree_m").first, "50.500000");
}
示例3: getHorizontalMoonPosition
void Astronomy::getHorizontalMoonPosition (
LongReal jday,
Ogre::Degree longitude, Ogre::Degree latitude,
Ogre::Degree &azimuth, Ogre::Degree &altitude)
{
LongReal az, al;
getHorizontalMoonPosition(jday, longitude.valueDegrees (), latitude.valueDegrees (), az, al);
azimuth = Ogre::Degree(az);
altitude = Ogre::Degree(al);
}
示例4: WorkFromThread_Ogre
//------------------------------------------------------------------------
void TApplySetup_CameraUp::WorkFromThread_Ogre()
{
Ogre::Camera* pCamera = TModuleLogic::Get()->GetC()->pGraphicEngine->GetGE()->GetCamera();
nsMathTools::TVector3 point(0,0,0);
pCamera->setPosition(point.x, point.y, point.z);
pCamera->lookAt(mVCameraUp.x, mVCameraUp.y, mVCameraUp.z);
Ogre::Degree degree;
degree = 90;
Ogre::Radian rad;
rad = degree.valueRadians();
pCamera->pitch(rad);
}
示例5: UpdateVehicle
void LandVehicleSimulation::UpdateVehicle(Actor* vehicle, float seconds_since_last_frame)
{
if (vehicle->isBeingReset() || vehicle->ar_physics_paused || vehicle->ar_replay_mode)
return;
#ifdef USE_ANGELSCRIPT
if (vehicle->ar_vehicle_ai && vehicle->ar_vehicle_ai->IsActive())
return;
#endif // USE_ANGELSCRIPT
EngineSim* engine = vehicle->ar_engine;
if (engine && engine->HasStarterContact() &&
engine->GetAutoShiftMode() == SimGearboxMode::AUTO &&
engine->getAutoShift() != EngineSim::NEUTRAL)
{
Ogre::Vector3 dirDiff = vehicle->getDirection();
Ogre::Degree pitchAngle = Ogre::Radian(asin(dirDiff.dotProduct(Ogre::Vector3::UNIT_Y)));
if (std::abs(pitchAngle.valueDegrees()) > 2.0f)
{
if (engine->getAutoShift() > EngineSim::NEUTRAL && vehicle->ar_avg_wheel_speed < +0.02f && pitchAngle.valueDegrees() > 0.0f ||
engine->getAutoShift() < EngineSim::NEUTRAL && vehicle->ar_avg_wheel_speed > -0.02f && pitchAngle.valueDegrees() < 0.0f)
{
// anti roll back in SimGearboxMode::AUTO (DRIVE, TWO, ONE) mode
// anti roll forth in SimGearboxMode::AUTO (REAR) mode
float g = std::abs(App::GetSimTerrain()->getGravity());
float downhill_force = std::abs(sin(pitchAngle.valueRadians()) * vehicle->getTotalMass()) * g;
float engine_force = std::abs(engine->GetTorque()) / vehicle->getAvgPropedWheelRadius();
float ratio = std::max(0.0f, 1.0f - (engine_force / downhill_force));
if (vehicle->ar_avg_wheel_speed * pitchAngle.valueDegrees() > 0.0f)
{
ratio *= sqrt((0.02f - vehicle->ar_avg_wheel_speed) / 0.02f);
}
vehicle->ar_brake = sqrt(ratio);
}
}
else if (vehicle->ar_brake == 0.0f && !vehicle->ar_parking_brake && engine->GetTorque() == 0.0f)
{
float ratio = std::max(0.0f, 0.2f - std::abs(vehicle->ar_avg_wheel_speed)) / 0.2f;
vehicle->ar_brake = ratio;
}
}
if (vehicle->cc_mode)
{
LandVehicleSimulation::UpdateCruiseControl(vehicle, seconds_since_last_frame);
}
if (vehicle->sl_enabled)
{
LandVehicleSimulation::CheckSpeedLimit(vehicle, seconds_since_last_frame);
}
}
示例6: createEntityByTypeTransform
CEntity* CEntityFactory::createEntityByTypeTransform(const std::string &type, Matrix4 transform, CMap *map)
{
//solo hacemos creamos algo a partir de un arquetipo así que nos aseguramos de que exista
ArchetypeMap::iterator find = _archetypes.find(type);
if( find == _archetypes.end())
{
return NULL;
}
//nos aseguramos de construir un nombre unico
//int id = EntityID::_nextId;
std::string uniqueName = type;
//Hacer un new para que no se desreferencie en el futuro
Map::CEntity *entityInfo = new Map::CEntity(uniqueName);
//El tipo
entityInfo->setType(type);
//La posicion
Vector3 pos;
Vector3 scale;
Quaternion quat;
transform.decomposition(pos, scale, quat);
std::string string = std::to_string(pos.x)+','+std::to_string(pos.y)+','+std::to_string(pos.z);
entityInfo->setAttribute("position", string );
//El nombre unico
entityInfo->setName(entityInfo->getName()+std::to_string(EntityID::_nextId));
//La orientacion
Vector3 axis;
Ogre::Degree angle;
quat.ToAngleAxis(angle, axis);
string = std::to_string(axis.x) +","+std::to_string(axis.y)+","+std::to_string(axis.z);
entityInfo->setAttribute("orientation",string);
//std::cout<<string<<std::endl;
string = std::to_string(angle.valueDegrees());
//std::cout<<string<<std::endl;
entityInfo->setAttribute("orientation_angle", string);
//meterlo en la cola de entidades del parser para que se borren al recargar mapas
Map::CMapParser::getSingletonPtr()->addEntityInfo(entityInfo);
return createEntity(entityInfo, map);
}
示例7: assert
void
Entity::SetRotation( const Ogre::Degree& rotation )
{
assert( m_model_root_node );
float angle = rotation.valueDegrees() - Ogre::Math::Floor( rotation.valueDegrees() / 360.0f ) * 360.0f;
if( angle < 0 )
{
angle = 360 + angle;
}
Ogre::Quaternion q;
Ogre::Vector3 vec = Ogre::Vector3::UNIT_Z;
q.FromAngleAxis( Ogre::Radian( Ogre::Degree( angle ) ), vec );
m_model_root_node->setOrientation( q );
m_DirectionNode->setOrientation( q );
}
示例8: updateGui
void QuaternionAdapter::updateGui(const Ogre::Quaternion& quaternion)
{
mSelfUpdate = true;
if (&quaternion) {
Ogre::Vector3 axis;
Ogre::Degree angle;
quaternion.ToAngleAxis( angle, axis);
mVectorAdapter.updateGui(axis);
if (mDegreeWindow) {
mDegreeWindow->setText(Ogre::StringConverter::toString(angle.valueDegrees()));
}
} else {
mVectorAdapter.updateGui(Ogre::Vector3::ZERO);
if (mDegreeWindow) {
mDegreeWindow->setText("");
}
}
mSelfUpdate = false;
}
示例9: setObserverLongitude
void PointStarfield::setObserverLongitude (Ogre::Degree value)
{
if (!Math::RealEqual (
mObserverLongitude.valueDegrees (),
value.valueDegrees (),
this->getObserverPositionRebuildDelta ().valueDegrees ()))
{
mObserverLongitude = value;
invalidateGeometry ();
}
}
示例10: blockMeleeAttack
bool blockMeleeAttack(const MWWorld::Ptr &attacker, const MWWorld::Ptr &blocker, const MWWorld::Ptr &weapon, float damage)
{
if (!blocker.getClass().hasInventoryStore(blocker))
return false;
if (blocker.getClass().getCreatureStats(blocker).getKnockedDown()
|| blocker.getClass().getCreatureStats(blocker).getHitRecovery())
return false;
MWWorld::InventoryStore& inv = blocker.getClass().getInventoryStore(blocker);
MWWorld::ContainerStoreIterator shield = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
if (shield == inv.end() || shield->getTypeName() != typeid(ESM::Armor).name())
return false;
Ogre::Degree angle = signedAngle (Ogre::Vector3(attacker.getRefData().getPosition().pos) - Ogre::Vector3(blocker.getRefData().getPosition().pos),
blocker.getRefData().getBaseNode()->getOrientation().yAxis(), Ogre::Vector3(0,0,1));
const MWWorld::Store<ESM::GameSetting>& gmst = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
if (angle.valueDegrees() < gmst.find("fCombatBlockLeftAngle")->getFloat())
return false;
if (angle.valueDegrees() > gmst.find("fCombatBlockRightAngle")->getFloat())
return false;
MWMechanics::CreatureStats& blockerStats = blocker.getClass().getCreatureStats(blocker);
if (blockerStats.getDrawState() == DrawState_Spell)
return false;
MWMechanics::CreatureStats& attackerStats = attacker.getClass().getCreatureStats(attacker);
float blockTerm = blocker.getClass().getSkill(blocker, ESM::Skill::Block) + 0.2 * blockerStats.getAttribute(ESM::Attribute::Agility).getModified()
+ 0.1 * blockerStats.getAttribute(ESM::Attribute::Luck).getModified();
float enemySwing = attackerStats.getAttackStrength();
float swingTerm = enemySwing * gmst.find("fSwingBlockMult")->getFloat() + gmst.find("fSwingBlockBase")->getFloat();
float blockerTerm = blockTerm * swingTerm;
if (blocker.getClass().getMovementSettings(blocker).mPosition[1] <= 0)
blockerTerm *= gmst.find("fBlockStillBonus")->getFloat();
blockerTerm *= blockerStats.getFatigueTerm();
float attackerSkill = attacker.getClass().getSkill(attacker, weapon.getClass().getEquipmentSkill(weapon));
float attackerTerm = attackerSkill + 0.2 * attackerStats.getAttribute(ESM::Attribute::Agility).getModified()
+ 0.1 * attackerStats.getAttribute(ESM::Attribute::Luck).getModified();
attackerTerm *= attackerStats.getFatigueTerm();
int x = int(blockerTerm - attackerTerm);
int iBlockMaxChance = gmst.find("iBlockMaxChance")->getInt();
int iBlockMinChance = gmst.find("iBlockMinChance")->getInt();
x = std::min(iBlockMaxChance, std::max(iBlockMinChance, x));
int roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 100; // [0, 99]
if (roll < x)
{
// Reduce shield durability by incoming damage
if (shield->getCellRef().mCharge == -1)
shield->getCellRef().mCharge = shield->getClass().getItemMaxHealth(*shield);
shield->getCellRef().mCharge -= std::min(shield->getCellRef().mCharge, int(damage));
if (!shield->getCellRef().mCharge)
inv.unequipItem(*shield, blocker);
// Reduce blocker fatigue
const float fFatigueBlockBase = gmst.find("fFatigueBlockBase")->getFloat();
const float fFatigueBlockMult = gmst.find("fFatigueBlockMult")->getFloat();
const float fWeaponFatigueBlockMult = gmst.find("fWeaponFatigueBlockMult")->getFloat();
MWMechanics::DynamicStat<float> fatigue = blockerStats.getFatigue();
float normalizedEncumbrance = blocker.getClass().getEncumbrance(blocker) / blocker.getClass().getCapacity(blocker);
normalizedEncumbrance = std::min(1.f, normalizedEncumbrance);
float fatigueLoss = fFatigueBlockBase + normalizedEncumbrance * fFatigueBlockMult;
fatigueLoss += weapon.getClass().getWeight(weapon) * attackerStats.getAttackStrength() * fWeaponFatigueBlockMult;
fatigue.setCurrent(fatigue.getCurrent() - fatigueLoss);
blockerStats.setFatigue(fatigue);
blockerStats.setBlock(true);
if (blocker.getClass().isNpc())
blocker.getClass().skillUsageSucceeded(blocker, ESM::Skill::Block, 0);
return true;
}
return false;
}
示例11: addPropertyQuaternion
void PropertiesWindow::addPropertyQuaternion(const Property& prop,
CEGUI::MultiColumnList* table, const CeGuiString& key)
{
// Check column count
// if count = 3 | MainTable
// if count = 2 | Array table
int colCount = table->getColumnCount();
int rowCount = table->getRowCount();
Ogre::Quaternion quat = prop.toQuaternion();
Ogre::Degree angle;
Ogre::Vector3 axis;
quat.ToAngleAxis( angle, axis );
char buf_angle [50];
sprintf(buf_angle, "%1.2f", angle.valueDegrees());
char buf_v1 [50];
sprintf(buf_v1, "%1.2f", axis.x);
char buf_v2 [50];
sprintf(buf_v2, "%1.2f", axis.y);
char buf_v3 [50];
sprintf(buf_v3, "%1.2f", axis.z);
// Table has the three columns Key, Type, Value
if ( colCount == 3 )
{
// Add row for the first IntTriple value
table->addRow(rowCount);
table->setItem(new ListboxTextItem(key + " "), 0, rowCount);
table->setItem(new ListboxTextItem("Quaternion "), 1, rowCount);
table->setItem(new ListboxTextItem("Axis: ( " +
CEGUI::String(buf_v1) + ", " +
CEGUI::String(buf_v2) + ", " +
CEGUI::String(buf_v3) + " )"),
2,
rowCount);
// Add second for the second IntTriple value
table->addRow(rowCount + 1);
table->setItem(new ListboxTextItem("Degree: " +
CEGUI::String(buf_angle)),
2,
rowCount + 1);
}
// Table has the two columns Type, Value
else if ( colCount == 2 )
{
table->addRow(rowCount);
table->setItem(new ListboxTextItem("Quaternion "), 0, rowCount);
table->setItem(new ListboxTextItem("Axis: ( " +
CEGUI::String(buf_v1) + ", " +
CEGUI::String(buf_v2) + ", " +
CEGUI::String(buf_v3) + " )"),
2,
rowCount);
// Add second for the second IntTriple value
table->addRow(rowCount + 1);
table->setItem(new ListboxTextItem("Degree " +
CEGUI::String(buf_angle)),
2,
rowCount + 1);
}
}
示例12: handleInput
void handleInput(Ogre::Real elapsedRealTime)
{
// This variable can be used to keep keys from repeating too fast.
static Ogre::Real toggleTimer = 0;
if (toggleTimer >= 0)
{
toggleTimer -= elapsedRealTime;
}
OIS::Keyboard* keyboard = gEngine.getKeyboard();
if (keyboard->isKeyDown(OIS::KC_W))
{
gCar->forward();
}
else if (keyboard->isKeyDown(OIS::KC_S))
{
gCar->reverse();
}
else
{
gCar->idle();
}
if (keyboard->isKeyDown(OIS::KC_A))
{
gCar->setSteering(-1);
}
else if (keyboard->isKeyDown(OIS::KC_D))
{
gCar->setSteering(1);
}
else
{
gCar->setSteering(0);
}
// If available, get data from the game controller.
if (gGamePad)
{
// Update the game controller state.
SDL_JoystickUpdate();
Ogre::Real joy0X = (Ogre::Real)SDL_JoystickGetAxis(gGamePad, 0) /
(Ogre::Real)32768;
Ogre::Real joy0Y = (Ogre::Real)SDL_JoystickGetAxis(gGamePad, 1) /
(Ogre::Real)32768;
Ogre::Real joy1X = (Ogre::Real)SDL_JoystickGetAxis(gGamePad, 4) /
(Ogre::Real)32768;
Ogre::Real joy1Y = (Ogre::Real)SDL_JoystickGetAxis(gGamePad, 3) /
(Ogre::Real)32768;
if (fabs(joy0Y) > 0.1)
{
gCar->setThrottle(-joy0Y);
}
else
{
gCar->idle();
}
if (fabs(joy0X) > 0.1)
{
gCar->setSteering(joy0X);
}
else
{
gCar->setSteering(0);
}
if (joy1X > 0.2 || joy1X < -0.2)
{
Ogre::Degree rotAroundY = -Ogre::Degree(joy1X);
gEngine.getCamera()->yawRelative(rotAroundY.valueDegrees());
}
if (joy1Y > 0.2 || joy1Y < -0.2)
{
Ogre::Degree rotAroundX = -Ogre::Degree(joy1Y);
gEngine.getCamera()->pitchRelative(rotAroundX.valueDegrees());
}
}
// Toggle GUI.
if (keyboard->isKeyDown(OIS::KC_G) && toggleTimer <= 0)
{
Ogre::Overlay* debugOverlay = Ogre::OverlayManager::getSingleton().
getByName("Verve/Debug");
if (debugOverlay->isVisible())
{
debugOverlay->hide();
gAgentDebugger->setDisplayEnabled(false);
}
else
{
debugOverlay->show();
gAgentDebugger->setDisplayEnabled(true);
}
//.........这里部分代码省略.........