96辅助游戏论坛 - 辅助工具|www.96fuzhu.com

 找回密码
 立即注册
5498057
117612016
查看: 7512|回复: 1

绝地求生3D透视方框代码

[复制链接]
发表于 2017-9-21 13:55 | 显示全部楼层 |阅读模式
fHVSqSK.png

Code:
  1.     public void Draw3DBox(FMinimalViewInfo POV, AActor actor)
  2.     {
  3.         float l, w, h, o;
  4.         l = 60f; w = 60f; h = 160f; o = 50f; //box size for standing player
  5.      
  6.         float zOffset = -100f;
  7.      
  8.         if (actor.Type == ActorTypes.Vehicle) //vehicles have a bigger box
  9.         {
  10.             zOffset = 50;
  11.             l = 200f; w = 160f; h = 80f; o = 0f;
  12.         }         
  13.      
  14.             //build box
  15.         Vector3 p00 = new Vector3(o, -w / 2,0f);
  16.         Vector3 p01 = new Vector3(o, w / 2, 0f);
  17.         Vector3 p02 = new Vector3(o - l, w / 2, 0f);
  18.         Vector3 p03 = new Vector3(o - l, -w / 2, 0f);
  19.      
  20.             //rotate rectangle to match actor rotation
  21.         float theta1 = 2.0f * (float)Math.PI * (actor.Rotation.Y) / 180.0f;
  22.         Matrix rotM = Matrix.RotationZ((float)(theta1 / 2)); // rotate around Z-axis
  23.      
  24.         Vector3 curPos = new Vector3(actor.Location.X, actor.Location.Y, actor.Location.Z + zOffset);
  25.         p00 = Vector3.TransformCoordinate(p00, rotM) + curPos;
  26.         p01 = Vector3.TransformCoordinate(p01, rotM) + curPos;
  27.         p02 = Vector3.TransformCoordinate(p02, rotM) + curPos;
  28.         p03 = Vector3.TransformCoordinate(p03, rotM) + curPos;
  29.      
  30.         RawVector2 s00 = W2S(p00, POV);
  31.         RawVector2 s01 = W2S(p01, POV);
  32.         RawVector2 s02 = W2S(p02, POV);
  33.         RawVector2 s03 = W2S(p03, POV);
  34.         RawVector2[] square0 = { s00, s01, s02, s03, s00 };
  35.      
  36.         DrawLines(square0);
  37.         
  38.         // top rectangle
  39.         p00.Z += h; s00 = W2S(p00, POV);
  40.         p01.Z += h; s01 = W2S(p01, POV);
  41.         p02.Z += h; s02 = W2S(p02, POV);
  42.         p03.Z += h; s03 = W2S(p03, POV);
  43.      
  44.         RawVector2[] square1 = { s00, s01, s02, s03, s00 };
  45.         DrawLines(square1);
  46.      
  47.         // upper/lower rectangles get connected
  48.         DrawLine(new RawVector2(square0[0].X, square0[0].Y), new RawVector2(square1[0].X, square1[0].Y));
  49.         DrawLine(new RawVector2(square0[1].X, square0[1].Y), new RawVector2(square1[1].X, square1[1].Y));
  50.         DrawLine(new RawVector2(square0[2].X, square0[2].Y), new RawVector2(square1[2].X, square1[2].Y));
  51.         DrawLine(new RawVector2(square0[3].X, square0[3].Y), new RawVector2(square1[3].X, square1[3].Y));
  52.     }
复制代码


Code:
  1.             public void DrawLines(RawVector2[] point0)
  2.             {
  3.                 if (point0.Length < 2)
  4.                     return;
  5.      
  6.                 for (int x = 0; x < point0.Length - 1; x++)
  7.                     DrawLine(point0[x], point0[x + 1],);
  8.             }
复制代码


回复

使用道具 举报

 楼主| 发表于 2017-9-22 18:43 | 显示全部楼层
a2281476663 发表于 2017-9-22 07:22
吧主在吗11111111111111

1
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|96辅助游戏论坛

GMT+8, 2024-11-23 05:36 , Processed in 0.062150 second(s), 21 queries .

Powered by Discuz! X3.4

© 2016-2023 Comsenz Inc.

快速回复 返回顶部 返回列表