当前位置: 首页>>代码示例>>C++>>正文


C++ SpaceStation::GetOrient方法代码示例

本文整理汇总了C++中SpaceStation::GetOrient方法的典型用法代码示例。如果您正苦于以下问题:C++ SpaceStation::GetOrient方法的具体用法?C++ SpaceStation::GetOrient怎么用?C++ SpaceStation::GetOrient使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SpaceStation的用法示例。


在下文中一共展示了SpaceStation::GetOrient方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:Luomu,项目名称:pioneer,代码行数:78,代码来源:LuaSpace.cpp


注:本文中的SpaceStation::GetOrient方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。