inline void GUIRadarLayout::DrawPos(unsigned num, Ogre::Vector3 dst_pos, Ogre::Quaternion players_orientation) { Ogre::Rectangle2D *row = Rows.Data[num]; Ogre::Rectangle2D *obj = Objects.Data[num]; //dst_pos -= CommonDeclarations::MaxDistForRadar/2; Ogre::Quaternion orientation(Ogre::Degree(30), Ogre::Vector3::UNIT_X); Ogre::Quaternion player_rotation(players_orientation.getYaw(), Ogre::Vector3::UNIT_Y); player_rotation = Ogre::Quaternion(players_orientation.getRoll(), Ogre::Vector3::UNIT_Z) * player_rotation; Ogre::Vector3 rel_pos = dst_pos, base_pos = rel_pos; base_pos.y=0; float scr_height = rel_pos.y*ScreenSize / CommonDeclarations::MaxDistForRadar; base_pos = orientation * players_orientation * base_pos; base_pos = (base_pos / CommonDeclarations::MaxDistForRadar)*ScreenSize; base_pos.x += 0.75; base_pos.y -= 0.75; if (scr_height==0) scr_height=0.01; float left=base_pos.x-0.0035, top=base_pos.y, right=base_pos.x+0.0035, bottom=base_pos.y+scr_height; // obj->setCorners(base_pos.x-0.01, base_pos.y+0.005, base_pos.x+0.01, base_pos.y-0.005); if (scr_height>0) { left=base_pos.x-0.0025; top=base_pos.y+scr_height; right=base_pos.x+0.0025; bottom=base_pos.y; obj->setMaterial("Radar/ObjMaterialUp"); } else if (scr_height<0) { left=base_pos.x-0.0025; top=base_pos.y; right=base_pos.x+0.0025; bottom=base_pos.y+scr_height; obj->setMaterial("Radar/ObjMaterialDn"); } row->setCorners(left, top, right, bottom); row->setVisible(true); obj->setVisible(true); }
inline void GUIRadarLayout::DrawCompas(Ogre::Quaternion players_orientation) { //static clock_t last_update_time=0; //if (clock()-last_update_time<100) // return; assert(CompasRect && CompasObj); //if (NULL==CompasRect || NULL==CompasObj) // return; //last_update_time = clock(); //CompasTarget; if (TargetID>0) { if (--WaitCompasTargetTimeout>=0) { CompasRect->setVisible(false); CompasObj->setVisible(false); return; } IAAObject *obj = CommonDeclarations::GetIDObject(TargetID); //assert(obj); if (NULL==obj) { RemoveCompasTarget(); return; } CompasTarget = obj->GetPosition(); } Ogre::Rectangle2D *row = CompasRect; Ogre::Rectangle2D *obj = CompasObj; //dst_pos -= CommonDeclarations::MaxDistForRadar/2; Ogre::Quaternion orientation(Ogre::Degree(30), Ogre::Vector3::UNIT_X); Ogre::Quaternion player_rotation(players_orientation.getYaw(), Ogre::Vector3::UNIT_Y); player_rotation = Ogre::Quaternion(players_orientation.getRoll(), Ogre::Vector3::UNIT_Z) * player_rotation; Ogre::Vector3 pl_pos = CommonDeclarations::GetPlayer()->GetPosition(); Ogre::Vector3 rel_pos = CompasTarget-pl_pos, base_pos = rel_pos; base_pos.y=0; bool checkpoint_mode=false; float scr_height = 0; if (rel_pos.squaredLength()>CommonDeclarations::SqMaxDistForRadar) { Ogre::Vector3 dist=base_pos; AAUtilities::Norm1(dist); base_pos = dist*CommonDeclarations::MaxDistForRadar; scr_height=0.01; checkpoint_mode=true; } else { scr_height =rel_pos.y*ScreenSize / CommonDeclarations::MaxDistForRadar; } base_pos = orientation * players_orientation * base_pos; base_pos = (base_pos / CommonDeclarations::MaxDistForRadar)*ScreenSize; base_pos.x += 0.75; base_pos.y -= 0.75; // if (!checkpoint_mode) { if (scr_height==0) scr_height=0.01; float left=base_pos.x-0.005, top=base_pos.y, right=base_pos.x+0.005, bottom=base_pos.y+scr_height; obj->setCorners(base_pos.x-0.01, base_pos.y+0.008, base_pos.x+0.01, base_pos.y-0.008); if (scr_height>0) { left=base_pos.x-0.0025; top=base_pos.y+scr_height; right=base_pos.x+0.0025; bottom=base_pos.y; obj->setMaterial("Radar/CompasObjMaterialUp"); } else if (scr_height<0) { left=base_pos.x-0.0025; top=base_pos.y; right=base_pos.x+0.0025; bottom=base_pos.y+scr_height; obj->setMaterial("Radar/CompasObjMaterialDn"); } row->setCorners(left, top, right, bottom); // row->setVisible(true); obj->setVisible(true); } else { obj->setMaterial("Radar/CompasFarMaterial"); obj->setCorners(base_pos.x-0.015, base_pos.y+0.015, base_pos.x+0.015, base_pos.y-0.015); obj->setVisible(true); } }