void Ship::SetFlightState(Ship::FlightState newState) { if (m_flightState == newState) return; if (IsHyperspaceActive() && (newState != FLYING)) ResetHyperspaceCountdown(); if (newState == FLYING) { m_testLanded = false; if (m_flightState == DOCKING || m_flightState == DOCKED) onUndock.emit(); m_dockedWith = 0; // lock thrusters for two seconds to push us out of station m_launchLockTimeout = 2.0; } m_flightState = newState; switch (m_flightState) { case FLYING: SetMoving(true); SetColliding(true); SetStatic(false); break; case DOCKING: SetMoving(false); SetColliding(false); SetStatic(false); break; // TODO: set collision index? dynamic stations... use landed for open-air? case DOCKED: SetMoving(false); SetColliding(false); SetStatic(false); break; case LANDED: SetMoving(false); SetColliding(true); SetStatic(true); break; case HYPERSPACE: SetMoving(false); SetColliding(false); SetStatic(false); break; } }
//////////////////////////////////////// // PUBLIC UTILITY FUNCTIONS //////////////////////////////////////// // Gets the current frame in the animation // and moves to the next one in order. RECT CAnimation::GetFrame() { SetTimeWaited(GetTimeWaited() + GAME->GetTimer().GetDeltaTime()); RECT tRect; tRect.left = GetCurrentFrame() * GetFrameWidth(); tRect.top = 0; tRect.right = tRect.left + GetFrameWidth(); tRect.bottom = tRect.top + GetFrameHeight(); if(GetTimeWaited() > GetTimePerFrame() && !GetStatic()) { SetTimeWaited(0.0f); SetCurrentFrame(GetCurrentFrame() + 1); if(GetCurrentFrame() > GetFrameCount()) { if(GetLooping()) ResetAnimation(); else { SetCurrentFrame(GetFrameCount()); SetStatic(true); } } } return tRect; }
void Ship::SetFlightState(Ship::FlightState newState) { if (m_flightState == newState) return; if (IsHyperspaceActive() && (newState != FLYING)) AbortHyperjump(); if (newState == FLYING) { m_testLanded = false; if (m_flightState == DOCKING || m_flightState == DOCKED) onUndock.emit(); m_dockedWith = nullptr; // lock thrusters on for amount of time needed to push us out of station static const double MASS_LOCK_REFERENCE(40000.0); // based purely on experimentation // limit the time to between 2.0 and 20.0 seconds of thrust, the player can override m_launchLockTimeout = std::min(std::max(2.0, 2.0 * (GetMass() / MASS_LOCK_REFERENCE)), 20.0); } m_flightState = newState; Properties().Set("flightState", EnumStrings::GetString("ShipFlightState", m_flightState)); switch (m_flightState) { case FLYING: SetMoving(true); SetColliding(true); SetStatic(false); break; case DOCKING: SetMoving(false); SetColliding(false); SetStatic(false); break; case UNDOCKING: SetMoving(false); SetColliding(false); SetStatic(false); break; // TODO: set collision index? dynamic stations... use landed for open-air? case DOCKED: SetMoving(false); SetColliding(false); SetStatic(false); break; case LANDED: SetMoving(false); SetColliding(true); SetStatic(true); break; case JUMPING: SetMoving(true); SetColliding(false); SetStatic(false); break; case HYPERSPACE: SetMoving(false); SetColliding(false); SetStatic(false); break; } }
CClientWeapon::CClientWeapon ( CClientManager * pManager, ElementID ID, eWeaponType type ) : ClassInit ( this ) , CClientObject ( pManager, ID, CClientPickupManager::GetWeaponModel ( type ), false ) { // Ensure m_pTarget and m_pOwner get NULLed when they are destroyed CClientEntityRefManager::AddEntityRefs ( ENTITY_REF_DEBUG ( this, "CClientWeapon" ), &m_pTarget, &m_pOwner, NULL ); m_pManager = pManager; m_pManager->GetWeaponManager ()->AddToList ( this ); m_Type = type; m_State = WEAPONSTATE_READY; m_pWeapon = NULL; m_pWeaponInfo = g_pGame->GetWeaponInfo ( m_Type ); m_bHasTargetDirection = false; m_pOwner = NULL; SetTypeName ( "weapon" ); SetStatic ( true ); Create (); #ifdef MARKER_DEBUG m_pMarker = new CClientMarker ( pManager, INVALID_ELEMENT_ID, 4 ); m_pMarker->SetColor( SColor( 0xFF00FF00 ) ); m_pMarker->SetSize ( 0.5f ); m_pMarker2 = new CClientMarker ( pManager, INVALID_ELEMENT_ID, 4 ); m_pMarker2->SetColor( SColor( 0xFFFF0000 ) ); m_pMarker2->SetSize ( 0.5f ); #endif m_sDamage = m_pWeaponInfo->GetDamagePerHit ( ); m_pWeaponStat = g_pGame->CreateWeaponStat ( type, WEAPONSKILL_STD ); ResetWeaponTarget ( ); // Setup weapon config. m_weaponConfig.bDisableWeaponModel = false; m_weaponConfig.bShootIfTargetBlocked = false; m_weaponConfig.bShootIfTargetOutOfRange = false; m_weaponConfig.flags.bShootThroughStuff = false; m_weaponConfig.flags.bIgnoreSomeObjectsForCamera = false; m_weaponConfig.flags.bSeeThroughStuff = false; m_weaponConfig.flags.bCheckDummies = true; m_weaponConfig.flags.bCheckObjects = true; m_weaponConfig.flags.bCheckPeds = true; m_weaponConfig.flags.bCheckVehicles = true; m_weaponConfig.flags.bCheckBuildings = true; m_weaponConfig.flags.bCheckCarTires = true; m_itargetWheel = MAX_WHEELS + 1; m_nAmmoInClip = m_pWeaponStat->GetMaximumClipAmmo(); m_ucCounter = 0; m_nAmmoTotal = 9999; m_iWeaponFireRate = GetWeaponFireTime ( m_pWeaponStat ); }
// ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- void TrackShoeBandBushing::AddVisualizationAssets(VisualizationType vis) { if (vis == VisualizationType::MESH && m_has_mesh) { auto trimesh = std::make_shared<geometry::ChTriangleMeshConnected>(); trimesh->LoadWavefrontMesh(vehicle::GetDataFile(m_meshFile), false, false); auto trimesh_shape = std::make_shared<ChTriangleMeshShape>(); trimesh_shape->SetMesh(trimesh); trimesh_shape->SetName(m_meshName); trimesh_shape->SetStatic(true); m_shoe->AddAsset(trimesh_shape); } else { ChTrackShoeBandBushing::AddVisualizationAssets(vis); } }
void SpaceStation::InitStation() { m_adjacentCity = 0; for(int i=0; i<NUM_STATIC_SLOTS; i++) m_staticSlot[i] = false; MTRand rand(m_sbody->seed); bool ground = m_sbody->type == SystemBody::TYPE_STARPORT_ORBITAL ? false : true; if (ground) m_type = &SpaceStationType::surfaceStationTypes[ rand.Int32(SpaceStationType::surfaceStationTypes.size()) ]; else m_type = &SpaceStationType::orbitalStationTypes[ rand.Int32(SpaceStationType::orbitalStationTypes.size()) ]; SetStatic(ground); // orbital stations are dynamic now SetModel(m_type->modelName.c_str()); if (ground) SetClipRadius(CITY_ON_PLANET_RADIUS); // overrides setmodel }
void SpaceStation::InitStation() { m_adjacentCity = 0; for(int i=0; i<NUM_STATIC_SLOTS; i++) m_staticSlot[i] = false; Random rand(m_sbody->GetSeed()); const bool ground = m_sbody->GetType() == SystemBody::TYPE_STARPORT_ORBITAL ? false : true; m_type = SpaceStationType::RandomStationType(rand, ground); if(m_shipDocking.empty()) { m_shipDocking.reserve(m_type->NumDockingPorts()); for (unsigned int i=0; i<m_type->NumDockingPorts(); i++) { m_shipDocking.push_back(shipDocking_t()); } // only (re)set these if we've not come from the ::Load method m_doorAnimationStep = m_doorAnimationState = 0.0; } assert(m_shipDocking.size() == m_type->NumDockingPorts()); // This SpaceStation's bay ports are an instance of... m_ports = m_type->Ports(); SetStatic(ground); // orbital stations are dynamic now // XXX hack. if we loaded a game then ModelBody::Load already restored the // model and we shouldn't overwrite it if (!GetModel()) SetModel(m_type->ModelName().c_str()); SceneGraph::Model *model = GetModel(); m_navLights.reset(new NavLights(model, 2.2f)); m_navLights->SetEnabled(true); if (ground) SetClipRadius(CITY_ON_PLANET_RADIUS); // overrides setmodel m_doorAnimation = model->FindAnimation("doors"); SceneGraph::ModelSkin skin; skin.SetDecal("pioneer"); if (model->SupportsPatterns()) { skin.SetRandomColors(rand); skin.Apply(model); model->SetPattern(rand.Int32(0, model->GetNumPatterns())); } else { skin.Apply(model); } }
/////////////////////////////////////////////// // CONSTRUCTOR / DECONSTRUCT / OP OVERLOADS /////////////////////////////////////////////// CAnimation::CAnimation(int nImageID,int nImageWidth,int nImageHeight, int nFrameWidth, int nFrameHeight,int nFrames,int nCurrent,float fTimePerFrame,bool bLooping,bool bStatic) { SetImageID(nImageID); SetImageWidth(nImageWidth); SetImageHeight(nImageHeight); SetFrameWidth(nFrameWidth); SetFrameHeight(nFrameHeight); // Because framecount starts at 0 SetFrameCount(nFrames - 1); SetCurrentFrame(nCurrent); SetLooping(bLooping); SetStatic(bStatic); SetTimePerFrame(fTimePerFrame); SetTimeWaited(0.0f); }
void SpaceStation::InitStation() { m_adjacentCity = 0; for(int i=0; i<NUM_STATIC_SLOTS; i++) m_staticSlot[i] = false; Random rand(m_sbody->seed); bool ground = m_sbody->type == SystemBody::TYPE_STARPORT_ORBITAL ? false : true; if (ground) m_type = &SpaceStationType::surfaceStationTypes[ rand.Int32(SpaceStationType::surfaceStationTypes.size()) ]; else m_type = &SpaceStationType::orbitalStationTypes[ rand.Int32(SpaceStationType::orbitalStationTypes.size()) ]; SetStatic(ground); // orbital stations are dynamic now // XXX hack. if we loaded a game then ModelBody::Load already restored the // model and we shouldn't overwrite it if (!GetModel()) SetModel(m_type->modelName.c_str()); if (ground) SetClipRadius(CITY_ON_PLANET_RADIUS); // overrides setmodel }
void SpaceStation::InitStation() { m_adjacentCity = 0; for(int i=0; i<NUM_STATIC_SLOTS; i++) m_staticSlot[i] = false; Random rand(m_sbody->seed); bool ground = m_sbody->type == SystemBody::TYPE_STARPORT_ORBITAL ? false : true; if (ground) { m_type = &SpaceStationType::surfaceStationTypes[ rand.Int32(SpaceStationType::surfaceStationTypes.size()) ]; } else { m_type = &SpaceStationType::orbitalStationTypes[ rand.Int32(SpaceStationType::orbitalStationTypes.size()) ]; } if(m_shipDocking.empty()) { m_shipDocking.reserve(m_type->numDockingPorts); for (unsigned int i=0; i<m_type->numDockingPorts; i++) { m_shipDocking.push_back(shipDocking_t()); } // only (re)set these if we've not come from the ::Load method m_doorAnimationStep = m_doorAnimationState = 0.0; } assert(m_shipDocking.size() == m_type->numDockingPorts); // This SpaceStation's bay groups is an instance of... mBayGroups = m_type->bayGroups; SetStatic(ground); // orbital stations are dynamic now // XXX hack. if we loaded a game then ModelBody::Load already restored the // model and we shouldn't overwrite it if (!GetModel()) SetModel(m_type->modelName.c_str()); m_navLights.Reset(new NavLights(GetModel(), 2.2f)); m_navLights->SetEnabled(true); if (ground) SetClipRadius(CITY_ON_PLANET_RADIUS); // overrides setmodel m_doorAnimation = GetModel()->FindAnimation("doors"); }
//////////////////////////////////////// // PRIVATE UTILITY FUNCTIONS //////////////////////////////////////// void CAnimation::ResetAnimation() { SetCurrentFrame(0); SetTimeWaited(0.0f); SetStatic(false); }
void CMyDialog::OnButton() { SetStatic(_T("Button Pressed")); TRACE("Button Pressed\n"); }
void CMyDialog::OnCheck1() { SetStatic(_T("Check Box 1")); TRACE("Check Box 1\n"); }
void quadsquare::AddHeightMap(const quadcornerdata& cd, const HeightMapInfo& hm) // Sets the height of all samples within the specified rectangular // region using the given array of floats. Extends the tree to the // level of detail defined by (1 << hm.Scale) as necessary. { RowSize = hm.RowWidth; NumRows = hm.ZSize; if ( cd.Parent == NULL ) { if ( VertexArrayIndices != NULL ) { delete VertexArrayIndices; } /* Maximum number of triangles is 2 * RowSize * NumRows This uses up a lot of space but it is a *big* performance gain. */ VertexArrayIndices = new GLuint[6 * RowSize * NumRows]; } // If block is outside rectangle, then don't bother. int BlockSize = 2 << cd.Level; if (cd.xorg > hm.XOrigin + ((hm.XSize + 2) << hm.Scale) || cd.xorg + BlockSize < hm.XOrigin - (1 << hm.Scale) || cd.zorg > hm.ZOrigin + ((hm.ZSize + 2) << hm.Scale) || cd.zorg + BlockSize < hm.ZOrigin - (1 << hm.Scale)) { // This square does not touch the given height array area; no need to modify this square or descendants. return; } if (cd.Parent && cd.Parent->Square) { cd.Parent->Square->EnableChild(cd.ChildIndex, *cd.Parent); // causes parent edge verts to be enabled, possibly causing neighbor blocks to be created. } int i; int half = 1 << cd.Level; // Create and update child nodes. for (i = 0; i < 4; i++) { quadcornerdata q; SetupCornerData(&q, cd, i); if (Child[i] == NULL && cd.Level > hm.Scale) { // Create child node w/ current (unmodified) values for corner verts. Child[i] = new quadsquare(&q); } // Recurse. if (Child[i]) { Child[i]->AddHeightMap(q, hm); } } // Deviate vertex heights based on data sampled from heightmap. float s[5]; s[0] = hm.Sample(cd.xorg + half, cd.zorg + half); s[1] = hm.Sample(cd.xorg + half*2, cd.zorg + half); s[2] = hm.Sample(cd.xorg + half, cd.zorg); s[3] = hm.Sample(cd.xorg, cd.zorg + half); s[4] = hm.Sample(cd.xorg + half, cd.zorg + half*2); // Modify the vertex heights if necessary, and set the dirty // flag if any modifications occur, so that we know we need to // recompute error data later. for (i = 0; i < 5; i++) { if (s[i] != 0) { Dirty = true; Vertex[i].Y += s[i]; } } if (!Dirty) { // Check to see if any child nodes are dirty, and set the dirty flag if so. for (i = 0; i < 4; i++) { if (Child[i] && Child[i]->Dirty) { Dirty = true; break; } } } if (Dirty) SetStatic(cd); }
void CMyDialog::OnRadio3() { SetStatic(_T("Radio 3")); TRACE("Radio 3\n"); }
void CMyDialog::OnRadio2() { SetStatic(_T("Radio 2")); TRACE("Radio 2\n"); }
void CMyDialog::OnRadio1() { SetStatic(_T("Radio 1")); TRACE("Radio 1\n"); }
void CMyDialog::OnCheck3() { SetStatic(_T("Check Box 3")); TRACE("Check Box 3\n"); }
void CMyDialog::OnCheck2() { SetStatic(_T("Check Box 2")); TRACE("Check Box 2\n"); }