void PipeDevice::ParseCommand(const std::string& command) { std::vector<std::string> tokens; SplitString(command, ' ', tokens); if (tokens.size() < 2 || tokens.size() > 4) return; if (tokens[0] == "PRESS" || tokens[0] == "RELEASE") { auto search = m_buttons.find(tokens[1]); if (search != m_buttons.end()) search->second->SetState(tokens[0] == "PRESS" ? 1.0 : 0.0); } else if (tokens[0] == "SET") { if (tokens.size() == 3) { double value = strtod(tokens[2].c_str(), nullptr); SetAxis(tokens[1], (value / 2.0) + 0.5); } else { double x = strtod(tokens[2].c_str(), nullptr); double y = strtod(tokens[3].c_str(), nullptr); SetAxis(tokens[1] + " X", x); SetAxis(tokens[1] + " Y", y); } } }
void hhProjectileStickyCrawlerGrenade::BindToCollisionObject( const trace_t* collision ) { if( !collision || collision->fraction > 1.0f ) { return; } //HUMANHEAD PCF rww 05/18/06 - wait until we receive bind info from the server if (gameLocal.isClient) { return; } //HUMANHEAD END idEntity* pEntity = gameLocal.entities[collision->c.entityNum]; HH_ASSERT( pEntity ); // HUMANHEAD PCF pdm 05-20-06: Check for some degenerate cases to combat the server hangs happening if (pEntity == this || this->IsBound()) { assert(0); // Report any of these return; } // HUMANHEAD END jointHandle_t jointHandle = CLIPMODEL_ID_TO_JOINT_HANDLE( collision->c.id ); if ( jointHandle != INVALID_JOINT ) { SetOrigin( collision->endpos ); SetAxis( DetermineCollisionAxis( (-collision->c.normal).ToMat3()) ); BindToJoint( pEntity, jointHandle, true ); } else { SetOrigin( collision->endpos ); SetAxis( DetermineCollisionAxis( (-collision->c.normal).ToMat3()) ); Bind( pEntity, true ); } }
/* ================ rvClientCrawlEffect::Think ================ */ void rvClientCrawlEffect::Think ( void ) { // If there is no crawl entity or no crawl joints then just free ourself if ( !crawlEnt || !crawlJoints.Num() ) { PostEventMS ( &EV_Remove, 0 ); return; } // Move to the next joint if its time if ( gameLocal.time > nextCrawl ) { jointStart = (jointStart + crawlDir + crawlJoints.Num() ) % crawlJoints.Num(); jointEnd = (jointStart + crawlDir + crawlJoints.Num() ) % crawlJoints.Num(); nextCrawl = gameLocal.time + crawlTime; } idVec3 offsetStart; idVec3 offsetEnd; idVec3 dir; idMat3 axis; // Get the start origin crawlEnt->GetJointWorldTransform ( crawlJoints[jointStart], gameLocal.time, offsetStart, axis ); SetOrigin ( offsetStart ); // Get the end origin crawlEnt->GetJointWorldTransform ( crawlJoints[jointEnd], gameLocal.time, offsetEnd, axis ); SetEndOrigin ( offsetEnd ); // Update the axis to point at the bone dir = offsetEnd - offsetStart; dir.Normalize(); SetAxis ( dir.ToMat3( ) ); rvClientEffect::Think ( ); }
void CPrefView::OnInitialUpdate() { CFormView::OnInitialUpdate(); // AfxGetApp()->m_pMainWnd->GetMenu()->EnableMenuItem(ID_FILE_MRU_FILE1,MF_GRAYED); // GetMenu()->EnableMenuItem(ID_FILE_MRU_FILE2,MF_GRAYED); // AfxGetApp()->m_pMainWnd->GetMenu()->CheckMenuItem(ID_MENUITEM_SHOWGRAD,MF_UNCHECKED); //ReSize(); if (m_pM->m_is_grad) AfxGetApp()->m_pMainWnd->GetMenu()->CheckMenuItem(ID_MENUITEM_SHOWGRAD,MF_CHECKED); else AfxGetApp()->m_pMainWnd->GetMenu()->CheckMenuItem(ID_MENUITEM_SHOWGRAD,MF_UNCHECKED); fSize=1; for (int i=3; i>=0; i--) m_OtherC.DeleteColumn(i); LV_COLUMN lvc; lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.fmt = LVCFMT_LEFT; lvc.pszText = (LPTSTR) "Наименование"; lvc.cx = m_OtherC.GetStringWidth(lvc.pszText) + 15; lvc.iSubItem = 0; m_OtherC.InsertColumn(0,&lvc); lvc.pszText = (LPTSTR) "Значение "; lvc.cx = m_OtherC.GetStringWidth(lvc.pszText) + 15; lvc.iSubItem = 1; m_OtherC.InsertColumn(1,&lvc); LoadFont(); SetDlgItemText(IDC_EDIT_GNAME,m_pG->GetName()); m_Slider.EnableWindow(FALSE); SetDlgItemText(IDC_EDIT_GOD,""); SetAxis(); GetDlgItem(IDC_MSFLEXGRID1)->SetFocus(); }
void xTEDSOrientationItem::SetOrientation(const orientation* NewOrientation) { if (NewOrientation == NULL) return; SetAxis(NewOrientation->axis_value); SetAngle(NewOrientation->angle_value); SetUnits(NewOrientation->units_value); }
/* ================ sdClientProjectile::Explode ================ */ void sdClientProjectile::Explode( const trace_t *collision, const char *sndExplode ) { const char *fxname; idVec3 normal, endpos; int removeTime; if ( spawnArgs.GetVector( "detonation_axis", "", normal ) ) { SetAxis( normal.ToMat3() ); } else { normal = collision ? collision->c.normal : idVec3( 0, 0, 1 ); } endpos = ( collision ) ? collision->endpos : GetOrigin(); removeTime = PROJECTILE_REMOVE_TIME; // play sound // StopSound( SND_CHANNEL_ANY ); StartSound( sndExplode, SND_CHANNEL_BODY ); StartSound( "snd_explode_med", SND_CHANNEL_BODY2 ); StartSound( "snd_explode_far", SND_CHANNEL_BODY3 ); Hide(); FreeLightDef(); SetOrigin( GetOrigin() + 8.0f * normal ); // change the model fxname = NULL; if ( g_testParticle.GetInteger() == TEST_PARTICLE_IMPACT ) { fxname = g_testParticleName.GetString(); } else { fxname = spawnArgs.GetString( "model_detonate" ); } ClientEntEvent_Remove( removeTime ); }
StretchDeformer::StretchDeformer(TimeValue t, ModContext &mc, float stretch, float amplify, int naxis, float from, float to, int doRegion, Matrix3& modmat, Matrix3& modinv) { Matrix3 mat; Interval valid; // if (from==to) doRegion = FALSE; this->doRegion = doRegion; this->from = from; this->to = to; time = t; tm = modmat; invtm = modinv; mat.IdentityMatrix(); switch ( naxis ) { case 0: mat.RotateY( -HALFPI ); break; //X case 1: mat.RotateX( HALFPI ); break; //Y case 2: break; //Z } SetAxis( mat ); assert (mc.box); bbox = *mc.box; CalcBulge(naxis, stretch, amplify); }
//-------------------------------- // hhProxDoorRotator::ReadFromSnapshot //-------------------------------- void hhProxDoorRotator::ReadFromSnapshot( const idBitMsgDelta &msg ) { // hhProxDoorSection::ReadFromSnapshot(msg); #ifdef _SYNC_PROXDOORS ReadBindFromSnapshot(msg); if (GetPhysics()->IsType(idPhysics_Static::Type)) { idPhysics_Static *phys = static_cast<idPhysics_Static *>(GetPhysics()); staticPState_t *state = phys->GetPState(); state->origin.x = msg.ReadFloat(); state->origin.y = msg.ReadFloat(); state->origin.z = msg.ReadFloat(); state->localOrigin.x = msg.ReadFloat(); state->localOrigin.y = msg.ReadFloat(); state->localOrigin.z = msg.ReadFloat(); idCQuat q; q.x = msg.ReadFloat(); q.y = msg.ReadFloat(); q.z = msg.ReadFloat(); state->localAxis = q.ToMat3(); } #else proxyParent.SetSpawnId(msg.ReadBits(32)); if (proxyParent.IsValid() && proxyParent->IsType(hhProxDoor::Type)) { hhProxDoor *parentPtr = static_cast<hhProxDoor *>(proxyParent.GetEntity()); if (parentPtr->hasNetData) { if (!hasNetData) { idVec3 parentOrigin; idMat3 parentAxis; parentOrigin = proxyParent->GetOrigin();//proxyParent->spawnArgs.GetVector("origin", "0 0 0", parentOrigin); parentAxis = proxyParent->GetAxis();//proxyParent->spawnArgs.GetMatrix("rotation", "1 0 0 0 1 0 0 0 1", parentAxis); SetOrigin(parentOrigin); SetAxis(parentAxis); spawnArgs.SetVector("origin", parentOrigin); spawnArgs.SetMatrix("rotation", parentAxis); hasNetData = true; } } else { hasNetData = false; } } ReadBindFromSnapshot(msg); bindParent.SetSpawnId(msg.ReadBits(32)); #endif //not needed without prediction /* int spawnId = msg.ReadBits(32); if (!spawnId) { bindParent = NULL; } else { bindParent.SetSpawnId(spawnId); } */ }
NS_IMETHODIMP HTMLTableCellElement::SetAxis(const nsAString& aAxis) { ErrorResult rv; SetAxis(aAxis, rv); return rv.ErrorCode(); }
void hhCenturion::Event_ReachedTunnel() { if( armchop_Target.IsValid() ) { idAngles faceAngles = armchop_Target->GetAxis()[0].ToAngles(); ideal_yaw = faceAngles.yaw; current_yaw = faceAngles.yaw; SetAxis( armchop_Target->GetAxis() ); } }
GraphCanvas::GraphCanvas(const Point2i& size, const std::string& xname, const std::string& yname, uint thick) : Widget(size) , thickness(thick) { SetAxis(xname, yname); }
/* ================ sdClientScriptEntity::Event_SetAngles ================ */ void sdClientScriptEntity::Event_SetAngles( const idAngles& ang ) { idMat3 axis = ang.ToMat3(); SetAxis( axis ); if ( GetPhysics() != NULL ) { GetPhysics()->SetAxis( axis ); } }
GraphCanvas::GraphCanvas(const Point2i& size, const std::string& xname, const std::string& yname, std::vector<Result>& res, uint thick) : Widget(size) , results(res) , thickness(thick) { SetAxis(xname, yname); }
BendDeformer::BendDeformer( TimeValue t, ModContext &mc, float angle, float dir, int naxis, float from, float to, int doRegion, Matrix3& modmat, Matrix3& modinv) { this->doRegion = doRegion; this->from = from; this->to = to; Matrix3 mat; Interval valid; time = t; tm = modmat; invtm = modinv; mat.IdentityMatrix(); switch (naxis) { case 0: mat.RotateY( -HALFPI ); break; //X case 1: mat.RotateX( HALFPI ); break; //Y case 2: break; //Z } mat.RotateZ(DegToRad(dir)); SetAxis(mat); assert (mc.box); bbox = *mc.box; CalcR(naxis,DegToRad(angle)); // Turn this off for a sec. this->doRegion = FALSE; float len = to-from; float rat1, rat2; if (len==0.0f) { rat1 = rat2 = 1.0f; } else { rat1 = to/len; rat2 = from/len; } Point3 pt; tmAbove.IdentityMatrix(); tmAbove.Translate(Point3(0.0f,0.0f,-to)); tmAbove.RotateY(DegToRad(angle * rat1)); tmAbove.Translate(Point3(0.0f,0.0f,to)); pt = Point3(0.0f,0.0f,to); tmAbove.Translate((Map(0,pt*invtm)*tm)-pt); tmBelow.IdentityMatrix(); tmBelow.Translate(Point3(0.0f,0.0f,-from)); tmBelow.RotateY(DegToRad(angle * rat2)); tmBelow.Translate(Point3(0.0f,0.0f,from)); pt = Point3(0.0f,0.0f,from); tmBelow.Translate((Map(0,pt*invtm)*tm)-pt); this->doRegion = doRegion; }
void TBTabContainer::SetAlignment(TB_ALIGN align) { bool horizontal = (align == TB_ALIGN_TOP || align == TB_ALIGN_BOTTOM); bool reverse = (align == TB_ALIGN_TOP || align == TB_ALIGN_LEFT); SetAxis(horizontal ? AXIS_Y : AXIS_X); m_root_layout.SetLayoutOrder(reverse ? LAYOUT_ORDER_TOP_TO_BOTTOM : LAYOUT_ORDER_BOTTOM_TO_TOP); m_tab_layout.SetLayoutPosition(reverse ? LAYOUT_POSITION_RIGHT_BOTTOM : LAYOUT_POSITION_LEFT_TOP); m_align = align; }
//-------------------------------- // hhProxDoorRotMaster::ReadFromSnapshot //-------------------------------- void hhProxDoorRotMaster::ReadFromSnapshot( const idBitMsgDelta &msg ) { //hhProxDoorSection::ReadFromSnapshot(msg); #ifdef _SYNC_PROXDOORS rotVector.x = msg.ReadFloat(); rotVector.y = msg.ReadFloat(); rotVector.z = msg.ReadFloat(); rotAngle = msg.ReadFloat(); idCQuat q; q.x = msg.ReadFloat(); q.y = msg.ReadFloat(); q.z = msg.ReadFloat(); baseAxis = q.ToMat3(); if (GetPhysics()->IsType(idPhysics_Static::Type)) { idPhysics_Static *phys = static_cast<idPhysics_Static *>(GetPhysics()); staticPState_t *state = phys->GetPState(); state->origin.x = msg.ReadFloat(); state->origin.y = msg.ReadFloat(); state->origin.z = msg.ReadFloat(); } float prox = msg.ReadFloat(); SetProximity(prox); #else ReadBindFromSnapshot(msg); proxyParent.SetSpawnId(msg.ReadBits(32)); if (proxyParent.IsValid() && proxyParent->IsType(hhProxDoorRotator::Type)) { hhProxDoorRotator *parentPtr = static_cast<hhProxDoorRotator *>(proxyParent.GetEntity()); if (parentPtr->hasNetData) { if (!hasNetData) { idVec3 sectionOffset, rot_vector; idVec3 parentOrigin; idMat3 parentAxis; proxyParent->spawnArgs.GetVector("origin", "0 0 0", parentOrigin); proxyParent->spawnArgs.GetMatrix("rotation", "1 0 0 0 1 0 0 0 1", parentAxis); proxyParent->spawnArgs.GetVector("section_offset", "0 0 0", sectionOffset); proxyParent->spawnArgs.GetVector("rot_vector", "0 0 0", rot_vector); proxyParent->spawnArgs.GetFloat("rot_angle", "0.0", rotAngle); SetOrigin(parentOrigin+(sectionOffset*parentAxis)); SetAxis(parentAxis); baseAxis = GetAxis(); rotVector = GetAxis() * rot_vector; hasNetData = true; } } else { parentPtr->hasNetData = false; } } #endif }
//-------------------------------- // hhProxDoorRotMaster::SetProximity //-------------------------------- void hhProxDoorRotMaster::SetProximity( float prox ) { idRotation desRotation( vec3_origin, rotVector, prox*rotAngle ); SetAxis( baseAxis * desRotation.ToMat3() ); //rww - proxy door pieces keep getting stuck, so make sure this bastard keeps running physics if (!IsActive(TH_PHYSICS)) { BecomeActive(TH_PHYSICS); } proximity = prox; }
TBSlider::TBSlider() : m_axis(AXIS_Y) ///< Make SetAxis below always succeed and set the skin , m_value(0) , m_min(0) , m_max(1) , m_to_pixel_factor(0) { SetIsFocusable(true); SetAxis(AXIS_X); AddChild(&m_handle); }
TBScrollBar::TBScrollBar() : m_axis(AXIS_Y) ///< Make SetAxis below always succeed and set the skin , m_value(0) , m_min(0) , m_max(1) , m_visible(1) , m_to_pixel_factor(0) { SetAxis(AXIS_X); AddChild(&m_handle); }
//-------------------------------- // hhProxDoorTranslator::ReadFromSnapshot //-------------------------------- void hhProxDoorTranslator::ReadFromSnapshot( const idBitMsgDelta &msg ) { //hhProxDoorSection::ReadFromSnapshot(msg); #ifdef _SYNC_PROXDOORS baseOrigin.x = msg.ReadFloat(); baseOrigin.y = msg.ReadFloat(); baseOrigin.z = msg.ReadFloat(); targetOrigin.x = msg.ReadFloat(); targetOrigin.y = msg.ReadFloat(); targetOrigin.z = msg.ReadFloat(); if (GetPhysics()->IsType(idPhysics_Static::Type)) { idPhysics_Static *phys = static_cast<idPhysics_Static *>(GetPhysics()); staticPState_t *state = phys->GetPState(); idCQuat q; q.x = msg.ReadFloat(); q.y = msg.ReadFloat(); q.z = msg.ReadFloat(); state->axis = q.ToMat3(); } float prox = msg.ReadFloat(); SetProximity(prox); #else ReadBindFromSnapshot(msg); proxyParent.SetSpawnId(msg.ReadBits(32)); if (proxyParent.IsValid() && proxyParent->IsType(hhProxDoor::Type)) { hhProxDoor *parentPtr = static_cast<hhProxDoor *>(proxyParent.GetEntity()); if (parentPtr->hasNetData) { if (!hasNetData) { idVec3 parentOrigin; idMat3 parentAxis; parentOrigin = proxyParent->GetOrigin();//proxyParent->spawnArgs.GetVector("origin", "0 0 0", parentOrigin); parentAxis = proxyParent->GetAxis();//proxyParent->spawnArgs.GetMatrix("rotation", "1 0 0 0 1 0 0 0 1", parentAxis); SetOrigin(parentOrigin); SetAxis(parentAxis); baseOrigin = GetOrigin(); spawnArgs.SetVector("origin", parentOrigin); spawnArgs.SetMatrix("rotation", parentAxis); hasNetData = true; } } else { hasNetData = false; } } #endif }
int hhProjectileFreezer::ProcessCollision( const trace_t* collision, const idVec3& velocity ) { idEntity* entHit = gameLocal.entities[ collision->c.entityNum ]; SetOrigin( collision->endpos ); SetAxis( collision->endAxis ); if (entHit) { //rww - may be null on client. DamageEntityHit( collision, velocity, entHit ); } fl.takedamage = false; physicsObj.SetContents( 0 ); physicsObj.PutToRest(); surfTypes_t matterType = gameLocal.GetMatterType( entHit, collision->c.material, "hhProjectile::ProcessCollision" ); return PlayImpactSound( gameLocal.FindEntityDefDict(spawnArgs.GetString("def_damage")), collision->endpos, matterType ); }
bool EddyPulse::Prepare (PrepareMode mode) { //if (m_prepared ) return true; m_axis = AXIS_VOID; SetTPOIs (); //parent of generating pulse is an AtomicSequence m_parent = ( (AtomicSequence*) (m_gen_pulse->GetParent() ) ); if (m_parent == NULL) return false; m_parent->SetEddyCurrents(true); if (m_gen_pulse == NULL ) return false; if (m_gen_pulse->HasDOMattribute("EddyConvLength")) m_length = *((int*) m_gen_pulse->GetAttribute("EddyConvLength")->GetAddress()); SetAxis ( m_gen_pulse->GetAxis() ); SetDuration ( m_gen_pulse->GetDuration() ); SetName ( "EC_"+m_gen_pulse->GetName() ); m_initial_delay = m_gen_pulse->GetInitialDelay() ; if ( !Insert(mode) ) return false; //should never happen //prepare for GetValue of decaying eddies outside the atom ConvKernel() ; m_area = GetAreaNumeric(1000); //use NLGs from the generating pulse //cout << GetName() << " : " << m_gen_pulse->HasDOMattribute("NLG_field") << " : " << HasDOMattribute("NLG_field") << endl; if ( mode !=PREP_UPDATE) { if ( m_gen_pulse->HasDOMattribute("NLG_field") && !HasDOMattribute("NLG_field") ) AddDOMattribute("NLG_field",m_gen_pulse->GetDOMattribute("NLG_field")); //cout << " !! " << GetDOMattribute("NLG_field") << endl; // -> nonsense? Observe ( GetAttribute("Area"), m_gen_pulse->GetName(),"Area", mode == PREP_VERBOSE); } //prepare call of base class m_prepared = (GradPulse::Prepare(mode) && m_prepared); return m_prepared; }
void hhProjectileCocoon::Event_TrackTarget() { idVec3 newVelocity; if( !enemy.IsValid() ) { physicsObj.SetLinearVelocity( GetAxis()[ 0 ] * velocity[ 0 ] + GetAxis()[ 1 ] * velocity[ 1 ] + GetAxis()[ 2 ] * velocity[ 2 ] ); physicsObj.SetAngularVelocity( angularVelocity.ToAngularVelocity() * GetAxis() ); return; } idVec3 enemyDir = DetermineEnemyDir( enemy.GetEntity() ); idVec3 currentDir = GetAxis()[0]; idVec3 newDir = currentDir*(1-turnFactor) + enemyDir*turnFactor; newDir.Normalize(); if ( driver.IsValid() ) { driver->SetAxis(newDir.ToMat3()); } else { SetAxis(newDir.ToMat3()); } newVelocity = GetAxis()[ 0 ] * velocity[ 0 ] + GetAxis()[ 1 ] * velocity[ 1 ] + GetAxis()[ 2 ] * velocity[ 2 ]; newVelocity *= spawnArgs.GetFloat( "bounce", "1.0" ); physicsObj.SetLinearVelocity( newVelocity ); physicsObj.SetAngularVelocity( angularVelocity.ToAngularVelocity() * GetAxis() ); }
TwistDeformer::TwistDeformer( TimeValue t, ModContext &mc, float angle, int naxis, float bias, float from, float to, int doRegion, Matrix3& modmat, Matrix3& modinv) { this->doRegion = doRegion; this->from = from; this->to = to; if (bias!=0.0f) { this->bias = 1.0f-(bias+100.0f)/200.0f; if (this->bias < 0.00001f) this->bias = 0.00001f; if (this->bias > 0.99999f) this->bias = 0.99999f; this->bias = float(log(this->bias)/log(0.5)); doBias = TRUE; } else { this->bias = 1.0f; doBias = FALSE; } Matrix3 mat; Interval valid; time = t; tm = modmat; invtm = modinv; mat.IdentityMatrix(); switch ( naxis ) { case 0: mat.RotateY( -HALFPI ); break; //X case 1: mat.RotateX( HALFPI ); break; //Y case 2: break; //Z } SetAxis( mat ); assert (mc.box); bbox = *mc.box; CalcHeight(naxis,DegToRad(angle)); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // root -l computeDrellYanPtllWeight.C+ // root -l -b -q computeDrellYanPtllWeight.C+ // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void computeDrellYanPtllWeight(TString fname = "h_pt2l_mm") { gInterpreter->ExecuteMacro("PaperStyle.C"); TFile* file = TFile::Open("figures/Control/01_DY/" + fname + ".root"); TH1D* ratio = (TH1D*)file->Get("ratio"); // Draw the ratio //---------------------------------------------------------------------------- TCanvas* c1 = new TCanvas("c1", "c1"); ratio->SetMinimum(0.85); ratio->SetMaximum(1.20); ratio->Draw("ep"); TString ytitle = Form("data / MC ratio / %.0f GeV", ratio->GetBinWidth(0)); SetAxis(ratio, ratio->GetXaxis()->GetTitle(), ytitle, 1.7, 1.8); // Draw the old function //---------------------------------------------------------------------------- TF1* fOld = new TF1("fOld", "[3]*(0.95 - [0]*TMath::Erf((x-[1])/[2]))", 0, 90); fOld->SetLineColor (kGreen+2); fOld->SetMarkerColor(kGreen+2); // https://github.com/latinos/PlotsConfigurations/blob/master/Configurations/ggH/nuisances_iteos.py#L969-L977 fOld->SetParameter(0, 0.1); fOld->SetParameter(1, 14.0); fOld->SetParameter(2, 8.8); fOld->SetParameter(3, 1.08683); fOld->Draw("same"); // Draw the old function error band //------------------------------------------------------------------------------ if (errorband) { TF1* fOld_down = (TF1*)fOld->Clone("fOld_down"); TF1* fOld_up = (TF1*)fOld->Clone("fOld_up"); fOld_down->SetParameter(0, 13.6); fOld_down->SetParameter(1, 8.6); fOld_up->SetParameter(0, 14.4); fOld_up->SetParameter(1, 9.0); fOld_down->Draw("same"); fOld_up ->Draw("same"); } // Update the fit parameters of the old function // // 1 p0 6.85257e-02 2.99341e-01 1.42129e-05 4.16760e-04 // 2 p1 1.24518e+01 4.76906e+01 3.55312e-03 6.41625e-07 // 3 p2 5.40627e+00 7.83907e+01 6.49546e-03 -1.96376e-06 // 4 p3 1.05396e+00 3.48880e-01 1.58779e-05 -3.97115e-05 // //---------------------------------------------------------------------------- TF1* fNew = new TF1("fNew", "[3]*(0.95 - [0]*TMath::Erf((x-[1])/[2]))", 0, 90); fNew->SetLineColor (kRed+1); fNew->SetMarkerColor(kRed+1); fNew->SetParameter(0, 0.1); fNew->SetParameter(1, 10); fNew->SetParameter(2, 1); fNew->SetParameter(3, 1); ratio->Fit(fNew, "mlr0"); fNew->Draw("same"); // Draw the updated error band //------------------------------------------------------------------------------ if (errorband) { TF1* fNew_down = (TF1*)fNew->Clone("fNew_down"); TF1* fNew_up = (TF1*)fNew->Clone("fNew_up"); fNew_down->SetParameter(0, 0.97 * fNew->GetParameter(0)); fNew_down->SetParameter(1, 0.97 * fNew->GetParameter(1)); fNew_up->SetParameter(0, 1.03 * fNew->GetParameter(0)); fNew_up->SetParameter(1, 1.03 * fNew->GetParameter(1)); fNew_down->Draw("same"); fNew_up ->Draw("same"); } // Fit Lorenzo's function // // 1 p0 1.17864e-01 7.44869e-01 1.03478e-05 1.79528e-03 // 2 p1 1.34231e+01 6.10789e+01 2.78074e-03 6.38697e-06 // 3 p2 9.76801e+00 1.03947e+02 5.51661e-03 -2.28998e-06 // 4 p3 1.01367e+00 6.56154e-01 1.29644e-05 -1.36428e-04 // 5 p4 2.50141e-03 2.62347e-02 1.53669e-07 -1.11290e-01 // 6 p5 1.10637e-05 1.42769e-04 1.32442e-09 1.17953e+01 // //---------------------------------------------------------------------------- TF1* fLo = new TF1("fLo", "([3] + [4]*x - [5]*x*x) * (0.95 - [0]*TMath::Erf((x-[1])/[2]))", 0, 150); fLo->SetLineColor (kBlue); fLo->SetMarkerColor(kBlue); fLo->SetParameter(0, 0.131835); fLo->SetParameter(1, 14.1972); fLo->SetParameter(2, 10.1525); fLo->SetParameter(3, 0.876979); fLo->SetParameter(4, 4.11598e-03); fLo->SetParameter(5, 2.35520e-05); ratio->Fit(fLo, "mlr0"); // Get the point where the first derivative is closest to zero // // fLo = 0.9608 and d(fLo)/d(ptll) = -0.000110 for ptll = 119 GeV // //---------------------------------------------------------------------------- float smallest_derivative_value = 999; float smallest_derivative_x = 999; for (int x=90; x<120; x++) { if (fLo->Derivative(x) < smallest_derivative_value) { smallest_derivative_value = fLo->Derivative(x); smallest_derivative_x = x; } } printf("\n fLo = %.4f and d(fLo)/d(ptll) = %f for ptll = %.0f GeV\n\n", fLo->Eval(smallest_derivative_x), fLo->Derivative(smallest_derivative_x), smallest_derivative_x); // Draw Lorenzo's function in two ranges //---------------------------------------------------------------------------- fLo->SetRange(0, smallest_derivative_x); fLo->Draw("same"); TF1* fHi = new TF1("fHi", "[0]", smallest_derivative_x, 150); fHi->SetLineColor (kBlue); fHi->SetMarkerColor(kBlue); fHi->SetParameter(0, fLo->Eval(smallest_derivative_x)); fHi->Draw("same"); // Legend //---------------------------------------------------------------------------- DrawLegend(0.69, 0.83, (TObject*)fOld, " old fit"); DrawLegend(0.69, 0.77, (TObject*)fNew, " new fit"); DrawLegend(0.69, 0.71, (TObject*)fLo, " Lorenzo's fit"); // Save //---------------------------------------------------------------------------- ratio->Draw("ep,same"); c1->SaveAs(fname + "_ratio_fit.png"); }
void cBillboard::SetType(eBillboardType aType) { mType = aType; SetAxis(mvAxis); }
/* ================ sdClientScriptEntity::Event_SetWorldAxis ================ */ void sdClientScriptEntity::Event_SetWorldAxis( const idVec3& fwd, const idVec3& right, const idVec3& up ) { idMat3 axis( fwd, right, up ); SetAxis( axis ); }
//------------------------------------------------------------------------------ // DrawHistogram //------------------------------------------------------------------------------ void DrawHistogram(TString hname, TString xtitle, Int_t ngroup = -1, Int_t precision = 1, TString units = "NULL", Double_t xmin = -999, Double_t xmax = 999, Bool_t moveOverflow = true) { //TCanvas* canvas = new TCanvas(hname, hname, 550, 720); TCanvas* canvas = new TCanvas(hname, hname, 800, 800); TPad* pad1 = new TPad("pad1", "pad1", 0, 0.3, 1, 1.0); TPad* pad2 = new TPad("pad2", "pad2", 0, 0.0, 1, 0.3); pad1->SetTopMargin (0.08); pad1->SetBottomMargin(0.02); pad1->Draw(); pad2->SetTopMargin (0.08); pad2->SetBottomMargin(0.35); pad2->Draw(); //---------------------------------------------------------------------------- // pad1 //---------------------------------------------------------------------------- pad1->cd(); pad1->SetLogy(_setLogy); THStack* hstack = new THStack(hname, hname); TH1F* hist[nProcesses]; //Save histograms to root file TFile* outfile; //TString fname = Form("files/%s_%djet.root", hname.Data(),_njet); TString fname = "files/0jet_"+hname+".root"; if(_njet==1) fname = "files/1jet_"+hname+".root"; outfile = new TFile(fname, "create"); TH1F* data; TH1F* top; TH1F* tW; TH1F* WW; TH1F* WZ; TH1F* ZZ; TH1F* Wg; TH1F* WgSMu; TH1F* WgSEl; TH1F* Wjets; TH1F* Zjets; TH1F* DYtau; TH1F* Zgamma; TH1F* ggH; for (UInt_t ip=0; ip<nProcesses; ip++) { hist[ip] = (TH1F*)input[ip]->Get(hname); hist[ip]->SetName(hname + process[ip]); hist[ip]->SetTitle(""); if(ip == iData) data = (TH1F*)hist[iData]->Clone("Data"); //data -> Sumw2(); if(ip == itt) top = (TH1F*)hist[itt]->Clone("top"); //top -> Sumw2(); if(ip == itW) tW = (TH1F*)hist[itW]->Clone("tW"); //tW -> Sumw2(); if(ip == iWW) WW = (TH1F*)hist[iWW]->Clone("WW"); //WW -> Sumw2(); if(ip == iWZ) WZ = (TH1F*)hist[iWZ]->Clone("WZ"); //VV -> Sumw2(); if(ip == iZZ) ZZ = (TH1F*)hist[iZZ]->Clone("ZZ"); //ZZ -> Sumw2(); if(ip == iWg) Wg = (TH1F*)hist[iWg]->Clone("Wg"); //Wg -> Sumw2(); if(ip == iWgSMu){ WgSMu = (TH1F*)hist[iWgSMu]->Clone("WgSMu"); //WgSMu -> Sumw2(); hist[iWgSMu]->Scale(1.5); } if(ip == iWgSEl){ WgSEl = (TH1F*)hist[iWgSEl]->Clone("WgSEl"); //WgSel -> Sumw2(); hist[iWgSEl]->Scale(1.5); //WgSel -> Sumw2(); } if(ip == iWj) Wjets = (TH1F*)hist[iWj]->Clone("W+jets"); //Wjets -> Sumw2(); if(ip == iDY) Zjets = (TH1F*)hist[iDY]->Clone("Z+jets"); //Zjets -> Sumw2(); if(ip == iDYtau) DYtau = (TH1F*)hist[iDYtau]->Clone("DYtau"); //DYtau -> Sumw2(); if(ip == iZgamma) Zgamma = (TH1F*)hist[iZgamma]->Clone("Zgamma"); //Zgamma -> Sumw2(); if(ip == iH125) ggH = (TH1F*)hist[iH125]->Clone("ggH"); //ggH -> Sumw2(); if (moveOverflow) MoveOverflowBins (hist[ip], xmin, xmax); else ZeroOutOfRangeBins(hist[ip], xmin, xmax); if (ngroup > 0) hist[ip]->Rebin(ngroup); if (ip == iWg) { //hist[ip]->Scale(0.01); } if (ip == iData) { hist[ip]->SetMarkerStyle(kFullCircle); } else { hist[ip]->SetFillColor(color[ip]); hist[ip]->SetFillStyle(1001); hist[ip]->SetLineColor(color[ip]); if (_dataDriven && ip == itt) hist[ip]->Scale(ttScale[_njet]); if (_dataDriven && ip == itW) hist[ip]->Scale(tWScale[_njet]); if (_dataDriven && ip == iWW) hist[ip]->Scale(WWScale[_njet]); if (_dataDriven && ip == iDY) hist[ip]->Scale(ZjScale[_njet]); if (_dataDriven && ip == iDYtau) hist[ip]->Scale(ZjScale[_njet]); if( ip != iZZ ) hstack->Add(hist[ip]);//TODO something wrong with ZZ } } if (_dataDriven) { top->Scale(ttScale[_njet]); tW->Scale(tWScale[_njet]); WW->Scale(WWScale[_njet]); Zjets->Scale(ZjScale[_njet]); DYtau->Scale(ZjScale[_njet]); } top ->Add(tW); //VV ->Add(ZZ); //VV ->Add(Wg); //Zjets->Add(DYtau); //Zjets->Add(Zgamma); data -> Write(); top -> Write(); WW -> Write(); //VV -> Write(); //Wjets -> Write(); //Zjets -> Write(); ggH -> Write(); outfile->Close(); // All MC //---------------------------------------------------------------------------- TH1F* allmc = (TH1F*)hist[iData]->Clone("allmc"); allmc->SetFillColor (kGray+2); allmc->SetFillStyle ( 3345); allmc->SetLineColor (kGray+2); allmc->SetMarkerColor(kGray+2); allmc->SetMarkerSize ( 0); for (UInt_t ibin=1; ibin<=allmc->GetNbinsX(); ibin++) { Double_t binValue = 0; Double_t binError = 0; for (UInt_t ip=0; ip<nProcesses; ip++) { if (ip == iData) continue; if (ip == iZZ) continue; Double_t binContent = hist[ip]->GetBinContent(ibin); binValue += binContent; binError += (hist[ip]->GetBinError(ibin) * hist[ip]->GetBinError(ibin)); //We need to calculate systematic uncertainty for ggH case // if (_dataDriven) // binError += (systError[ip]*binContent * systError[ip]*binContent); } binError = sqrt(binError); allmc->SetBinContent(ibin, binValue); allmc->SetBinError (ibin, binError); } // Axis labels //------------------------------------------------------------------ TAxis* xaxis = hist[iData]->GetXaxis(); TAxis* yaxis = hist[iData]->GetYaxis(); TString ytitle = Form("entries / %s.%df", "%", precision); xaxis->SetTitle(xtitle); yaxis->SetTitle(Form(ytitle.Data(), hist[iData]->GetBinWidth(0))); yaxis->SetTitleOffset(1.6); if (!units.Contains("NULL")) { xaxis->SetTitle(Form("%s [%s]", xaxis->GetTitle(), units.Data())); yaxis->SetTitle(Form("%s %s", yaxis->GetTitle(), units.Data())); } // Draw //-------------------------------------------------------------------- xaxis->SetRangeUser(xmin, xmax); hist[iData]->Draw("ep"); hstack ->Draw("hist,same"); allmc ->Draw("e2,same"); hist[iData]->Draw("ep,same"); // Adjust scale //---------------------------------------------------------------------------- Float_t theMax = GetMaximumIncludingErrors(hist[iData], xmin, xmax); Float_t theMaxMC = GetMaximumIncludingErrors(allmc, xmin, xmax); if (theMaxMC > theMax) theMax = theMaxMC; if (pad1->GetLogy()) { theMax = TMath::Power(10, TMath::Log10(theMax) + 2.7); hist[iData]->SetMinimum(0.05); } else theMax *= 1.55; hist[iData]->SetMaximum(theMax); // Legend //---------------------------------------------------------------------- Double_t x0 = 0.720; Double_t y0 = 0.834; Double_t yoffset = 0.048; Double_t delta = yoffset + 0.001; Double_t ndelta = 0; Double_t YieldTop = Yield(hist[itt]) + Yield(hist[itW]); Double_t YieldWZ = Yield(hist[iWZ]); Double_t YieldVV = Yield(hist[iWZ]) + Yield(hist[iZZ]) + Yield(hist[iWg]); //Double_t YieldZJets = Yield(hist[iDY]) + Yield(hist[iDYtau]); Double_t YieldZJets = Yield(hist[iDY]) + Yield(hist[iDYtau]) + Yield(hist[iZgamma]); DrawLegend(x0 - 0.49, y0 - ndelta, hist[iData], Form(" data (%.0f)", Yield(hist[iData])), "lp", 0.03, 0.2, yoffset); ndelta += delta; //DrawLegend(x0 - 0.23, y0 - ndelta, hist[itt], Form(" tt (%.0f)", Yield(hist[itt])), "f", 0.03, 0.2, yoffset); ndelta += delta; //DrawLegend(x0 - 0.23, y0 - ndelta, hist[itW], Form(" tW (%.0f)", Yield(hist[itW])), "f", 0.03, 0.2, yoffset); ndelta += delta; //DrawLegend(x0 - 0.49, y0 - ndelta, allmc, Form(" all (%.0f)", Yield(allmc)), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.49, y0 - ndelta, hist[iWW], Form(" WW (%.0f)", Yield(hist[iWW])), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.49, y0 - ndelta, hist[iWZ], Form(" WZ (%.0f)", Yield(hist[iWZ])), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.49, y0 - ndelta, hist[iWg], Form(" Wg (%.0f)", Yield(hist[iWg])), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.49, y0 - ndelta, hist[iWgSMu], Form(" Wg*Mu (%.0f)", Yield(hist[iWgSMu])), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.49, y0 - ndelta, hist[iWgSEl], Form(" Wg*El (%.0f)", Yield(hist[iWgSEl])), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.49, y0 - ndelta, hist[iWj], Form(" W+jets (%.0f)",Yield(hist[iWj])), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.49, y0 - ndelta, hist[iZZ], Form(" ZZ (%.0f)", Yield(hist[iZZ])), "f", 0.03, 0.2, yoffset); ndelta += delta; ndelta = 0; DrawLegend(x0 - 0.23, y0 - ndelta, hist[iDY], Form(" DY (%.0f)", Yield(hist[iDY])), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.23, y0 - ndelta, hist[iDYtau], Form(" DYtau (%.0f)", Yield(hist[iDYtau])),"f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.23, y0 - ndelta, hist[iZgamma],Form(" Zg (%.0f)", Yield(hist[iZgamma])),"f", 0.03, 0.2, yoffset); ndelta += delta; //DrawLegend(x0 - 0.23, y0 - ndelta, hist[iDY], Form(" Z+jets (%.0f)", YieldZJets), "f", 0.03, 0.2, yoffset); ndelta += delta; //DrawLegend(x0 - 0.23, y0 - ndelta, hist[iH125], Form(" Higgs (%.0f)", Yield(hist[iH125])), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.23, y0 - ndelta, hist[iH125], Form(" ggH (%.0f)", Yield(hist[iH125])), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.23, y0 - ndelta, hist[itt], Form(" tt (%.0f)", Yield(hist[itt])), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.23, y0 - ndelta, hist[itW], Form(" tW (%.0f)", Yield(hist[itW])), "f", 0.03, 0.2, yoffset); ndelta += delta; // Additional titles //---------------------------------------------------------------------------- //TString channelLabel = "ee/#mu#mu/e#mu/#mue"; TString channelLabel = ""; //if (_channel == "EE") channelLabel = "ee"; //if (_channel == "MuMu") channelLabel = "#mu#mu"; //if (_channel == "EMu") channelLabel = "e#mu"; //if (_channel == "MuE") channelLabel = "#mue"; //if (_channel == "SF") channelLabel = "ee/#mu#mu"; //if (_channel == "OF") channelLabel = "e#mu/#mue"; channelLabel += Form(" %d", _njet); if (_njet == 0) channelLabel += "-jets"; if (_njet == 1) channelLabel += "-jet"; if (_njet >= 2) channelLabel += "-jets"; double nBin; double binWidth; nBin = allmc->GetSize(); nBin -=2; binWidth = allmc->GetBinWidth(2); int Z1bin=70/binWidth; int Z2bin=110/binWidth; cout<<"number of bin: "<<nBin<<endl; cout<<"Z bin1: "<<Z1bin<<" Z bin2: "<<Z2bin<<endl; double nMcZ, nDataZ; nMcZ = allmc->Integral(Z1bin,Z2bin); nDataZ = hist[iData]->Integral(Z1bin,Z2bin); double effiCorr; effiCorr=nDataZ/nMcZ; cout<<"efficiency correction factor: "<<effiCorr<<endl; double nMcGstar, nDataGstar, nMcGamma; nMcGstar = hist[iWgSMu]->Integral(1,2); nMcGamma = hist[iWg]->Integral(1,2); //nMcGstar = allmc->Integral(1,2); nMcGstar *= effiCorr; nMcGamma *= effiCorr; nDataGstar = hist[iData]->Integral(1,2); double Kfactor; double KfactorErr; nDataGstar -= nMcGamma; Kfactor = nDataGstar/nMcGstar; KfactorErr =Kfactor* TMath::Sqrt(nDataGstar/nDataGstar/nDataGstar + nMcGstar/nMcGstar/nMcGstar); KfactorErr += 0.1; cout<<"Kfactor: "<<Kfactor<<"+"<<KfactorErr<<endl; //DrawTLatex(0.185, 0.975, 0.05, 13, channelLabel.Data(),""); DrawTLatex(0.940, 0.983, 0.05, 33, Form("L = %.1f fb^{-1}", _luminosity/1e3),""); DrawTLatex(0.45, 0.48, 0.04, 13, Form("K factor (Data/Wg*) = %.2f #pm %.2f", Kfactor, KfactorErr ),""); DrawTLatex(0.45, 0.43, 0.04, 13, Form("0< InvM(#mu^{+}#mu^{-}) <4 GeV"),""); //---------------------------------------------------------------------------- // pad2 //---------------------------------------------------------------------------- pad2->cd(); TH1F* ratio = (TH1F*)hist[iData]->Clone("ratio"); TH1F* uncertainty = (TH1F*)allmc->Clone("uncertainty"); for (UInt_t ibin=1; ibin<=ratio->GetNbinsX(); ibin++) { Double_t mcValue = allmc->GetBinContent(ibin); Double_t mcError = allmc->GetBinError (ibin); Double_t dtValue = ratio->GetBinContent(ibin); Double_t dtError = ratio->GetBinError (ibin); Double_t ratioValue = (mcValue > 0) ? dtValue/mcValue : 0.0; Double_t ratioError = (mcValue > 0) ? dtError/mcValue : 0.0; Double_t uncertaintyError = (mcValue > 0) ? mcError/mcValue : 0.0; ratio->SetBinContent(ibin, ratioValue); ratio->SetBinError (ibin, ratioError); uncertainty->SetBinContent(ibin, 1.0); uncertainty->SetBinError (ibin, uncertaintyError); } TAxis* uaxis = (TAxis*)uncertainty->GetXaxis(); uaxis->SetRangeUser(xmin, xmax); uncertainty->Draw("e2"); ratio ->Draw("ep,same"); uncertainty->GetYaxis()->SetRangeUser(0, 2.5); // Save //---------------------------------------------------------------------- pad2->cd(); SetAxis(uncertainty, hist[iData]->GetXaxis()->GetTitle(), "data / prediction", 0.10, 0.8); pad1->cd(); SetAxis(hist[iData], "", hist[iData]->GetYaxis()->GetTitle(), 0.05, 1.6); canvas->cd(); TString suffixLogy = (_setLogy) ? "_Log" : "_Lin"; canvas->SaveAs(Form("%s/%s%s.%s", _output.Data(), hname.Data(), suffixLogy.Data(), _format.Data())); }
void hhShuttleTransport::UpdateAxis( const idMat3 &newAxis ) { // Yaw transport to match yaw of shuttle idAngles ang = newAxis.ToAngles(); ang.pitch = ang.roll = 0.0f; SetAxis(ang.ToMat3()); }
void GamepadDirectX::Update() { m_lpDirectInputDevice->Poll(); // Get events: while (true) { DIDEVICEOBJECTDATA buffer[16]; DWORD num_events = 16; HRESULT result = m_lpDirectInputDevice->GetDeviceData( sizeof(DIDEVICEOBJECTDATA), buffer, &num_events, 0); // Try to reacquire joystick if we lost it. if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) m_lpDirectInputDevice->Acquire(); if (FAILED(result) && result != DI_BUFFEROVERFLOW) break; if (num_events == 0) break; for (unsigned int i=0; i<num_events; i++) { if (buffer[i].dwOfs == FIELD_OFFSET(DIJOYSTATE2, lX)) { SetAxis(0, float(buffer[i].dwData)/(0xffff/2)-1.0f); } else if (buffer[i].dwOfs == FIELD_OFFSET(DIJOYSTATE2, lY)) { // Y Axis position event SetAxis(1, float(buffer[i].dwData)/(0xffff/2)-1.0f); } else if (buffer[i].dwOfs == FIELD_OFFSET(DIJOYSTATE2, lZ)) { // Z Axis position event SetAxis(2, float(buffer[i].dwData)/(0xffff/2)-1.0f); }else if (buffer[i].dwOfs == FIELD_OFFSET(DIJOYSTATE2, rglSlider[0])) { // extra 1 axis position event SetAxis(3, float(buffer[i].dwData)/(0xffff/2)-1.0f); } else if (buffer[i].dwOfs == FIELD_OFFSET(DIJOYSTATE2, rglSlider[1])) { // extra 2 axis position event SetAxis(4, float(buffer[i].dwData)/(0xffff/2)-1.0f); } else if (buffer[i].dwOfs >= FIELD_OFFSET(DIJOYSTATE2, rgbButtons) && buffer[i].dwOfs < FIELD_OFFSET(DIJOYSTATE2, rgbButtons)+128) { // Button event int button_index = buffer[i].dwOfs - FIELD_OFFSET(DIJOYSTATE2, rgbButtons); // If high bit of lower byte is set, key is down OnButton( LOBYTE(buffer[i].dwData) != 0, button_index); } else if (buffer[i].dwOfs >= FIELD_OFFSET(DIJOYSTATE2, rgdwPOV) && buffer[i].dwOfs < FIELD_OFFSET(DIJOYSTATE2, rgdwPOV)+4*sizeof(DWORD)) { // Hat event: int hat_index = (buffer[i].dwOfs - FIELD_OFFSET(DIJOYSTATE2, rgdwPOV)) / sizeof(DWORD); bool centered = (LOWORD(buffer[i].dwData) == 0xFFFF); int direction = buffer[i].dwData / DI_DEGREES; if (centered) direction = -1; OnHat(hat_index, (float)direction); } else if (buffer[i].dwOfs == FIELD_OFFSET(DIJOYSTATE2, lRx)) { // X Axis rotation event SetAxis(5, float(buffer[i].dwData)/(0xffff/2)-1.0f); } else if (buffer[i].dwOfs == FIELD_OFFSET(DIJOYSTATE2, lRy)) { // Y Axis rotation event SetAxis(6, float(buffer[i].dwData)/(0xffff/2)-1.0f); } else if (buffer[i].dwOfs == FIELD_OFFSET(DIJOYSTATE2, lRz)) { // Z Axis rotation event SetAxis(7, float(buffer[i].dwData)/(0xffff/2)-1.0f); } { //Ignoring hat data, force, torque, rotation, etc for now #ifdef _DEBUG //LogMsg("Unhandled gamepad event"); #endif } } } Gamepad::Update(); }