// 戦闘部隊ネームプレート表示 public void DrawFightingUnitNamePlate() { // マップの高さを反映した部隊座標 Vector3 unitPos = new Vector3(pos.X, thisGame.MainMap.GetHeight(pos), pos.Z); // カメラ座標とカメラ注視点の宣言 Vector3 cameraPos = thisGame.MainMap.GetCameraPosition(); Vector3 cameraInt = thisGame.MainMap.GetCameraInterest(); Vector3 vecA = cameraPos; // カメラから部隊までのベクトル Vector3 cameraToPos = unitPos - cameraPos; // カメラ座標からカメラ注視点までのベクトル Vector3 cameraVec = cameraInt - cameraPos; // カメラから部隊までの距離 float length = (cameraToPos).Length(); // スケールレート float scaleRate = 100 / length; // 「カメラから部隊までのベクトル」の角度 double rotCameraToPos = Math.Atan2(cameraToPos.Z , cameraToPos.X); // 「カメラ座標からカメラ注視点までのベクトル」の角度 double rotCameraVec = Math.Atan2(cameraVec.Z, cameraVec.X); // カメラ注視点と部隊の角度 float rotCameraIntToUnit = Math.Abs(MathHelper.ToDegrees((float)(rotCameraToPos - rotCameraVec))); // カメラに近くて視野角(45度)範囲内の部隊のみ表示する if (scaleRate > 0.6f && rotCameraIntToUnit < (45.0f / 2.0f)) { // 視線(2点を結ぶ直線)上に、視線を遮る地形が存在するか高度をチェックする bool chk = thisGame.MainMap.mainMapCheck.VisuallyCheckByHeight(vecA, unitPos); if (chk == true) { // ネームプレート描画処理(スプライトバッチ) } } }