本文整理汇总了C++中SpaceStation::GetFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ SpaceStation::GetFrame方法的具体用法?C++ SpaceStation::GetFrame怎么用?C++ SpaceStation::GetFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpaceStation
的用法示例。
在下文中一共展示了SpaceStation::GetFrame方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Space
Game::Game(const SystemPath &path, double time) :
m_time(time),
m_state(STATE_NORMAL),
m_wantHyperspace(false),
m_timeAccel(TIMEACCEL_1X),
m_requestedTimeAccel(TIMEACCEL_1X),
m_forceTimeAccel(false)
{
Pi::FlushCaches();
m_space.reset(new Space(this, path));
SpaceStation *station = static_cast<SpaceStation*>(m_space->FindBodyForPath(&path));
assert(station);
m_player.reset(new Player("kanara"));
m_space->AddBody(m_player.get());
m_player->SetFrame(station->GetFrame());
m_player->SetDockedWith(station, 0);
Polit::Init();
CreateViews();
}
示例2: l_space_spawn_ship_docked
/*
* Function: SpawnShipDocked
*
* Create a ship and place it inside the given <SpaceStation>.
*
* > ship = Space.SpawnShipDocked(type, station)
*
* Parameters:
*
* type - the name of the ship
*
* station - the <SpaceStation> to place the ship inside
*
* Return:
*
* ship - a <Ship> object for the new ship, or nil if there was no space
* inside the station
*
* Availability:
*
* alpha 10
*
* Status:
*
* stable
*/
static int l_space_spawn_ship_docked(lua_State *l)
{
if (!Pi::game)
luaL_error(l, "Game is not started");
LUA_DEBUG_START(l);
const char *type = luaL_checkstring(l, 1);
if (! ShipType::Get(type))
luaL_error(l, "Unknown ship type '%s'", type);
SpaceStation *station = LuaSpaceStation::CheckFromLua(2);
int port = station->GetFreeDockingPort();
if (port < 0)
return 0;
Ship *ship = new Ship(type);
assert(ship);
ship->SetFrame(station->GetFrame());
Pi::game->GetSpace()->AddBody(ship);
ship->SetDockedWith(station, port);
LuaShip::PushToLua(ship);
LUA_DEBUG_END(l, 1);
return 1;
}
示例3: l_space_spawn_ship_parked
/*
* Function: SpawnShipParked
*
* Create a ship and place it in one of the given <SpaceStation's> parking spots.
*
* > ship = Space.SpawnShipParked(type, station)
*
* For orbital stations the parking spots are some distance from the door, out
* of the path of ships entering and leaving the station. For group stations
* the parking spots are directly above the station, usually some distance
* away.
*
* Parameters:
*
* type - the name of the ship
*
* station - the <SpaceStation> to place the near
*
* Return:
*
* ship - a <Ship> object for the new ship, or nil if there was no space
* inside the station
* Availability:
*
* alpha 10
*
* Status:
*
* experimental
*/
static int l_space_spawn_ship_parked(lua_State *l)
{
if (!Pi::game)
luaL_error(l, "Game is not started");
LUA_DEBUG_START(l);
const char *type = luaL_checkstring(l, 1);
if (! ShipType::Get(type))
luaL_error(l, "Unknown ship type '%s'", type);
SpaceStation *station = LuaObject<SpaceStation>::CheckFromLua(2);
int slot;
if (!station->AllocateStaticSlot(slot))
return 0;
Ship *ship = new Ship(type);
assert(ship);
double parkDist = station->GetStationType()->parkingDistance;
parkDist -= ship->GetPhysRadius(); // park inside parking radius
double parkOffset = 0.5 * station->GetStationType()->parkingGapSize;
parkOffset += ship->GetPhysRadius(); // but outside the docking gap
double xpos = (slot == 0 || slot == 3) ? -parkOffset : parkOffset;
double zpos = (slot == 0 || slot == 1) ? -parkOffset : parkOffset;
vector3d parkPos = vector3d(xpos, parkDist, zpos);
parkPos = station->GetPosition() + station->GetOrient() * parkPos;
// orbital stations have Y as axis of rotation
matrix3x3d rot = matrix3x3d::RotateX(M_PI/2) * station->GetOrient();
ship->SetFrame(station->GetFrame());
ship->SetVelocity(vector3d(0.0));
ship->SetPosition(parkPos);
ship->SetOrient(rot);
Pi::game->GetSpace()->AddBody(ship);
ship->AIHoldPosition();
LuaObject<Ship>::PushToLua(ship);
LUA_DEBUG_END(l, 1);
return 1;
}
示例4: Start
void Pi::Start()
{
WorldView *view = new WorldView();
Gui::Fixed *splash = new Gui::Fixed(Gui::Screen::GetWidth(), Gui::Screen::GetHeight());
Gui::Screen::AddBaseWidget(splash, 0, 0);
splash->SetTransparency(true);
const float w = Gui::Screen::GetWidth() / 2;
const float h = Gui::Screen::GetHeight() / 2;
const int OPTS = 5;
Gui::ToggleButton *opts[OPTS];
opts[0] = new Gui::ToggleButton(); opts[0]->SetShortcut(SDLK_1, KMOD_NONE);
opts[1] = new Gui::ToggleButton(); opts[1]->SetShortcut(SDLK_2, KMOD_NONE);
opts[2] = new Gui::ToggleButton(); opts[2]->SetShortcut(SDLK_3, KMOD_NONE);
opts[3] = new Gui::ToggleButton(); opts[3]->SetShortcut(SDLK_4, KMOD_NONE);
opts[4] = new Gui::ToggleButton(); opts[4]->SetShortcut(SDLK_5, KMOD_NONE);
splash->Add(opts[0], w, h-64);
splash->Add(new Gui::Label("New game starting on Earth"), w+32, h-64);
splash->Add(opts[1], w, h-32);
splash->Add(new Gui::Label("New game starting on Epsilon Eridani"), w+32, h-32);
splash->Add(opts[2], w, h);
splash->Add(new Gui::Label("New game starting on debug point"), w+32, h);
splash->Add(opts[3], w, h+32);
splash->Add(new Gui::Label("Load a saved game"), w+32, h+32);
splash->Add(opts[4], w, h+64);
splash->Add(new Gui::Label("Quit"), w+32, h+64);
splash->ShowAll();
int choice = 0;
Uint32 last_time = SDL_GetTicks();
float _time = 0;
do {
Pi::HandleEvents();
Render::PrepareFrame();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
float fracH = 1.0 / Pi::GetScrAspect();
glFrustum(-1, 1, -fracH, fracH, 1.0f, 10000.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SDL_ShowCursor(1);
SDL_WM_GrabInput(SDL_GRAB_OFF);
draw_intro(view, _time);
Render::PostProcess();
Gui::Draw();
Render::SwapBuffers();
Pi::frameTime = 0.001*(SDL_GetTicks() - last_time);
_time += Pi::frameTime;
last_time = SDL_GetTicks();
// poll ui instead of using callbacks :-J
for (int i=0; i<OPTS; i++) if (opts[i]->GetPressed()) choice = i+1;
} while (!choice);
splash->HideAll();
Gui::Screen::RemoveBaseWidget(splash);
delete splash;
delete view;
InitGame();
if (choice == 1) {
/* Earth start point */
SBodyPath path(0,0,0);
Space::DoHyperspaceTo(&path);
//Frame *pframe = *(++(++(Space::rootFrame->m_children.begin())));
//player->SetFrame(pframe);
// XXX there isn't a sensible way to find stations for a planet.
SpaceStation *station = 0;
for (Space::bodiesIter_t i = Space::bodies.begin(); i!=Space::bodies.end(); i++) {
if ((*i)->IsType(Object::SPACESTATION)) { station = (SpaceStation*)*i; break; }
}
assert(station);
player->SetPosition(vector3d(0,0,0));
player->SetFrame(station->GetFrame());
player->SetDockedWith(station, 0);
MainLoop();
} else if (choice == 2) {
/* Epsilon Eridani start point */
SBodyPath path(1,0,2);
Space::DoHyperspaceTo(&path);
// XXX there isn't a sensible way to find stations for a planet.
SpaceStation *station = 0;
for (Space::bodiesIter_t i = Space::bodies.begin(); i!=Space::bodies.end(); i++) {
if ((*i)->IsType(Object::SPACESTATION)) {
station = (SpaceStation*)*i;
if (!station->IsGroundStation()) break;
}
}
assert(station);
player->SetPosition(vector3d(0,0,0));
player->SetFrame(station->GetFrame());
//.........这里部分代码省略.........
示例5: l_space_spawn_ship_parked
/*
* Function: SpawnShipParked
*
* Create a ship and place it in one of the given <SpaceStation's> parking spots.
*
* > ship = Space.SpawnShipParked(type, station)
*
* For orbital stations the parking spots are some distance from the door, out
* of the path of ships entering and leaving the station. For group stations
* the parking spots are directly above the station, usually some distance
* away.
*
* Parameters:
*
* type - the name of the ship
*
* station - the <SpaceStation> to place the near
*
* Return:
*
* ship - a <Ship> object for the new ship, or nil if there was no space
* inside the station
* Availability:
*
* alpha 10
*
* Status:
*
* experimental
*/
static int l_space_spawn_ship_parked(lua_State *l)
{
if (!Pi::game)
luaL_error(l, "Game is not started");
LUA_DEBUG_START(l);
const char *type = luaL_checkstring(l, 1);
if (! ShipType::Get(type))
luaL_error(l, "Unknown ship type '%s'", type);
SpaceStation *station = LuaSpaceStation::CheckFromLua(2);
int slot;
if (!station->AllocateStaticSlot(slot))
return 0;
Ship *ship = new Ship(type);
assert(ship);
vector3d pos, vel;
matrix4x4d rot = matrix4x4d::Identity();
if (station->GetSystemBody()->type == SystemBody::TYPE_STARPORT_SURFACE) {
vel = vector3d(0.0);
// XXX on tiny planets eg asteroids force this to be larger so the
// are out of the docking path
pos = station->GetPosition() * 1.1;
station->GetRotMatrix(rot);
vector3d axis1, axis2;
axis1 = pos.Cross(vector3d(0.0,1.0,0.0));
axis2 = pos.Cross(axis1);
double ang = atan((140 + ship->GetLmrCollMesh()->GetBoundingRadius()) / pos.Length());
if (slot<2) ang = -ang;
vector3d axis = (slot == 0 || slot == 3) ? axis1 : axis2;
pos.ArbRotate(axis, ang);
}
else {
double dist = 100 + ship->GetLmrCollMesh()->GetBoundingRadius();
double xpos = (slot == 0 || slot == 3) ? -dist : dist;
double zpos = (slot == 0 || slot == 1) ? -dist : dist;
pos = vector3d(xpos,5000,zpos);
vel = vector3d(0.0);
rot.RotateX(M_PI/2);
}
ship->SetFrame(station->GetFrame());
ship->SetVelocity(vel);
ship->SetPosition(pos);
ship->SetRotMatrix(rot);
Pi::game->GetSpace()->AddBody(ship);
ship->AIHoldPosition();
LuaShip::PushToLua(ship);
LUA_DEBUG_END(l, 1);
return 1;
}