本文整理汇总了C++中Planet类的典型用法代码示例。如果您正苦于以下问题:C++ Planet类的具体用法?C++ Planet怎么用?C++ Planet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Planet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init_objects
void init_objects() {
renderables = list<Renderable *>();
Planet *earth = new Planet(10, 0, 0, 0);
// TODO: need to sort out the relative paths
earth->setTexture("resources/earthmap1k.jpg");
renderables.push_back(earth);
// Setup the player
Player::player = new Player(12);
renderables.push_back(Player::player);
// Create the stars
StarGenerator *stars = new StarGenerator();
renderables.push_back(stars);
}
示例2: GetFrame
double DynamicBody::CalcAtmosphericForce(double dragCoeff) const
{
Body *body = GetFrame()->GetBody();
if (!body || !GetFrame()->IsRotFrame() || !body->IsType(Object::PLANET))
return 0.0;
Planet *planet = static_cast<Planet*>(body);
double dist = GetPosition().Length();
double speed = m_vel.Length();
double pressure, density;
planet->GetAtmosphericState(dist, &pressure, &density);
const double radius = GetClipRadius(); // bogus, preserving behaviour
const double area = radius;
// ^^^ yes that is as stupid as it looks
return 0.5*density*speed*speed*area*dragCoeff;
}
示例3: i
void PlanetariumEngine::update_positions(void)
{
QHashIterator<const sim::Body*,Planet*> i(mObjects);
while (i.hasNext()) {
i.next();
Planet* p = i.value();
const sim::Body* body = i.key();
double* std_pos = body->getPosition();
irr::core::vector3df position( std_pos[0] * mScale,
std_pos[1] * mScale,
std_pos[2] * mScale);
p->getIrrlichtNode()->setPosition(position);
}
}
示例4: Player
/**\brief Load a player from a file.
* \param[in] filename of a player's xml saved game.
* \returns pointer to new Player instance.
*/
Player* Player::Load( string filename ) {
xmlDocPtr doc;
xmlNodePtr cur;
Player* newPlayer = new Player();
File xmlfile = File (filename);
long filelen = xmlfile.GetLength();
char *buffer = xmlfile.Read();
doc = xmlParseMemory( buffer, static_cast<int>(filelen) );
cur = xmlDocGetRootElement( doc );
newPlayer->FromXMLNode( doc, cur );
// We check the planet location at loadtime in case planet moved or lastPlanet changed.
// This happens with --random-universe. TODO: Does this matter? random-universe was removed.
Planet* p = Menu::GetCurrentScenario()->GetPlanets()->GetPlanet( newPlayer->lastPlanet );
if( p != NULL ) {
newPlayer->SetWorldPosition( p->GetWorldPosition() );
} else {
LogMsg(INFO, "There is no planet named: '%s'.", newPlayer->lastPlanet.c_str() );
}
newPlayer->RemoveLuaControlFunc();
// We can't start the game with bad player Information
assert( newPlayer->GetModelName() != "" );
assert( newPlayer->GetEngineName() != "" );
// Tell Lua to initialize these escorts.
for(list<Player::HiredEscort*>::iterator iter_escort = newPlayer->hiredEscorts.begin(); iter_escort != newPlayer->hiredEscorts.end(); iter_escort++) {
(*iter_escort)->Lua_Initialize( newPlayer->GetID(), newPlayer->GetWorldPosition() );
}
// Remember this Player
newPlayer->lastLoadTime = time(NULL);
LogMsg(INFO, "Successfully loaded the player: '%s'.", newPlayer->GetName().c_str() );
LogMsg(INFO, "Loaded Player '%s' with Model='%s' Engine='%s' Credits = %d at (%.0f,%.0f).",
newPlayer->GetName().c_str(),
newPlayer->GetModel()->GetName().c_str(),
newPlayer->GetEngine()->GetName().c_str(),
newPlayer->GetCredits(),
newPlayer->GetWorldPosition().GetX(), newPlayer->GetWorldPosition().GetY()
);
return newPlayer;
}
示例5: CanMoveFrom
bool GameEngine::CanMoveFrom(Planet& planeta, uint16 gracz) const
{
uint16 okup=planeta.RetOkupant();
if(okup)
{
if(okup==gracz)
return true;
return false;
}
else
{
if(planeta.RetGracz()==gracz)
return true;
return false;
};
};
示例6: inputFrame
Result Bombard::inputFrame(Frame * f, unsigned int playerid) {
Result r = Order::inputFrame(f, playerid);
if(!r) return r;
ObjectManager *om = Game::getGame()->getObjectManager();
IGObject *planetObj = om->getObject(planet->getObjectId());
Planet *planetData = dynamic_cast<Planet*>(planetObj->getObjectBehaviour());
if(!planetData)
planet->setObjectId(0);
else if(planetData->getOwner() == playerid)
planet->setObjectId(0);
return Success();
}
示例7: update
void ChunkManager::update()
{
if (!planetList.empty()) {
timeNow = Planet::getTimer().getMilliseconds();
std::list<Planet*>::iterator i;
for (i = planetList.begin(); i != planetList.end(); ++i) {
Planet *planet = *i;
expirationTime = planet->getChunkLoader()->getExpirationTime();
for (Ogre::uint32 o = 0; o < 6; ++o) {
updateNode(planet->getCubeFace(o));
}
}
}
}
示例8: GetFrame
void DynamicBody::CalcExternalForce()
{
// gravity
if (!GetFrame()) return; // no external force if not in a frame
Body *body = GetFrame()->GetBody();
if (body && !body->IsType(Object::SPACESTATION)) { // they ought to have mass though...
vector3d b1b2 = GetPosition();
double m1m2 = GetMass() * body->GetMass();
double invrsqr = 1.0 / b1b2.LengthSqr();
double force = G*m1m2 * invrsqr;
m_externalForce = -b1b2 * sqrt(invrsqr) * force;
}
else m_externalForce = vector3d(0.0);
m_gravityForce = m_externalForce;
// atmospheric drag
if (body && GetFrame()->IsRotFrame() && body->IsType(Object::PLANET))
{
Planet *planet = static_cast<Planet*>(body);
double dist = GetPosition().Length();
double speed = m_vel.Length();
double pressure, density;
planet->GetAtmosphericState(dist, &pressure, &density);
const double radius = GetClipRadius(); // bogus, preserving behaviour
const double AREA = radius;
// ^^^ yes that is as stupid as it looks
const double DRAG_COEFF = 0.1; // 'smooth sphere'
vector3d dragDir = -m_vel.NormalizedSafe();
vector3d fDrag = 0.5*density*speed*speed*AREA*DRAG_COEFF*dragDir;
// make this a bit less daft at high time accel
// only allow atmosForce to increase by .1g per frame
vector3d f1g = m_atmosForce + dragDir * GetMass();
if (fDrag.LengthSqr() > f1g.LengthSqr()) m_atmosForce = f1g;
else m_atmosForce = fDrag;
m_externalForce += m_atmosForce;
}
else m_atmosForce = vector3d(0.0);
// centrifugal and coriolis forces for rotating frames
if (GetFrame()->IsRotFrame()) {
vector3d angRot(0, GetFrame()->GetAngSpeed(), 0);
m_externalForce -= m_mass * angRot.Cross(angRot.Cross(GetPosition())); // centrifugal
m_externalForce -= 2 * m_mass * angRot.Cross(GetVelocity()); // coriolis
}
}
示例9: Ship
void Scene::createScene(TextureManager* texture, ID3D11Device* pd3dDevice, ID3D11DeviceContext* context, Shader* shader){
std::wstring txtName = L"ships/F5S4.png";
std::wstring playerShip = L"ships/F5S2.png";
std::wstring planetTexture = L"planets/spr_planet01.png";
texture->createTexture(&txtName);
texture->createTexture(&playerShip);
texture->createTexture(&planetTexture);
int count = 0;
int h = 6;
for (int i = 0; i <= trisH; i++){
float startX = -h * (i / 2.0);
float startY = i * h;
for (int b = 0; b < i; b++){
ships[count++] = new Ship(txtName.c_str(), txtName.c_str(), &Vec3{ startX + b*h, startY, 0 });
}
}
ships[shipAmount - 1] = new Ship(txtName.c_str(), txtName.c_str(), &Vec3{0,-2,0 });
for (int i = 0; i < shipAmount; i++){
ships[i]->create(pd3dDevice,context,shader);
ships[i]->setTexture(txtName);
ships[i]->mulScale(1, 1, 1);
registerObject(ships[i]);
}
getPlayerShip()->setTexture(playerShip);
Planet* p = new Planet(&Vec3(100,0,0));
p->create(pd3dDevice, context, shader);
p->setTexture(planetTexture);
p->mulScale(35, 35, 1);
registerObject(p);
Planet* p2 = new Planet(&Vec3(-100, 0, 0));
p2->create(pd3dDevice, context, shader);
p2->setTexture(planetTexture);
p2->mulScale(35, 35, 1);
registerObject(p2);
Planet* p3 = new Planet(&Vec3(0, 100, 0));
p3->create(pd3dDevice, context, shader);
p3->setTexture(planetTexture);
p3->mulScale(15, 15, 1);
//registerObject(p3);
}
示例10: makePlanet
void SolarSystemCreator::createWorlds()
{
double currentDistance;
_star->numDesert(0);
_star->numGasGiant(0);
double prevSatDistance = 0.0;
//double prevDistance = 0.0;
const double MIN_PLANET_DISTANCE_GG = 4000000.0;
const double MAX_OUTER_PLANET = 100.0;
_star->calcStarValue();
for (int h = 0; h < _orbits; h++) {
bool advanceNextPlanet = true;
do {
Planet px;
px.setStar(_star.data());
if (h == 0) {
double dModifier = 0.1;
if (_star->starType() == NSStar::stM)
dModifier *= .33;
if (_star->starType() == NSStar::stK)
dModifier *= .66;
if (_star->starType() == NSStar::stF)
dModifier *= 1.25;
currentDistance = dModifier + SSGX::floatRand() * dModifier;
}
else {
prevSatDistance = currentDistance;
auto minDistance = currentDistance + (prevSatDistance * 50.0 / 150000000.0);
auto newDistance = (currentDistance * (1.05+ (double)(rand() % 900)/1000.0)) - currentDistance;
if (minDistance > newDistance)
currentDistance += minDistance;
else
currentDistance += newDistance;
}
int chance = SSGX::d10();
if (chance < 8 && currentDistance < MAX_OUTER_PLANET) {
makePlanet(advanceNextPlanet, MIN_PLANET_DISTANCE_GG, currentDistance, prevSatDistance, px);
}
} while (!advanceNextPlanet);
}
_star->calcStarValue();
}
示例11:
Planet::Planet(const Planet& p) :
ships_count(p.ships_count),
_planet_id(p._planet_id),
_growth_rate(p._growth_rate),
_coordinate(p.coordinate()),
_ownerID(p._ownerID)
{
}
示例12: assert
map<uint32_t, pair<string, uint32_t> > Colonize::generateListOptions() {
map<uint32_t, pair<string,uint32_t> > options;
Game* game = Game::getGame();
ObjectManager* om = game->getObjectManager();
IGObject::Ptr selectedObj = game->getObjectManager()->getObject(
game->getOrderManager()->getOrderQueue(orderqueueid)->getObjectId());
Planet* planet = dynamic_cast<Planet*>(selectedObj->getObjectBehaviour());
assert(planet);
om->doneWithObject(selectedObj->getID());
set<uint32_t> allObjs = om->getAllIds();
uint32_t availibleUnits = planet->getResource("Army").first + planet->getResource("Army").second - 1;
/* This for loop will iterate over every adjacent planet.
This is where the majority of the work occurs, and we populate our list.
You see here we select an item of the map, in my case (*i)->getID(), and
for that item we create a pair.
If its a little hard to read, here is what I am doing:
options[#] = pair<string,uint32_t>( "title", max# );
For my pair I set the title as the adjacent planet to move to, and set the
max to availible units. */
for(set<uint32_t>::iterator i = allObjs.begin(); i != allObjs.end(); i++) {
IGObject::Ptr currObj = om->getObject((*i));
Planet* owned = dynamic_cast<Planet*>(currObj->getObjectBehaviour());
if ( owned != NULL && owned->getOwner() == 0) {
options[owned->getID()] = pair<string,uint32_t>(
owned->getName(), availibleUnits );
}
}
return options;
}
示例13: Entity
void TestGame::Init() {
Entity *camera = new Entity( Vector3f( 0, 5, 15 ) );
camera->AddComponent( new FreeLookFreeMoveComponent() );
SetCamera( camera );
Planet *planet = new Planet( 12310, 4, 10.0f, 30 );
Entity *entity = new Entity();
RenderComponent* render = new RenderComponent( planet->CreateMesh() );
render->SetShaderType( ShaderType::SHADER_COLORIZED );
entity->AddComponent( render );
entity->AddComponent( new PlanetColorComponent( planet ) );
AddToScene( entity );
// Entity* cube = new Entity();
// cube->AddComponent( new RenderComponent( "cube.obj", "test.png" ) );
// AddToScene( cube );
}
示例14: Planet
Planet* UnitFactory::createPlanet( QVector x,
QVector y,
float vely,
const Vector &rotvel,
float pos,
float gravity,
float radius,
const std::string &filename,
const std::string &technique,
const std::string &unitname,
BLENDFUNC sr,
BLENDFUNC ds,
const vector< string > &dest,
const QVector &orbitcent,
Unit *parent,
const GFXMaterial &ourmat,
const std::vector< GFXLightLocal > &ligh,
int faction,
string fullname,
bool inside_out,
ObjSerial netcreate )
{
_Universe->netLock( true );
Planet *p = new Planet( x, y, vely, rotvel, pos, gravity, radius,
filename, technique, unitname, dest, orbitcent, parent, faction,
fullname, inside_out, ligh.size() );
_Universe->netLock( false );
if (netcreate)
p->SetSerial( netcreate );
/*
* // False: Only allow creation through system files? Doesn't make sense to be able to dynamically generate these.
* // Could cause inconsistencies with new clients that just read system files.
* if ( false && !_Universe->netLocked()) {
* NetBuffer netbuf;
* // Send a packet to clients in order to make them create this unit
*
* addPlanetBuffer( netbuf, x, y, vely, rotvel, pos, gravity, radius, filename, sr, ds, dest, orbitcent, parent, ourmat, ligh, faction, fullname, inside_out, netcreate);
* endBuffer( netbuf );
* VSServer->broadcast( netbuf, 0, _Universe->activeStarSystem()->GetZone(), CMD_ENTERCLIENT, true);
* }
* VSServer->invalidateSnapshot();
*/
return p;
}
示例15: getRandomPlanetPosition
// round从0算起
void StageEndlessLayer::initCatPlanetsWithRound(int round)
{
int countForSide = 0;
if(round < 2)
countForSide = 2;
else
countForSide = 3;
for(int i = 0; i <countForSide; i++)
{
int fightUnit = 10;
CCPoint posi = getRandomPlanetPosition();
if(posi.x > 0 && posi.y > 0)
{
Planet* cat = makePlanet(kForceSideCat, posi, fightUnit, 0);
m_pCatPlanetArray->addObject(cat);
}
}
// 以9为一个循环数
int levelSum = (round % 9)* 1.5;
levelSum -=2;
if(levelSum < 0)
levelSum = 0;
if(levelSum > 5)
levelSum = 5;
while(levelSum > 0)
{
CCObject* pOb = NULL;
CCARRAY_FOREACH(m_pCatPlanetArray, pOb)
{
Planet* pPlanet = (Planet*) pOb;
if(!pPlanet->isDirty())
{
if(levelSum >0)
{
pPlanet->levelUp();
--levelSum;
}
}
}
}