// convert from human-friendly format void CMappingDefinition::FromUI(const CMappingDefinitionUI &mdui) { // extract all values from mapping definition md_fUoS = +Cos(-(mdui.mdui_aVRotation)); md_fUoT = +Sin(-(mdui.mdui_aVRotation)); md_fVoS = +Cos(-(mdui.mdui_aURotation)+AngleDeg(90.0f)); md_fVoT = +Sin(-(mdui.mdui_aURotation)+AngleDeg(90.0f)); md_fUoS /= mdui.mdui_fUStretch; md_fUoT /= mdui.mdui_fUStretch; md_fVoS /= mdui.mdui_fVStretch; md_fVoT /= mdui.mdui_fVStretch; md_fUOffset = mdui.mdui_fUOffset; md_fVOffset = mdui.mdui_fVOffset; }
/*! */ AngleDeg Body_AdvanceBall2009::getBestAngle( const PlayerAgent * agent ) { const BallObject & ball = agent->world().ball(); const double max_dist = 30.0; Vector2D left_limit( 0.0, -ServerParam::i().pitchHalfWidth() + 3.0 ); double ydiff = std::fabs( left_limit.y - ball.pos().y ); if ( ydiff < max_dist ) { left_limit.x = ball.pos().x + std::sqrt( max_dist * max_dist - ydiff * ydiff ); } if ( left_limit.x > 50.0 ) { left_limit.x = 50.0; } Vector2D right_limit( 0.0, ServerParam::i().pitchHalfWidth() - 5.0 ); ydiff = std::fabs( right_limit.y - ball.pos().y ); if ( ydiff < max_dist ) { right_limit.x = ball.pos().x + std::sqrt( max_dist * max_dist - ydiff * ydiff ); } if ( right_limit.x > 50.0 ) { right_limit.x = 50.0; } double lower_angle = ( left_limit - ball.pos() ).th().degree(); if ( lower_angle < -65.0 ) lower_angle = -65.0; double upper_angle = ( right_limit - ball.pos() ).th().degree(); if ( upper_angle > 65.0 ) upper_angle = 65.0; if ( lower_angle > upper_angle ) { dlog.addText( Logger::CLEAR, __FILE__": getBestAngle. angle_error. lower=%.1f, uppser=%.1f", lower_angle, upper_angle ); return AngleDeg( 0.0 ); } dlog.addText( Logger::CLEAR, __FILE__": getBestAngle. left(%.1f %.1f)lower_angle=%.1f right(%.1f %.1f)upper_angle=%.1f", left_limit.x, left_limit.y, lower_angle, right_limit.x, right_limit.y, upper_angle ); return get_best_advance_angle( agent, lower_angle, upper_angle, false ); }
// ================================================================================== Vector2D TacticTransferObject::AvoidtoEnterCircle(Circle2D Ci, Vector2D pnt, Vector2D finPOS) { // Avoided=false; Segment2D S(pnt,finPOS); if(Ci.HasIntersection(S) || Ci.contains(pnt) || Ci.contains(finPOS)) { // qDebug() << " HAS INTERSECTION WITH CIRCLE !! DO NOT ENTER THIS CIRCLE PLEASE !!!"; // qDebug() << " HAS INTERSECTION WITH CIRCLE ( " << Ci.center().x << "," << Ci.center().y << " ) , Radius : " << Ci.radius() ; Vector2D c2r = pnt - Ci.center() ; Vector2D c2f = finPOS - Ci.center() ; c2r.setLength(Ci.radius()+50); AngleDeg angle=c2r.dir() - c2f.dir(); //double ang=c2r.dir().radian() - c2f.dir().radian(); if (angle.radian() > M_PI) angle -= AngleDeg(M_PI) *= 2; if (angle.radian() < -M_PI) angle += AngleDeg(M_PI) *= 2; //if (ang > M_PI) ang -= 2 * M_PI; //if (ang < -M_PI) ang += 2 * M_PI; //qDebug() << "c2r DIRECTION = " << c2r.dir().degree() << "c2f DIRECTION = " << c2f.dir().degree() << " ANGLE = " << angle.degree() << " ANG =" << ang*57.32; int div=int(Ci.radius()/50); // qDebug() << "div = " << div ; angle=angle/=min(div,6); angle=c2r.dir() - angle; c2r.setDir(angle);// c2f.dir())); Vector2D p = Ci.center() + c2r ; // Avoided=true; // qDebug() << " Avoided point is : (" << finPOS.x << "," <<finPOS.y << ") & Corrected is : ("<< // p.x << "," << p.y << ")" ; return p; } else { return finPOS; } }
bool SkillGoalie::execute(RobotCommand &rc) { if(_rid==-1) return false; Ray2D ballRay(_wm->ball.pos.loc,AngleDeg(_wm->ball.vel.loc.dir().degree())); Line2D lineGoal(Vector2D(-3025,-2025),Vector2D(-3025,2025)); Vector2D gdir, gloc; gdir=Vector2D(); gloc=Vector2D(); int kickerID=-1; float minDist=9000000,temp; Vector2D ballContact = ballRay.intersection(lineGoal); if(_wm->ball.pos.loc.dist2(Vector2D(-3025,175))<=640000 || _wm->ball.pos.loc.dist2(Vector2D(-3025,-175))<=640000 || (_wm->ball.pos.loc.x<=-2225 && _wm->ball.pos.loc.y<=175 && _wm->ball.pos.loc.y>=-175)) { if(ballContact.y>=-350 && ballContact.y<=350) { gloc=_wm->ball.pos.loc+_wm->ball.vel.loc.setLengthVector(90); } else { gloc=_wm->ball.pos.loc; gloc.x-=90; } gdir.x=1; gdir.y=0; } else { if(ballContact.y>=-350 && ballContact.y<=350) { gloc=ballContact-_wm->ball.vel.loc.setLengthVector(350); gdir=-_wm->ball.vel.loc; } else { for(int i=0; i<PLAYERS_MAX_NUM;i++) { if(_wm->oppRobot[i].isValid) { temp=_wm->oppRobot[i].pos.loc.dist2(_wm->ball.pos.loc); if(temp<minDist) { minDist=temp; kickerID=i; } } } if(kickerID!=-1) { if(_wm->oppRobot[kickerID].pos.dir>=-M_PI_2 && _wm->oppRobot[kickerID].pos.dir<=M_PI_2) { Vector2D rTarget,rTemp; Ray2D tRay(_wm->oppRobot[kickerID].pos.loc,AngleDeg(_wm->oppRobot[kickerID].pos.dir*AngleDeg::RAD2DEG)); minDist=100000000; for(int i=0;i<PLAYERS_MAX_NUM;i++) { rTemp=tRay.intersection(Ray2D(_wm->oppRobot[i].pos.loc,AngleDeg(_wm->oppRobot[i].vel.loc.dir().degree()))); temp=_wm->ball.pos.loc.dist2(rTemp); if(temp<minDist) { rTarget=rTemp; minDist=temp; } } gdir=(rTarget-Vector2D(-3025,0)).setLengthVector(500); gloc=Vector2D(-3025,0)+gdir; } else { Vector2D ins; Line2D l1(_wm->oppRobot[kickerID].pos.loc,AngleDeg(_wm->oppRobot[kickerID].pos.dir*AngleDeg::RAD2DEG)); ins = l1.intersection(lineGoal); if(ins.y>350) { ins.y=350; } else if(ins.y<-350) { ins.y=-350; } ins.x=-3025; gdir=(_wm->ball.pos.loc-ins).setLengthVector(500); gloc=gdir+ins; } } else { gdir=(_wm->ball.pos.loc-Vector2D(-3025,0)).setLengthVector(500); gloc=Vector2D(-3025,0)+gdir; } } } if(gloc.x<-2980) gloc.x=-2980; rc.FinalPos.loc=gloc; rc.TargetPos.loc=gloc; rc.FinalPos.dir=gdir.dir().radian(); rc.TargetPos.dir=gdir.dir().radian(); rc.Speed=1; return true; }
void PlayStop::setPositions() { Position leftDefPos,rightDefPos,goaliePos; int leftID = -1, rightID = -1 , midID = -1; bool leftNav, rightNav; if( wm->ourRobot[previousLeftID].Role != AgentRole::DefenderLeft ) previousLeftID = -1; if( wm->ourRobot[previousRightID].Role != AgentRole::DefenderRight ) previousRightID = -1; if( (wm->ourRobot[tDefenderLeft->getID()].Role == AgentRole::DefenderLeft) && (leftChecker < PresenceCounter) ) { leftID = tDefenderLeft->getID(); this->previousLeftID = tDefenderLeft->getID();; } if( wm->ourRobot[tDefenderRight->getID()].Role == AgentRole::DefenderRight && (rightChecker < PresenceCounter) ) { rightID = tDefenderRight->getID(); this->previousRightID = tDefenderRight->getID();; } if( leftChecker > PresenceCounter || leftID == -1 ) midID = rightID; if( rightChecker > PresenceCounter || rightID == -1) midID = leftID; zonePositions(leftID,rightID,midID,goaliePos,leftDefPos,leftNav,rightDefPos,rightNav); tDefenderLeft->setIdlePosition(leftDefPos); tDefenderLeft->setUseNav(leftNav); tDefenderRight->setIdlePosition(rightDefPos); tDefenderRight->setUseNav(rightNav); if( leftID != -1) { if( (wm->ourRobot[leftID].Status != AgentStatus::FollowingBall ) && (wm->ourRobot[leftID].pos.loc - leftDefPos.loc).length() > 250 ) leftChecker++; else leftChecker = 0; } else { if( !haltedRobotIsInField(previousLeftID) ) leftChecker = 0; } if( rightID != -1) { if( (wm->ourRobot[rightID].Status != AgentStatus::FollowingBall ) && (wm->ourRobot[rightID].pos.loc - rightDefPos.loc).length() > 250 ) rightChecker++; else rightChecker = 0; } else { if( !haltedRobotIsInField(previousRightID) ) rightChecker = 0; } tGolie->setIdlePosition(goaliePos); if(wm->kn->IsInsideGolieArea(wm->ball.pos.loc) ) { tStopLeft->setStopPosition(Vector2D(Field::MinX/2.0,Field::ourGoalPost_L.y+200)); tStopRight->setStopPosition(Vector2D(Field::MinX/2.0,Field::ourGoalPost_R.y-200)); tStopMid->setStopPosition(Vector2D(Field::MinX/2.0,Field::ourGoalCenter.y)); } else if( wm->kn->IsInsideNearArea(wm->ball.pos.loc) ) { Vector2D candidateL_1, candidateL_2, mainL; Circle2D cir_l(Field::defenceLineLinear_L,Field::goalCircle_R+ROBOT_RADIUS); Line2D thirty_l(Field::defenceLineLinear_L,AngleDeg(30)); cir_l.intersection(thirty_l,&candidateL_1,&candidateL_2); if( wm->kn->IsInsideField(candidateL_1) && !wm->kn->IsInsideGolieArea(candidateL_1) ) mainL = candidateL_1; else mainL = candidateL_2; tStopLeft->setStopPosition(Vector2D(mainL.x,sign(wm->ball.pos.loc.y)*mainL.y)); tStopMid->setStopPosition(Vector2D(Field::MinX+300,-sign(wm->ball.pos.loc.y)*1400)); tStopRight->setStopPosition(Vector2D(mainL.x,-sign(wm->ball.pos.loc.y)*mainL.y)); } else { Vector2D finalPos,notImportant,leftPos,rightPos; Circle2D robotCircle(wm->ball.pos.loc,ALLOW_NEAR_BALL_RANGE); Segment2D line2Goal(wm->ball.pos.loc,Field::ourGoalCenter); robotCircle.intersection(line2Goal,&finalPos,¬Important); Circle2D secondCircle(finalPos,(2.5)*ROBOT_RADIUS); robotCircle.intersection(secondCircle,&leftPos,&rightPos); if( !wm->kn->IsInsideField(leftPos) ) { leftPos = finalPos; finalPos = rightPos; Vector2D leftPos2,rightPos2; Circle2D secondCircle(finalPos,(2.5)*ROBOT_RADIUS); robotCircle.intersection(secondCircle,&leftPos2,&rightPos2); if( leftPos.dist(leftPos2) < leftPos.dist(rightPos2) ) rightPos = rightPos2; else rightPos = leftPos2; } else if( !wm->kn->IsInsideField(rightPos) ) { rightPos = finalPos; finalPos = leftPos; Vector2D leftPos2,rightPos2; Circle2D secondCircle(finalPos,(2.5)*ROBOT_RADIUS); robotCircle.intersection(secondCircle,&leftPos2,&rightPos2); if( rightPos.dist(leftPos2) < rightPos.dist(rightPos2) ) leftPos = rightPos2; else leftPos = leftPos2; } if( collisionwithDefenders(finalPos,leftPos,rightPos) || oneOfDefendersIsInPenalty(leftPos,finalPos,rightPos) ) { if( wm->kn->IsInsideRect(wm->ball.pos.loc,Vector2D(Field::MinX,Field::MaxY),Vector2D(0,0.25*Field::MaxY)) || wm->kn->IsInsideRect(wm->ball.pos.loc,Vector2D(Field::MinX,0.25*Field::MinY),Vector2D(0,Field::MinY)) ) { Vector2D candidateL_1, candidateL_2, mainL; Circle2D cir_l(Field::defenceLineLinear_L,Field::goalCircle_R+ROBOT_RADIUS); Line2D thirty_l(Field::defenceLineLinear_L,AngleDeg(30)); cir_l.intersection(thirty_l,&candidateL_1,&candidateL_2); if( wm->kn->IsInsideField(candidateL_1) && !wm->kn->IsInsideGolieArea(candidateL_1) ) mainL = candidateL_1; else mainL = candidateL_2; tStopLeft->setStopPosition(Vector2D(mainL.x,sign(wm->ball.pos.loc.y)*mainL.y)); tStopMid->setStopPosition(Vector2D(Field::ourPenaltySpot.x+200,Field::ourPenaltySpot.y)); tStopRight->setStopPosition(Vector2D(mainL.x,-sign(wm->ball.pos.loc.y)*mainL.y)); } else { //tStopLeft->setStopPosition(Vector2D(wm->ourRobot[tDefenderLeft->getID()].pos.loc.x // , wm->ourRobot[tDefenderLeft->getID()].pos.loc.y+5*ROBOT_RADIUS)); finalPos = Vector2D(wm->ourRobot[tDefenderLeft->getID()].pos.loc.x, 0.5*(wm->ourRobot[tDefenderLeft->getID()].pos.loc.y+wm->ourRobot[tDefenderRight->getID()].pos.loc.y) ); tStopLeft->setStopPosition(Vector2D(finalPos.x,finalPos.y+4.5*ROBOT_RADIUS)); tStopMid->setStopPosition(Vector2D(finalPos.x,finalPos.y-6.5*ROBOT_RADIUS)); tStopRight->setStopPosition(Vector2D(finalPos.x,finalPos.y-4.5*ROBOT_RADIUS)); } } else { tStopLeft->setStopPosition(leftPos); tStopMid->setStopPosition(finalPos); tStopRight->setStopPosition(rightPos); } } }
void CDlgCreateSpecularTexture::DrawPreview( CDrawPort *pdp, FLOAT fExp) { BOOL bErrorOcured = FALSE; if( (m_moModel.GetData() == NULL) || (m_moModel.mo_toTexture.GetData() == NULL) || (m_moModel.mo_toSpecular.GetData() == NULL) ) // obtain components for rendering try { DECLARE_CTFILENAME( fnBCGTexture, "Models\\Editor\\SpecularPreviewBCG.tex"); m_toBackground.SetData_t( fnBCGTexture); DECLARE_CTFILENAME( fnTeapotModel, "Models\\Editor\\Teapot.mdl"); DECLARE_CTFILENAME( fnTeapotTexture, "Models\\Editor\\Teapot.tex"); m_moModel.SetData_t( fnTeapotModel); m_moModel.mo_toTexture.SetData_t( fnTeapotTexture); m_moModel.mo_toSpecular.SetData_t( CTString("temp\\SpecularTemp.tex")); } catch( char *strError) { (void) strError; bErrorOcured = TRUE; } if( !bErrorOcured) { ((CModelData*)m_moModel.GetData())->md_colSpecular = m_colorSpecular.GetColor(); PIXaabbox2D screenBox = PIXaabbox2D( PIX2D(0,0), PIX2D(pdp->GetWidth(), pdp->GetHeight()) ); //pdp->PutTexture( &m_moModel.mo_toSpecular, screenBox); //return; pdp->PutTexture( &m_toBackground, screenBox); pdp->FillZBuffer( ZBUF_BACK); CRenderModel rmRenderModel; CPerspectiveProjection3D prPerspectiveProjection; a3dObjectAngles += a3dObjectRotation; a3dLightAngles += a3dLightRotation; m_plPlacement.pl_OrientationAngle = a3dObjectAngles; AnglesToDirectionVector( a3dLightAngles, rmRenderModel.rm_vLightDirection); prPerspectiveProjection.FOVL() = AngleDeg(50.0f); prPerspectiveProjection.ScreenBBoxL() = FLOATaabbox2D( FLOAT2D(0.0f,0.0f),FLOAT2D((float)pdp->GetWidth(), (float)pdp->GetHeight())); prPerspectiveProjection.AspectRatioL() = 1.0f; prPerspectiveProjection.FrontClipDistanceL() = 0.05f; prPerspectiveProjection.ViewerPlacementL().pl_PositionVector = FLOAT3D(0.0f,0.0f,0.0f); prPerspectiveProjection.ViewerPlacementL().pl_OrientationAngle = ANGLE3D( 0, -20, 0); prPerspectiveProjection.Prepare(); CAnyProjection3D apr; apr = prPerspectiveProjection; BeginModelRenderingView(apr, pdp); _mrpModelRenderPrefs.SetRenderType( RT_TEXTURE|RT_SHADING_PHONG); m_plPlacement.pl_PositionVector = FLOAT3D( 0.0f, -0.19f, -0.35f); rmRenderModel.SetObjectPlacement(m_plPlacement); rmRenderModel.rm_colLight = m_colorLight.GetColor(); rmRenderModel.rm_colAmbient = m_colorAmbient.GetColor(); m_moModel.SetupModelRendering(rmRenderModel); m_moModel.RenderModel(rmRenderModel); EndModelRenderingView(); } /* pdp->Fill(C_GREEN|CT_OPAQUE); PIX pixSizeI = pdp->GetWidth(); PIX pixSizeJ = pdp->GetHeight(); for (PIX pixI=0; pixI<pixSizeI; pixI++) { for (PIX pixJ=0; pixJ<pixSizeJ; pixJ++) { FLOAT fX = pixI*2.0f/pixSizeI-1; FLOAT fY = pixJ*2.0f/pixSizeJ-1; FLOAT fZ; FLOAT fZ2 = 1-fX*fX-fY*fY; if (fZ2<0) { fZ = 0; } else { fZ = Sqrt(fZ2); } FLOAT fZN = FLOAT(pow(fZ, fExp)); ASSERT(fZN>=0 && fZN<=1); UBYTE ub = UBYTE(fZN*255); pdp->Fill(pixI, pixJ, 1,1, RGBToColor(ub,ub,ub)|CT_OPAQUE); } } */ }
bool SkillGoaliePenalty::execute(RobotCommand &rc) { if(_rid==-1) return false; Line2D lineGoal(Vector2D(-3025,-2025),Vector2D(-3025,2025)); Vector2D gdir, gloc; gdir=Vector2D(); gloc=Vector2D(); int kickerID=-1; float minDist=9000000,temp; for(int i=0; i<PLAYERS_MAX_NUM;i++) { if(_wm->oppRobot[i].isValid) { temp=_wm->oppRobot[i].pos.loc.dist2(_wm->ball.pos.loc); if(temp<minDist) { minDist=temp; kickerID=i; } } } ////// if(kickerID!=-1) { gdir=Vector2D(1,0); gloc=Vector2D(-3025,0); } else { Vector2D ins; Line2D l1(_wm->oppRobot[kickerID].pos.loc,AngleDeg(_wm->oppRobot[kickerID].pos.dir*AngleDeg::RAD2DEG)); ins = l1.intersection(lineGoal); if(ins.y>265) { ins.y=265; } else if(ins.y<-265) { ins.y=-265; } ins.x=-3025; gdir=Vector2D(1,0); gloc=ins; } if(gloc.x<-3010) gloc.x=-3010; rc.FinalPos.loc=gloc; rc.TargetPos.loc=gloc; rc.FinalPos.dir=gdir.dir().radian(); rc.TargetPos.dir=gdir.dir().radian(); rc.Speed=1; return true; }
void CDlgPgInfoAttachingPlacement::DoDataExchange(CDataExchange* pDX) { CPropertyPage::DoDataExchange(pDX); CModelerView *pModelerView = CModelerView::GetActiveView(); if(pModelerView == NULL) return; CModelerDoc* pDoc = pModelerView->GetDocument(); CModelData *pMD = &pDoc->m_emEditModel.edm_md; INDEX ctPositions = pDoc->m_emEditModel.edm_aamAttachedModels.Count(); if( (m_iActivePlacement == -1) && ( ctPositions != 0) ) m_iActivePlacement = 0; if( m_iActivePlacement >= ctPositions) { if( ctPositions != 0) m_iActivePlacement = 0; else m_iActivePlacement = -1; } // if transfering data from document to dialog if( !pDX->m_bSaveAndValidate) { BOOL bAttachmentExists = ( m_iActivePlacement != -1); GetDlgItem( IDC_ATTACHING_PLACEMENT_INDEX_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_PREVIOUS_ATTACHING_PLACEMENT )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_NAME )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_NEXT_ATTACHING_PLACEMENT )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_REMOVE_ATTACHING_PLACEMENT )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_X_OFFSET_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_X_OFFSET )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_Y_OFFSET_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_Y_OFFSET )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_Z_OFFSET_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_Z_OFFSET )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_HEADING_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_HEADING )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_PITCH_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_PITCH )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_BANKING_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_BANKING )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_IS_VISIBLE )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_BROWSE_MODEL )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_MODEL_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_MODEL_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_MODEL_ANIMATION_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHMENT_MODEL_ANIMATION_COMBO)->EnableWindow( bAttachmentExists); GetDlgItem( IDC_VERTICES_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_VERTICES )->EnableWindow( bAttachmentExists); if( bAttachmentExists) { pMD->md_aampAttachedPosition.Lock(); pDoc->m_emEditModel.edm_aamAttachedModels.Lock(); CPlacement3D plCurrent = pMD->md_aampAttachedPosition[ m_iActivePlacement].amp_plRelativePlacement; m_fHeading = DegAngle( plCurrent.pl_OrientationAngle(1)); m_fPitch = DegAngle( plCurrent.pl_OrientationAngle(2)); m_fBanking = DegAngle( plCurrent.pl_OrientationAngle(3)); m_fXOffset = plCurrent.pl_PositionVector(1); m_fYOffset = plCurrent.pl_PositionVector(2); m_fZOffset = plCurrent.pl_PositionVector(3); CAttachedModel *pam = &pDoc->m_emEditModel.edm_aamAttachedModels[ m_iActivePlacement]; m_strName = pam->am_strName; m_strAttachingModel = pam->am_moAttachedModel.GetName(); char achrLine[ 256]; sprintf( achrLine, "center:%d, front:%d, up:%d", pMD->md_aampAttachedPosition[ m_iActivePlacement].amp_iCenterVertex, pMD->md_aampAttachedPosition[ m_iActivePlacement].amp_iFrontVertex, pMD->md_aampAttachedPosition[ m_iActivePlacement].amp_iUpVertex); m_strAttachingVertices = achrLine; sprintf( achrLine, "%d.", m_iActivePlacement); m_strPlacementIndex = achrLine; m_bIsVisible = pDoc->m_emEditModel.edm_aamAttachedModels[ m_iActivePlacement].am_bVisible != 0; pDoc->m_emEditModel.edm_aamAttachedModels.Unlock(); pMD->md_aampAttachedPosition.Unlock(); if( IsWindow( m_comboAttachmentModelAnimation.m_hWnd)) { m_comboAttachmentModelAnimation.EnableWindow( m_bIsVisible); FillAttachmentModelAnimationCombo(); } // mark that the values have been updated to reflect the state of the view m_udAllValues.MarkUpdated(); } } //{{AFX_DATA_MAP(CDlgPgInfoAttachingPlacement) DDX_Control(pDX, IDC_ATTACHMENT_MODEL_ANIMATION_COMBO, m_comboAttachmentModelAnimation); DDX_Text(pDX, IDC_ATTACHING_PLACEMENT_BANKING, m_fBanking); DDX_Text(pDX, IDC_ATTACHING_PLACEMENT_HEADING, m_fHeading); DDX_Text(pDX, IDC_ATTACHING_PLACEMENT_PITCH, m_fPitch); DDX_Text(pDX, IDC_ATTACHING_PLACEMENT_X_OFFSET, m_fXOffset); DDX_Text(pDX, IDC_ATTACHING_PLACEMENT_Y_OFFSET, m_fYOffset); DDX_Text(pDX, IDC_ATTACHING_PLACEMENT_Z_OFFSET, m_fZOffset); DDX_Text(pDX, IDC_ATTACHING_PLACEMENT_NAME, m_strName); DDX_Text(pDX, IDC_ATTACHING_MODEL_T, m_strAttachingModel); DDX_Text(pDX, IDC_ATTACHING_VERTICES, m_strAttachingVertices); DDX_Text(pDX, IDC_ATTACHING_PLACEMENT_INDEX_T, m_strPlacementIndex); DDX_Check(pDX, IDC_IS_VISIBLE, m_bIsVisible); //}}AFX_DATA_MAP // if transfering data from dialog to document if( pDX->m_bSaveAndValidate) { if( m_iActivePlacement == -1) return; pMD->md_aampAttachedPosition.Lock(); pDoc->m_emEditModel.edm_aamAttachedModels.Lock(); CPlacement3D plCurrent; plCurrent.pl_OrientationAngle(1) = AngleDeg( m_fHeading); plCurrent.pl_OrientationAngle(2) = AngleDeg( m_fPitch); plCurrent.pl_OrientationAngle(3) = AngleDeg( m_fBanking); plCurrent.pl_PositionVector(1) = m_fXOffset; plCurrent.pl_PositionVector(2) = m_fYOffset; plCurrent.pl_PositionVector(3) = m_fZOffset; pMD->md_aampAttachedPosition[ m_iActivePlacement].amp_plRelativePlacement = plCurrent; pDoc->m_emEditModel.edm_aamAttachedModels[ m_iActivePlacement].am_strName = CStringA(m_strName); pDoc->m_emEditModel.edm_aamAttachedModels[ m_iActivePlacement].am_bVisible = m_bIsVisible; pDoc->m_emEditModel.edm_aamAttachedModels.Unlock(); pMD->md_aampAttachedPosition.Unlock(); pDoc->ClearAttachments(); pDoc->SetupAttachments(); pDoc->SetModifiedFlag(); pDoc->UpdateAllViews( NULL); } }
void CDlgPgPosition::DoDataExchange(CDataExchange* pDX) { if( theApp.m_bDisableDataExchange) return; CPropertyPage::DoDataExchange(pDX); SetModified( TRUE); // obtain document CWorldEditorDoc* pDoc = theApp.GetDocument(); // if document doesn't exist, return if( pDoc == NULL) return; // get active view CWorldEditorView *pWorldEditorView = theApp.GetActiveView(); // if dialog is recieving data if( pDX->m_bSaveAndValidate == FALSE) { // is CSG on? if( pDoc->m_pwoSecondLayer != NULL) { // yes, pick up coordinates for editting from second layer m_fHeading = DegAngle( pDoc->m_plSecondLayer.pl_OrientationAngle(1)); m_fPitch = DegAngle( pDoc->m_plSecondLayer.pl_OrientationAngle(2)); m_fBanking = DegAngle( pDoc->m_plSecondLayer.pl_OrientationAngle(3)); m_fX = pDoc->m_plSecondLayer.pl_PositionVector(1); m_fY = pDoc->m_plSecondLayer.pl_PositionVector(2); m_fZ = pDoc->m_plSecondLayer.pl_PositionVector(3); } // otherwise if we are in entity mode and there is only one entity selected else if( (pDoc->m_iMode == ENTITY_MODE) && ( pDoc->m_selEntitySelection.Count() == 1) ) { // lock selection's dynamic container pDoc->m_selEntitySelection.Lock(); // get first entity CEntity *penEntityOne = pDoc->m_selEntitySelection.Pointer(0); // unlock selection's dynamic container pDoc->m_selEntitySelection.Unlock(); // get placement of first entity CPlacement3D plEntityOnePlacement = penEntityOne->GetPlacement(); m_fHeading = DegAngle( plEntityOnePlacement.pl_OrientationAngle(1)); m_fPitch = DegAngle( plEntityOnePlacement.pl_OrientationAngle(2)); m_fBanking = DegAngle( plEntityOnePlacement.pl_OrientationAngle(3)); m_fX = plEntityOnePlacement.pl_PositionVector(1); m_fY = plEntityOnePlacement.pl_PositionVector(2); m_fZ = plEntityOnePlacement.pl_PositionVector(3); } m_udSelection.MarkUpdated(); } //{{AFX_DATA_MAP(CDlgPgPosition) DDX_Text(pDX, IDC_EDIT_BANKING, m_fBanking); DDX_Text(pDX, IDC_EDIT_HEADING, m_fHeading); DDX_Text(pDX, IDC_EDIT_PITCH, m_fPitch); DDX_Text(pDX, IDC_EDIT_X, m_fX); DDX_Text(pDX, IDC_EDIT_Y, m_fY); DDX_Text(pDX, IDC_EDIT_Z, m_fZ); //}}AFX_DATA_MAP // if dialog is giving data if( pDX->m_bSaveAndValidate != FALSE) { // is CSG on? if( pDoc->m_pwoSecondLayer != NULL) { // yes, copy coordinates from editting controls into second layer pDoc->m_plSecondLayer.pl_OrientationAngle(1) = AngleDeg( m_fHeading); pDoc->m_plSecondLayer.pl_OrientationAngle(2) = AngleDeg( m_fPitch); pDoc->m_plSecondLayer.pl_OrientationAngle(3) = AngleDeg( m_fBanking); pDoc->m_plSecondLayer.pl_PositionVector(1) = m_fX; pDoc->m_plSecondLayer.pl_PositionVector(2) = m_fY; pDoc->m_plSecondLayer.pl_PositionVector(3) = m_fZ; // snap values to grid pDoc->SnapToGrid( pDoc->m_plSecondLayer, SNAP_FLOAT_12); theApp.m_vfpCurrent.vfp_plPrimitive = pDoc->m_plSecondLayer; // update all document's views pDoc->UpdateAllViews( NULL); } // otherwise if we are in entity mode else if( pDoc->m_iMode == ENTITY_MODE) { // there must be only one entity selected ASSERT( pDoc->m_selEntitySelection.Count() == 1); // lock selection's dynamic container pDoc->m_selEntitySelection.Lock(); // get first entity CEntity *penEntityOne = pDoc->m_selEntitySelection.Pointer(0); // unlock selection's dynamic container pDoc->m_selEntitySelection.Unlock(); // get placement of first entity CPlacement3D plEntityOnePlacement = penEntityOne->GetPlacement(); plEntityOnePlacement.pl_OrientationAngle(1) = AngleDeg( m_fHeading); plEntityOnePlacement.pl_OrientationAngle(2) = AngleDeg( m_fPitch); plEntityOnePlacement.pl_OrientationAngle(3) = AngleDeg( m_fBanking); plEntityOnePlacement.pl_PositionVector(1) = m_fX; plEntityOnePlacement.pl_PositionVector(2) = m_fY; plEntityOnePlacement.pl_PositionVector(3) = m_fZ; // snap entity's placement pDoc->SnapToGrid( plEntityOnePlacement, SNAP_FLOAT_12); // set placement back to entity penEntityOne->SetPlacement( plEntityOnePlacement); pDoc->SetModifiedFlag( TRUE); pDoc->UpdateAllViews( NULL); m_udSelection.MarkUpdated(); // update all document's views pDoc->UpdateAllViews( NULL); } } }