コード例 #1
0
 // 0x68: Train platform and stopping zone
 // [B0] [B1]
 // [B2] {[X1 X1] [Z1 Z1] [X2 X2] [Z2 Z2] [X3 X3] [Z3 Z3]}
 // [WW WW WW WW]
 // [AA] {[H0 H0] [H2 H2] [H4 H4] [H6 H6] [H8 H8] [HA HA] [HC HC] [HE HE] [HG HG] [HI HI] [BK]}
 // [CC] {[BZ]}
 private void decodeTrainPlatform(byte[] data)
 {
     uint start = BE.U32(data, 0x68);
      uint end = BE.U32(data, 0x6C);
      uint idx = start;
      int count;
      while (idx < end)
      {
     TrainPlatform platform = new TrainPlatform();
     platform.b0 = data[idx++];
     platform.b1 = data[idx++];
     count = data[idx++];
     platform.stoppingZone = new TrainPlatform.StoppingTriangle[count];
     for (uint i = 0; i < count; i++)
     {
        TrainPlatform.StoppingTriangle triangle = new TrainPlatform.StoppingTriangle();
        triangle.x1 = BE.I16(data, idx);
        triangle.z1 = BE.I16(data, idx + 2);
        triangle.x2 = BE.I16(data, idx + 4);
        triangle.z2 = BE.I16(data, idx + 6);
        triangle.x3 = BE.I16(data, idx + 8);
        triangle.z3 = BE.I16(data, idx + 0xA);
        idx += 0xC;
        platform.stoppingZone[i] = triangle;
     }
     platform.word = BE.U32(data, idx);
     idx += 4;
     count = data[idx++];
     platform.collision = new TrainPlatform.PlatformCollision[count];
     for (uint i = 0; i < count; i++)
     {
        TrainPlatform.PlatformCollision collision = new TrainPlatform.PlatformCollision();
        collision.x1 = BE.I16(data, idx);
        collision.y1 = BE.I16(data, idx + 2);
        collision.z1 = BE.I16(data, idx + 4);
        collision.x2 = BE.I16(data, idx + 6);
        collision.y2 = BE.I16(data, idx + 8);
        collision.z2 = BE.I16(data, idx + 0xA);
        collision.x3 = BE.I16(data, idx + 0xC);
        collision.y3 = BE.I16(data, idx + 0xE);
        collision.z3 = BE.I16(data, idx + 0x10);
        collision.h12 = BE.U16(data, idx + 0x12);
        collision.b14 = data[idx + 0x14];
        idx += 0x15;
        platform.collision[i] = collision;
     }
     count = data[idx++];
     platform.someList = new byte[count];
     for (uint i = 0; i < count; i++)
     {
        platform.someList[i] = data[idx];
        idx++;
     }
     trainPlatforms.Add(platform);
      }
 }
コード例 #2
0
        void drawPlatform(TrainPlatform platform, Color color)
        {
            GL.Enable(EnableCap.LineSmooth);
             GL.Enable(EnableCap.Blend);
             GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
             GL.Hint(HintTarget.LineSmoothHint, HintMode.DontCare);
             GL.Enable(EnableCap.PolygonOffsetLine);
             GL.PolygonOffset(-1.0f, -1.0f);
             GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
             GL.LineWidth(1.0f);
             GL.Color3(color);

             GL.Begin(PrimitiveType.Triangles);
             foreach (TrainPlatform.PlatformCollision tri in platform.collision)
             {
            GL.Vertex3(tri.x1, tri.y1, tri.z1);
            GL.Vertex3(tri.x2, tri.y2, tri.z2);
            GL.Vertex3(tri.x3, tri.y3, tri.z3);
             }
             GL.End();

             GL.Disable(EnableCap.LineSmooth);
             GL.Disable(EnableCap.Blend);
             GL.Disable(EnableCap.PolygonOffsetLine);
        }